正文
guest_name
+
' telephone number empty not messaging'
wks_attendees
.
update_acell
(
'E'
+
str
(
num
),
'0'
)
# set number to 0
else
:
print
'Sending message to '
+
guest_name
client
.
messages
.
create
(
to
=
"+"
+
guest_number
,
# add the + back to make the number e.164
from_
=
""
,
# your twilio number here
body
=
message_body
,
)
wks_attendees
.
update_acell
(
'E'
+
str
(
num
),
int
(
wks_attendees
.
acell
(
'E'
+
str
(
num
)).
value
)
+
1
)
# increment the message count row
else
:
# else part of the loop
print
'finished'
因为短信可以看起来很简单,所以我添加了一些unicode来让它们有趣些。下面是幸运的受邀者接收到的短信样式:
接下来,我使用Flask作为我的web服务器,然后设置我的Twilio消息请求URL指向/messages url,并创建简单的if语句来解析回复 (yes, no):hello_guest.py
@app.route("/messages", methods=['GET', 'POST'])
def hello_guest():
if "yes" in body_strip:
# We have a keeper! Find the attendee and update their confirmation_status
wks_attendees.update_acell("F"+str(guest_confirmation_cell.row), 'Accepted') # update the status to accepted for that guest
resp.message(u"\u2665" + "Thanks for confirming, we'll be in touch!" + u"\u2665") # respond to the guest with a confirmation!
elif "no" in from_body.lower():
# update the confirmation_status row to declined for that guest
wks_attendees.update_acell("F"+str(guest_confirmation_cell.row), 'Declined')
# respond to the user confirming the action
resp.message("Sorry to hear that, we still love you though!")
else: # respond with invalid keyword
resp.message("You sent a different keyword, we need a yes or a no, you sent: "+
from_body)
return str(resp)
第一条消息是在2月19日早上8:37的时候发送的,而在3分钟后,也就是早上8:40收到了第一条回复。到了早上9:38,我收到了23条确认回复,这可是32%的接受率!初始群发短信2天后,我们收到了58%的客人的确认!尽管取得了明显的成功,但是我的未婚妻并不热衷于我那作为婚礼邀请服务(SAAWIS?)的短信,因此,我决定添加一些功能到我的应用中。
统计!我可以计算现场出席名单并按要求退回,给新娘即使反馈客人名单的成型。代码很简单,因为我已经在电子表格中设置了一些基本的计数器,因此,仅仅是抓取这些单元格的内容,并将其添加到短信中的事:hello_guest.py
# attendance variables
guest_confirmed = wks_attendees.acell('C70').value
guest_unconfirmed = wks_attendees.acell('C71').value
guest_no_response