toto11
toto11

Reputation: 1582

Twilio TwiML XML String instead of url

I want to call the twilio voice API without providing the URL. Normally you would do it like this using python:

call = client.calls.create(url="http://demo.twilio.com/docs/voice.xml",
            to=request.receiver,
            from_=sender_number)

Instead of providing the URL I want to provide the XML-String. Is that somehow possible?

Background: I'm generating the XML via a google cloud endpoints api. The response is in JSON format and a variable contains the XML. I need to parse the JSON to get the XML.

Upvotes: 2

Views: 2705

Answers (2)

TwHello Inc
TwHello Inc

Reputation: 601

Sounds like you could use the echo Twimlet. https://www.twilio.com/labs/twimlets/echo

Echo will just output whatever TwiML is passed into it via the URL. It is useful for building stateless, outbound apps, where arbitrarily complex content of the call is pre-generated and just passed into the REST API to initiate a call.

Example: http://twimlets.com/echo?Twiml=%3CResponse%3E%3CSay%3EHi+there.%3C%2FSay%3E%3C%2FResponse%3E

Upvotes: 4

xmjw
xmjw

Reputation: 3434

Twilio Evangelist here. I'm afraid you cannot do this, however there are a number of solutions. If your call doesn't require any dynamic XML, you can host it on S3, or a similar service (I use Dropbox public links quite a lot).

If you do need dynamic XML, then we have a whole bunch of tutorials that can help you get setup with a simple web application.

Hope this helps!

Upvotes: 1

Related Questions