Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

TwiML™ Voice: <Client>


The <Dial> verb's <Client> noun specifies a client identifier to dial. The client identifier may be up to 256 characters.

You can use up to ten <Client> nouns within a <Dial> verb to simultaneously attempt a connection with many clients at once. The first client to accept the incoming connection is connected to the call and the other connection attempts are canceled. If you want to connect with multiple other clients simultaneously, read about the <Conference> noun.

(warning)

Warning

The client identifier should not contain control, space, delims, or unwise(link takes you to an external page) characters. Mobile SDKs cannot include any special characters and must only use alphanumeric characters and underscore.


Noun Attributes

attributes page anchor

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

Attribute NameAllowed ValuesDefault Value
urlAny URLnone
methodGET, POSTPOST
statusCallbackEventinitiated, ringing, answered, completednone
statusCallbackAny URLnone
statusCallbackMethodGET, POSTPOST

url

attributes-url page anchor

The url attribute allows you to specify a URL for a TwiML document that will run on the called party's end, after she answers, but before the parties are connected. You can use this TwiML to privately play or say information to the called party, or provide a chance to decline the phone call using <Gather> and <Hangup>. If answerOnBridge attribute is used on <Dial>, the current caller will continue to hear ringing while the TwiML document executes on the other end. TwiML documents executed in this manner are not allowed to contain the <Dial> verb.

The method attribute allows you to specify which HTTP method Twilio should use when requesting the URL in the url attribute. The default is POST.

When dialing out to a Client using <Dial>, an outbound call is initiated. The call transitions from the initiated state to the ringing state when the phone starts ringing. It transitions to the answered state when the call is picked up, and finally to the completed state when the call is over. With statusCallbackEvent, you can subscribe to receive webhooks for the different call progress events: initiated, ringing, answered, or completed for a given call.

The statusCallbackEvent attribute allows you to specify which events Twilio should call a webhook on. To specify multiple events separate them with a space: initiated ringing answered completed. If a statusCallback is provided and no status callback events are specified the completed event will be sent by default.

As opposed to creating an outbound call via the API, outbound calls created using <Dial> are initiated right away and never queued. The following shows a timeline of possible call events that can be returned and the different call statuses that a <Dial> leg may experience:

Outbound Dial call events diagram.
Node.js
Python
C#
Java
PHP
Ruby

_16
const VoiceResponse = require('twilio').twiml.VoiceResponse;
_16
_16
const response = new VoiceResponse();
_16
const dial = response.dial();
_16
const client = dial.client();
_16
client.identity('user_jane');
_16
client.parameter({
_16
name: 'FirstName',
_16
value: 'Jane'
_16
});
_16
client.parameter({
_16
name: 'LastName',
_16
value: 'Doe'
_16
});
_16
_16
console.log(response.toString());

Output

_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Dial>
_10
<Client>
_10
<Identity>user_jane</Identity>
_10
<Parameter name="FirstName" value ="Jane"/>
_10
<Parameter name="LastName" value ="Doe" />
_10
</Client>
_10
</Dial>
_10
</Response>

These custom parameters can retrieved using the SDKs. For the Voice JavaScript SDK, refer to Connection.customParameters, for iOS, refer to TVOConnectOption.params(link takes you to an external page), and for Android, refer to ConnectOptions.getParams()(link takes you to an external page)


Example 1: Dialing a Voice SDK device

examples-1 page anchor

In this example, we want to connect the current call to a client named joey. To connect the call to joey, use a <Dial> verb with a <Client> noun nested inside.

Dialing a Voice SDK device

dialing-a-voice-sdk-device page anchor
Node.js
Python
C#
Java
PHP
Ruby

_10
const VoiceResponse = require('twilio').twiml.VoiceResponse;
_10
_10
_10
const response = new VoiceResponse();
_10
const dial = response.dial();
_10
dial.client('joey');
_10
_10
console.log(response.toString());

Output

_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Dial>
_10
<Client>joey</Client>
_10
</Dial>
_10
</Response>

Example 2: Simultaneous dialing

examples-2 page anchor

You can use up to ten total <Number> and <Client> nouns within a <Dial> verb to dial multiple <Number>s and <Client>s at the same time. The first person to answer the call will be connected to the caller, while the rest of the call attempts are hung up.

Node.js
Python
C#
Java
PHP
Ruby

_12
const VoiceResponse = require('twilio').twiml.VoiceResponse;
_12
_12
_12
const response = new VoiceResponse();
_12
const dial = response.dial({
_12
callerId: '+1888XXXXXXX'
_12
});
_12
dial.number('858-987-6543');
_12
dial.client('joey');
_12
dial.client('charlie');
_12
_12
console.log(response.toString());

Output

_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Dial callerId="+1888XXXXXXX">
_10
<Number>858-987-6543</Number>
_10
<Client>joey</Client>
_10
<Client>charlie</Client>
_10
</Dial>
_10
</Response>

Example 3: Call-progress events

examples-3 page anchor

In this case, we want to receive a webhook for each call-progress event when dialing a Voice SDK device using <Dial>.

Node.js
Python
C#
Java
PHP
Ruby

_12
const VoiceResponse = require('twilio').twiml.VoiceResponse;
_12
_12
_12
const response = new VoiceResponse();
_12
const dial = response.dial();
_12
dial.client({
_12
statusCallbackEvent: 'initiated ringing answered completed',
_12
statusCallback: 'https://myapp.com/calls/events',
_12
statusCallbackMethod: 'POST'
_12
}, 'joey');
_12
_12
console.log(response.toString());

Output

_11
<?xml version="1.0" encoding="UTF-8"?>
_11
<Response>
_11
<Dial>
_11
<Client
_11
statusCallbackEvent='initiated ringing answered completed'
_11
statusCallback='https://myapp.com/calls/events'
_11
statusCallbackMethod='POST'>
_11
joey
_11
</Client>
_11
</Dial>
_11
</Response>


Rate this page: