TwiML Trying to create Hold music during call forwarding

948 Views Asked by At

I'm trying to create an customized Music for Call forwarding.

When someone calling the it's redirecting to Enqueue named by "support".

<Response>
    <Enqueue waitUrl="waitMusic.xml"></Enqueue>
</Response>

waitMusic.xml (Playing the audio)

<Response>
    <Play>http://audio_file.mp3</Play>
</Response>

I don't know how to continue, I tried all out of things, and nothing works. Please help!

1

There are 1 best solutions below

2
On

You have 2 legs, the user leg and the agent leg.

When the user calls to Twilio's number, Twilio will do a request to your server which should return (same TwiML as you are using, but with a queue name):

<Response>
    <Enqueue waitUrl="waitMusic.xml">support</Enqueue>
</Response>

This puts the user in hold playing the music from waitMusic.xml if there are no agents available.

But you also need the logic for the agent. The agent will call to a Twilio phone, and in this case you'll return a different TwiML:

<Response>
    <Dial>
        <Queue url="agentWaitMusic.xml">support</Queue>
    </Dial>
</Response>

This is a "dial queue" (docs) that automatically dequeues any user that is on the the queue "support" and connects them together. If there are no users in the queue, the agent will be put on hold, playing the music from "agentWaitMusic.xml".

It's important to use the same queue name (in this case "support") for both, the "enqueue" and the "dial queue" actions.