-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusrResponse.py
More file actions
11 lines (11 loc) · 836 Bytes
/
usrResponse.py
File metadata and controls
11 lines (11 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/python
# -*- coding: utf-8 -*-def handle_user_response(request):
""" response handler function"""# twilio passes key pressed digits via form-data form key value Digitsdigits = request.POST.get('Digits', '')
response = VoiceResponse()# evaluate user input from phones keypad and take an appropriate actionif digits == '1':
response.play('http://demo.twilio.com/hellomonkey/monkey.mp3')
if digits == '2':
number = request.POST.get('From', '')
response.say('Thank you for calling, for more content see site blog'
)
response.sms('Thanks for trying out this tutorial, share with your friends!'
, to=number)# HttResponse will return xml response object for twilio api to processreturn HttpResponse(str(response), content_type='application/xml')