TwiML™ Voice: <Client>
<Client> noun specifies a client identifier to dial.
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
The client identifier should not contain control, space, delims, or unwise characters. Mobile SDKs cannot include any special characters and must only use alphanumeric characters and underscore.
<Client> noun supports the following attributes that modify its behavior:
|Attribute Name||Allowed Values||Default Value|
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
<Hangup>. If answerOnBridge attribute is used on
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
method attribute allows you to specify which HTTP method Twilio should
use when requesting the URL in the
url attribute. The default is
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:
completed for a
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
<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:
||This event is fired when Twilio starts dialing the call.|
||This event is fired when the call starts ringing.|
||This event is fired when the call is answered.|
||This event is fired when the call is completed, regardless of the termination status:
statusCallback attribute allows you to specify a URL for Twilio to send
webhook requests to on each event specified in the
attribute. Non-relative URLs must contain a valid hostname (underscores are not permitted).
statusCallbackMethod attribute allows you to specify which HTTP method
Twilio should use when requesting the URL in the
The default is
Status Callback HTTP Parameters
The parameters Twilio passes to your application in its asynchronous request to
StatusCallback URL include all parameters passed in a synchronous request
to retrieve TwiML when Twilio receives a call to one of your Twilio numbers.
The full list of parameters and descriptions of each are in the TwiML Voice
When the call progress events are fired, the Status Callback request also passes these additional parameters:
||A unique identifier for this call, generated by Twilio. You can use the
||A unique identifier for the parent call.|
||A descriptive status for the call. The value is one of
||The duration in seconds of the just-completed call. Only present in the
||The URL of the phone call's recorded audio. This parameter is included only if record is set on the
||The unique ID of the Recording from this call.
||The duration of the recorded audio (in seconds).
||The timestamp when the event was fired, given as UTC in RFC 2822 format.|
||A string that describes the source of the webhook. This is provided to help disambiguate why the webhook was made. On Status Callbacks, this value is always
||The order in which the events were fired, starting from
It is possible to include additional key value pairs that will be passed to the Client (Web or Mobile). You can do this by using the nested
<Parameter> TwiML noun.
These custom parameters can retrieved using the SDKs. For Client JS, refer to
Connection.customParameters, for iOS, refer to
TVOConnectOption.params, and for Android, refer to
Example 1: Dialing a client
In this example, we want to connect the current call to a client named
To connect the call to
joey, use a
<Client> noun nested inside.
Example 2: Simultaneous dialing
You can use up to ten total
<Dial> verb to dial multiple phone
numbers and clients 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.
Example 3: Call-progress events
In this case, we want to receive a webhook for each call-progress event when
dialing a Client using
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.