def on_post(self, req, resp):
post_dict = parse_qs(req.context['body'])
msg_id = req.get_param('message_id', required=True)
if 'Digits' not in post_dict:
raise HTTPBadRequest('Digits argument not found')
# For phone call callbacks, To argument is the target and From is the
# twilio number
if 'To' not in post_dict:
raise HTTPBadRequest('To argument not found')
digits = post_dict['Digits'][0]
source = post_dict['To'][0]
try:
_, response = self.handle_user_response('call', msg_id, source, digits)
except Exception:
logger.exception('Failed to handle call response: %s' % digits)
raise
else:
resp.status = HTTP_200
resp.body = ujson.dumps({'app_response': response})
评论列表
文章目录