4

How can you play music in a call with (preferably) a TwiML XML file? I have gotten so far as:

<!-- page located at http://example.com/simple_dial.xml -->
<Response>
<Dial>PHONE NUMBER</Dial>
<Play>
AUDIO FILE URL
</Play>
</Response>

but it waits until PHONE NUMBER hangs up to play the audio. How can I call a phone number, and then play an mp3 in the call?

John Sheehan
  • 77,456
  • 30
  • 160
  • 194
user1166110
  • 49
  • 1
  • 2

1 Answers1

2

Initiate a new call via the REST API, using a URL that returns the following TwiML:

<Response>
    <Play>AUDIO FILE URL</Play>
</Response>

Here's a quickstart tutorial that talks through the process of making an outbound call with the PHP helper library. It's equally easy with the libraries in the other languages as well.

John Sheehan
  • 77,456
  • 30
  • 160
  • 194
  • The Linked Quickstart also allows you to choose from .NET/C#, Ruby, and Python as languages that the examples are written in. – Ehtesh Choudhury Oct 26 '13 at 23:44
  • 6
    I'm confused. The original question was very specific, but you point to a documentation page that doesn't address the specific question. How do I play music on hold WHILE twilio attempts to connect my call? – Terry Riegel Sep 18 '14 at 17:01