I am trying to get a notification from twilio when a user hangs up or when it is completed. I have already gotten my code to call the user but i cannot get a notification when the call is complete.
from twilio.rest import TwilioRestClient
def call():
account_sid = '************************'
auth_token = '***********************'
client = TwilioRestClient(account_sid, auth_token)
call = client.calls.create(to='+254723453841',
from_='+1 214-390-9422',
url='https://dl.dropbox.com/u/*******/acceptanceOfTerms.xml',
if_machine='Hangup', timeout=20, status_callback='https://dl.dropbox.com/u/*******/response.xml' )
print call.sid
print 'The Sid is '+ call.sid+' and the call status is '+call.status
Frrm the twilio documentation http://www.twilio.com/docs/quickstart/python/rest/call-request You are supposed to include a url for notification. My question is what is supposed to be the content of this file in the url and how i can receive a return on the status that a call has been completed or rejected etc..
I found the answer there : http://www.twilio.com/docs/api/twiml/twilio_request
After receiving a call, requesting TwiML from your app, processing it, and finally ending the call, Twilio will make an asynchronous HTTP request to the StatusCallback URL configured for the called Twilio number (if there is one). By providing a StatusCallback URL for your Twilio number and capturing this request you can determine when a call ends and receive information about the call.
Request Parameters
The parameters Twilio passes to your application in an asynchronous request to the StatusCallback URL include all those passed in a synchronous TwiML request.
Following the link http://www.twilio.com/docs/api/twiml/twilio_request#synchronous
When Twilio receives a call for one of your Twilio numbers it makes a synchronous HTTP request to the Voice URL configured for that number, and expects to receive TwiML in response. Twilio sends the following parameters with its request as POST parameters or URL query parameters, depending on which HTTP method you’ve configured.