The <Dial> verb's <Application> noun allows you to connect a call to another Twilio account without losing the original call leg's context (e.g. the original "From" number). Rather than dialing a phone number or SIP endpoint, you can <Dial> a TwiML App directly with <Dial><Application>. <Dial><Application> also supports sending custom parameters using <Parameter>.
You can also direct a call to a TwiML App within your TwiML account using <Dial><Application>.
Note: Simultaneous dialing is NOT supported when performing <Dial><Application>.
This page covers <Application>'s attributes, supported TwiML nouns, and supported <Dial> attributes.
To learn more about how use <Dial><Application>, how Twilio handles <Dial><Application> instructions, and an example scenario, go to the <Dial><Application> Usage page.
The TwiML example below shows the most basic use of <Dial><Application>.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const dial = response.dial();5const application = dial.application();6application.applicationSid('AP1234567890abcdef1234567890abcd');78console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Dial>4<Application>5<ApplicationSid>AP1234567890abcdef1234567890abcd</ApplicationSid>6</Application>7</Dial>8</Response>
<Application> supports the following attributes:
Attribute | Allowed Values | Default Value |
---|---|---|
customerId optional | a string up to 256 characters in length | The Twilio Account SID that is providing the <Dial><Application> TwiML instructions |
copyParentTo optional | true , false | false |
<Application>'s customerId
attribute allows you to set an identifier for the "sender" of the <Dial><Application>. The customerId
will be sent as a parameter in Twilio's request to the TwiML App's Voice Request URL.
The customerId
attribute can be any string up to 256 characters.
The default value of the customerId
attribute is the Account SID associated with the <Dial><Application> TwiML.
The customerId
attribute is optional.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const dial = response.dial();5const application = dial.application({6customerId: 'CustomerFriendlyName'7});8application.applicationSid('AP1234567890abcdef1234567890abcd');910console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Dial>4<Application customerId="CustomerFriendlyName">5<ApplicationSid>AP1234567890abcdef1234567890abcd</ApplicationSid>6</Application>7</Dial>8</Response>
<Application>'s copyParentTo
attribute, when set to true
, uses the parent call's To
parameter as the To
parameter in the request to the TwiML App's Voice URL.
When the copyParentTo
value is false
, the To
field is the dialed TwiML App's SID.
The default value of the copyParentTo
attribute is false
.
The copyParentTo
attribute is optional.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const dial = response.dial();5const application = dial.application({6copyParentTo: true7});8application.applicationSid('AP1234567890abcdef1234567890abcd');910console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Dial>4<Application copyParentTo="true">5<ApplicationSid>AP1234567890abcdef1234567890abcd</ApplicationSid>6</Application>7</Dial>8</Response>
<Application> accepts nested <ApplicationSid> and <Parameter> nouns.
<ApplicationSid> is required, while <Parameter> is optional.
In order to use <Dial><Application>, an <ApplicationSid> noun must be nested within <Application>'s opening and closing tags.
Between <ApplicationSid>'s opening and closing tags, specify the SID of the TwiML App that you wish to dial.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const dial = response.dial();5const application = dial.application();6application.applicationSid('AP1234567890abcdef1234567890abcd');78console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Dial>4<Application>5<ApplicationSid>AP1234567890abcdef1234567890abcd</ApplicationSid>6</Application>7</Dial>8</Response>
<Dial><Application> supports <Parameter> nouns, which allows you to pass custom parameters in Twilio's request to the receiving TwiML App's Voice URL.
You may nest one or more <Parameter> nouns within <Application>.
Each <Parameter> noun nested inside <Application> represents a key/value pair of information you wish to send in Twilio's request to the TwiML App's Voice URL.
The <Parameter> noun has two attributes:
name
- the name of your custom parametervalue
- the value of your custom parameterEach custom parameter is passed as a request parameter in Twilio's request to the TwiML App's Voice URL. In the request, each custom parameter's name
is prefixed with Param_
.
The TwiML example below shows how to use <Dial><Application> with nested <Parameter> nouns.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const dial = response.dial();5const application = dial.application();6application.applicationSid('AP1234567890abcdef1234567890abcd');7application.parameter({8name: 'AccountNumber',9value: '12345'10});11application.parameter({12name: 'TicketNumber',13value: '9876'14});1516console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Dial>4<Application>5<ApplicationSid>AP1234567890abcdef1234567890abcd</ApplicationSid>6<Parameter name="AccountNumber" value="12345"/>7<Parameter name="TicketNumber" value="9876"/>8</Application>9</Dial>10</Response>
For the example above, the body of Twilio's request to the TwiML App's Voice URL will contain Param_AccountNumber: "12345"
and Param_TicketNumber: "9876"
.
<Application> supports the following <Dial> attributes:
<Dial><Application> supports sending custom parameters from the dialed party back to the originating <Dial>'s action
URL. Learn more on the <Dial><Application> Usage page.
Note: REFER support via referUrl
is NOT supported when using <Dial><Application>.