Skip to contentSkip to navigationSkip to topbar
On this page

TwiML™ Voice: <Queue>


The <Dial> verb's <Queue> noun specifies a queue to dial. When dialing a queue, the caller will be connected with the first enqueued call in the specified queue. If the queue is empty, Dial will wait until the next person joins the queue or until the <Dial> timeout duration is reached. If the queue does not exist, Dial will post an error status to its action URL.


Noun Attributes

attributes page anchor

The <Queue> noun supports the following attributes that modify its behavior:

Attribute NameAllowed ValuesDefault Value
urlrelative or absolute URLnone
methodGET, POSTPOST
reservationSidReservation Sidnone
postWorkActivitySidActivity Sidnone

url

attributes-url page anchor

The url attribute takes an absolute or relative URL as a value. The URL points to a TwiML document that will be executed on the queued caller's end before the two parties are connected. This is typically used to be able to notify the queued caller that they are about to be connected to an agent or that the call may be recorded. The allowed verbs in this TwiML document are Play, Say, Pause, and Redirect.

Request Parameters

attributes-url-parameters page anchor

Twilio will pass the following parameters in addition to the standard TwiML Voice request parameters with its request to the value of the url attribute:

ParameterDescription
QueueSidThe SID of the queue.
CallSidThe CallSid of the dequeued call.
QueueTimeThe time the call spent in the queue in seconds.
DequeingCallSidThe CallSid of the call dequeuing the caller.

The method attribute takes the value GET or POST. This tells Twilio whether to request the url above via HTTP GET or POST. This attribute is modeled after the HTML form method attribute. POST is the default value.

If a call was enqueued with a TaskRouter Workflow Sid, you may specify a Reservation Sid in order to bridge this call to the enqueued caller. Once the call has been successfully bridged the pending Reservation will be marked as 'accepted'.

If a call is bridged using the 'reservationSid' attribute, you may specify an optional postWorkActivitySid value to indicate the what activity state that the Worker should be moved to after the call completes.


Example 1: Dialing a queue

examples-1 page anchor

In this example, the caller wants to dequeue a call from the 'support' queue. Before connecting, the following TwiML might be executed:

Dialing a queueLink to code sample: Dialing a queue
1
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2
3
4
const response = new VoiceResponse();
5
const dial = response.dial();
6
dial.queue({
7
url: 'about_to_connect.xml'
8
}, 'support');
9
10
console.log(response.toString());

Output

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Queue url="about_to_connect.xml">support</Queue>
5
</Dial>
6
</Response>

And the 'about_to_connect.xml" TwiML document which will be played to the caller waiting in the queue before connecting might look something like this:

1
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2
3
4
const response = new VoiceResponse();
5
response.say('You will now be connected to an agent.');
6
7
console.log(response.toString());

Output

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Say>You will now be connected to an agent.</Say>
4
</Response>

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.