royce3
royce3

Reputation: 1422

play music to caller while simultaneous dial to multiple destinations

We've got a basic twiml set up that sends a call to multiple destinations, it looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Play loop="10">https://xxx.xxx.xxx/assets/MoH.wav</Play>
    <Dial>
        <Number>+1800XXXXXXX</Number>
        <Number>+1912XXXXXXX</Number>
    </Dial>
</Response>

The problem with this is that the <Dial> doesn't happen until the <Play> finishes. We want to play music to the caller while waiting for the call to be answered by one of the destination parties.

We've tried <Enqueue> to play the music but it still doesn't dial simultaneously.

Upvotes: -1

Views: 270

Answers (1)

philnash
philnash

Reputation: 73029

Twilio developer evangelist here.

You are right that TwiML expects to finish one verb before it starts the next, so in your example code it will play the <Play> all the way through before starting to dial the numbers.

If you want to play music to the caller while the dial happens, then you will need to use <Enqueue> to put them into a holding pattern while you dial the other numbers. However, you will not be able to use TwiML to dial the numbers, instead you will need to make the outbound calls using the REST API.

Once one of the outbound calls connects, you can then connect it with the original call by <Dial>ling in to the <Queue> that you placed the caller in. You will also want to end the other calls using the REST API.

Upvotes: 0

Related Questions