<Play> verb plays an audio file back to the caller. Twilio retrieves
the file from a URL that you provide.
<Play> verb supports the following attributes that modify its behavior:
|Attribute Name||Allowed Values||Default Value|
|loop||integer >= 0||1|
|digits||integer >= 0, w||no default digits for Play|
The 'loop' attribute specifies how many times the audio file is played.
The default behavior is to play the audio once. Specifying '0' will cause
<Play> verb to loop until the call is hung up.
Use it like so:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Play loop="10">https://api.twilio.com/cowbell.mp3</Play> </Response>
The ‘digits’ attribute lets you play DTMF tones during a call.
For example, if you need to test an IVR system, you can use this feature to simulate digits being pressed to navigate through the menu options.
The "noun" of a TwiML verb is the stuff nested within the verb that's
not a verb itself; it's the stuff the verb acts upon. These are the
|plain text||The URL of an audio file that Twilio will retrieve and play to the caller.|
Twilio supports the following audio MIME types for audio files retrieved
|audio/mpeg||mpeg layer 3 audio|
|audio/wav||wav format audio|
|audio/wave||wav format audio|
|audio/x-wav||wav format audio|
|audio/aiff||audio interchange file format|
|audio/x-aifc||audio interchange file format|
|audio/x-aiff||audio interchange file format|
|audio/x-gsm||GSM audio format|
|audio/gsm||GSM audio format|
|audio/ulaw||μ-law audio format|
You can't nest any verbs within
<Play>. You can nest
<Play> within a
<Gather> verb, with one major exception - you can't play "digits" within a
This TwiML document tells Twilio to download the cowbell.mp3 file and play the audio to the caller.
<?xml version="1.0" encoding="UTF-8" ?> <Response> <Play>https://api.twilio.com/cowbell.mp3</Play> </Response>
We are going to test our IVR menu to make sure users can navigate properly. We know that the length of the initial greeting and the menu number we need to enter. We can add a few leading 'w' characters to add a pause. Each 'w' character tells Twilio to wait 0.5 seconds instead of playing a digit. This lets you adjust the timing of when the digits begin playing to suit the phone system you are dialing.
<?xml version="1.0" encoding="UTF-8" ?> <Response> <Play digits="wwww3"></Play> </Response>
<Play>ing a file that is longer than 40 minutes can result in a dropped call. If you need to
<Play>a file longer longer than 40 minutes, consider splitting it up into smaller chunks.