handsome
handsome

Reputation: 2392

place incoming call in queue and call agents with twilio

hello Im using Twilio and I want to put the caller on a queue. then call all the agents sequentially and if an agent pick up the phone I want to connect him with the caller that´s on a queue.

this is what I have so far but when I call I hear the agent voice mail. no waiting music.

<?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Say>Please wait while we connect you to the next available agent.</Say>
        <Enqueue>support</Enqueue>
        <Dial timeout="15" url="/call-queue">+100000000</Dial>
        <Dial timeout="15" url="/call-queue">+100000001</Dial>
        <Dial timeout="15" url="/call-queue">+100000002</Dial>
    </Response>

the response for /call-queue is

<?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Dial>
            <Queue>support</Queue>
        </Dial>
    </Response>

my goal is for the caller to wait in line with some music until one agent pickup the phone.

any ideas? is this the right approach? thank you!

update:

the caller gets added to the call like this

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Please wait while we connect you with the next agent.</Say>
    <Enqueue>support</Enqueue>
</Response>

then I make a REST call to call the agent

twilio.calls
    .create({
        url: "example.com/call-queue",
        from: myTwilioNumber,
        to: agentNumber
    })
    .then(call => console.log("twilio call sid", call.sid))
    .catch(error => console.log("twilio call error", error));

example.com/call-queue only returns

<Dial><Queue>support</Queue></Dial>

Upvotes: 0

Views: 981

Answers (1)

philnash
philnash

Reputation: 73029

Twilio developer evangelist here.

That's not the approach you want there. Following the <Enqueue> with <Dial> will just queue the caller and should not travel onto the next <Dial> until the caller leaves the queue again.

Since you have multiple agents, you might want to look into TaskRouter to achieve this. With TaskRouter you queue the incoming call and then a workflow that you define will attempt to dial your agents. Your agents can also choose to accept the incoming call or send it back to the queue. The TaskRouter call routing is also sensitive to agents already being calls and not trying to route to them.

Check out the documentation on queueing Twilio calls with TaskRouter to learn more.

Upvotes: 1

Related Questions