def web_inbound_call(button=None):
"""
Handles an inbound phone call
This function is called from twilio cloud back-end
"""
if button is None:
button = settings['server']['default']
logging.info("Receiving inbound call for button '{}'".format(button))
try:
button = decode_token(settings, button, action='call')
context = load_button(settings, button)
update, twilio_action = get_push_details(context)
response.content_type = 'text/xml'
behaviour = twilio.twiml.Response()
say = None
if 'call' in twilio_action:
for line in twilio_action['call']:
if line.keys()[0] == 'say':
say = line['say']
break
if say is None:
say = "What's up Doc?"
behaviour.say(say)
return str(behaviour)
except Exception as feedback:
if logging.getLogger().getEffectiveLevel() == logging.DEBUG:
logging.error("Unable to handle inbound call for '{}'".format(button))
raise
else:
logging.error(str(feedback))
response.status = 400
return 'Invalid request'
#
# the collection of buttons that we manage
#
评论列表
文章目录