Search code examples
pythonresttwiliooutbound

Twilio REST API: making calls with android and python / flask


I'm working on an android app using twilio to make calls / conferences and had everything working good using just the TwiML. Now i need to track events so i'm switching to the Rest API and am having trouble getting the calls to connect.

I have the android and python quickstart projects working, but the examples given use the Say verb or Dial verb. Now I'm trying to actually make and connect calls from one phone with the test app to another phone. I don't need it to speak to me or dial another number when it connects, i just need it to answer and allow the parties to talk to one another.

From the documentation... URL Parameter: When you initiate a call through the REST API, Twilio makes a synchronous HTTP request to the URL found in the value of the 'Url' POST parameter, in order to retrieve TwiML for handling the call.

This page of the python tutorial shows exactly where i need help. The piece of the puzzle i'm missing is the correct TwiML response that twilio needs when the call connects. https://www.twilio.com/docs/tutorials/walkthrough/click-to-call/python/flask#7

What i've tried..

  1. an empty Response -- results with an immediate hang up.

  2. return just a 200 status code -- results with an immediate hang up and twilio error for invalid content type.

  3. an empty Say verb with loop attribute set to 0 to simulate an inifnite loop while the call is connected. resulted in an android Connection Declined error.

I'm hoping a twilio evangelist finds this and helps with this seemingly easy answer. It has eluded me for an embarrassingly amount of time.

I can post my python code if that would be useful, but the link above is essentially exactly what i'm working with.


Solution

  • Twilio developer evangelist here.

    In this case, you do need to onto the number you are trying to connect to. In the Android quick start python server application, the application sends a To parameter as part of the request and these lines use that To number to generate the <Dial>.

    Let me know if that makes sense and helps at all.