def handle_sms():
"""Handles Twillio SMS message"""
customer_phone_number = request.values["From"]
text_message_body = request.values["Body"]
# Retrieve the customer from the DB or create a new one
customer = Customer.get_customer_by_phone_number(customer_phone_number)
if not customer:
# Save the customer to the DB
customer = Customer.create_new({
CFields.PHONE_NUMBER: customer_phone_number,
})
customer.create()
customer_lc.on_new_customer()
messaging.on_message_recieve(customer, text_message_body)
return jsonpickle.encode(dict(
success=True
))
评论列表
文章目录