Python Twilio making a call with Client
Python Twilio making a call with Client
I am trying to make a call using twilio and python with the code below:
account_sid = "***"
auth_token = "***"
client = Client(account_sid, auth_token)
call = client.calls.create(to=phone_number, from_="+***", record=True, url="https://handler.twilio.com/twiml/***")
print call.sid
Here is my xml on that url:
<Response>
<Say>Hi, Thanks for accepting our call!</Say>
</Response>
The call connects, but after the xml triggers, the call ends.
Can someone point me out what I am doing wrong?
I can successfully make a call by doing the approach below, but I need the callsid right after dial for storing the callsid in the database to retrieve the recording later:
resp = VoiceResponse()
dial = Dial(caller_id='+1***', record="record-from-ringing")
dial.number(phone_number, url="https://handler.twilio.com/twiml/***")
resp.append(dial)
return HttpResponse(resp, mimetype='text/xml')
The url above is the same as the first example, but after playing the SAY tag, the call connects. Doing this approach doesn't allow me to get the callsid.
Any ideas?
1 Answer
1
The first call example ends because you run out of TwiML. You can place your in that TwiML to then connect the outbound-api call to another party.
For the second example using a instead of a REST API to the Calls resource,
You can use the recordingStatusCallbackEvent attribute to be informed of those details, once the recording is available.
https://www.twilio.com/docs/voice/twiml/dial#recordingstatuscallbackevent
You would use the <Dial> to dial the other end of the call, or the child leg of the call. So the outbound-api dials one leg and the URL with the <Dial> the other and Twilio connects them together. To make it simple, just set up the customized call forward Twimlet - twilio.com/labs/twimlets/forward, as the URL. At the bottom of the page is the Twimlet generator you can use for your custom URL.
– Alan
2 days ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thanks for the answer. For the first example, I don't get it, so the xml should contain another dial? what specific tag should I use to connect the call? I tried dial and it just rings, like calling the same number.
– Batutoy Tria
Jul 2 at 17:19