Dial
The<Dial> element connects the current call to another phone number, SIP endpoint, or Plivo user. When the dialed party answers, both parties are connected. When either party hangs up, the connection ends.
Basic Usage
Dial Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
action | URL | - | URL to receive dial completion status |
method | string | POST | HTTP method for action URL (GET, POST) |
timeout | integer | - | Seconds to wait for answer |
timeLimit | integer | 14400 | Maximum call duration in seconds |
callerId | string | caller’s ID | Caller ID to display |
callerName | string | caller’s name | Caller name (max 50 chars) |
hangupOnStar | boolean | false | Let caller hang up B-leg by pressing * |
redirect | boolean | true | Redirect to action URL when complete |
Callback Attributes
| Attribute | Type | Description |
|---|---|---|
callbackUrl | URL | URL for real-time dial events |
callbackMethod | string | HTTP method for callback (GET, POST) |
confirmSound | URL | URL returning XML to play when B-leg answers |
confirmKey | string | Key B-leg must press to accept call |
confirmTimeout | integer | Seconds to wait for confirm key |
dialMusic | URL | URL returning XML for ringback, or real |
digitsMatch | string | DTMF patterns to report (A-leg) |
digitsMatchBLeg | string | DTMF patterns to report (B-leg) |
sipHeaders | string | Custom SIP headers (key=value,key2=value2) |
Nested Elements
<Dial> must contain at least one nested element:
Number Element
Dial a phone number:| Attribute | Type | Default | Description |
|---|---|---|---|
sendDigits | string | - | DTMF digits to send after answer. Use w for 0.5s pause |
sendOnPreanswer | boolean | false | Send digits during early media |
User Element
Dial a SIP endpoint:Simultaneous Dialing
Ring multiple numbers at once. First to answer is connected:Sequential Dialing
Try numbers one at a time with timeouts:Dial with Confirmation
Require the called party to press a key to accept:confirmSound URL should return XML like:
Custom Caller ID
Custom Ringback
Play custom audio instead of the standard ring:dialMusic="real" to play the actual ringtone from the carrier.
Dial Extensions
Send DTMF tones after the call connects (useful for extensions):w adds a 0.5-second pause. This example waits 2 seconds, then dials extension 1234.
Dial Action URL Parameters
When the dial completes, these parameters are sent to theaction URL:
| Parameter | Description |
|---|---|
DialStatus | completed, busy, failed, cancel, timeout, no-answer |
DialRingStatus | true or false - whether the call rang |
DialHangupCause | Standard telephony hangup cause |
DialALegUUID | Call UUID of the A-leg (original caller) |
DialBLegUUID | Call UUID of the B-leg (empty if not answered) |
Dial Callback URL Parameters
Real-time events sent tocallbackUrl:
| Parameter | Description |
|---|---|
DialAction | answer, connected, hangup, digits |
DialBLegStatus | B-leg status |
DialALegUUID | A-leg call UUID |
DialBLegUUID | B-leg call UUID |
DialBLegDuration | Call duration (on hangup) |
DialBLegBillDuration | Billed duration (on hangup) |
DialBLegFrom | B-leg caller number |
DialBLegTo | B-leg destination |
DialDigitsMatch | Matched DTMF digits |
DialDigitsPressedBy | ALeg or BLeg |
DialBLegHangupCauseName | Hangup reason |
DialBLegHangupCauseCode | Hangup code |
DialBLegHangupSource | Who hung up |
STIRVerification | STIR/SHAKEN attestation |
Dial to SIP
Redirect
The<Redirect> element transfers call execution to a different URL. Plivo fetches new XML instructions from the specified URL and continues the call.
Basic Usage
Redirect Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
method | string | POST | HTTP method to use (GET, POST) |
Dynamic Routing
Redirect based on conditions:After Dial Failure
Redirect when a dial attempt fails:Conditional IVR Flow
Menu Loop
Create a menu that returns to itself:Redirect with GET Method
Redirect Request Parameters
When Plivo calls the redirect URL, it includes all standard request parameters:| Parameter | Description |
|---|---|
CallUUID | Unique call identifier |
From | Caller’s number |
To | Called number |
CallStatus | Current call status |
Direction | inbound or outbound |
Redirect Best Practices
- Avoid infinite loops - Ensure redirects eventually lead to an endpoint that doesn’t redirect
- Handle errors - Your redirect URL should always return valid XML
- Use HTTPS - All URLs should use HTTPS
- Pass context - Use query parameters to pass state between endpoints
Hangup
The<Hangup> element terminates the current call. Use it to gracefully end calls after completing a flow.
Basic Usage
Hangup Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
reason | string | - | Hangup reason: rejected, busy |
schedule | integer | - | Seconds to wait before hanging up |
Scheduled Hangup
End the call after a delay:Reject with Reason
Provide a hangup reason to simulate different call states:| Reason | Effect |
|---|---|
rejected | Caller hears rejection tone |
busy | Caller hears busy signal |
After IVR Timeout
After Business Hours
Block Spam Callers
Implicit Hangup
If your XML doesn’t end with<Hangup>, the call automatically ends when all elements are executed. However, it’s good practice to include it explicitly for clarity.
Wait
The<Wait> element pauses call execution for a specified duration. Use it for hold times, delays, or with answering machine detection.
Basic Usage
Wait Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
length | integer | 1 | Seconds to wait |
silence | boolean | false | Play silence (vs default hold music) |
minSilence | integer | - | Minimum silence milliseconds to detect |
beep | string | - | Detect beeps: true or beep parameters |
Silent Wait
By default,<Wait> plays hold music. For silence:
Delayed Call Answer
Use<Wait> to delay answering (useful for screening):
Answering Machine Detection
Detect answering machines by listening for beeps:Beep Detection Parameters
For fine-grained control, pass beep parameters as a comma-separated string:| Parameter | Default | Description |
|---|---|---|
duration | 300 | Beep duration in ms to match |
inter_silence | 50 | Silence between beeps (ms) |
intra_silence | 500 | Silence after beep to confirm (ms) |
threshold | 256 | Audio level threshold |
Silence Detection
Detect when the other party stops speaking:minSilence is the minimum silence duration in milliseconds to trigger detection.
Machine Detection Flow
Combine with<Speak> for voicemail drops:
Use in PreAnswer
Delay before answering the call:PreAnswer
The<PreAnswer> element plays audio to the caller before the call is answered. This is useful for custom ringback tones or screening calls. The caller is not billed during this phase.
Basic Usage
Nested Elements
<PreAnswer> can contain:
<Speak>- Text-to-speech messages<Play>- Audio files<Wait>- Pauses
Custom Ringback
Play music while connecting:Use Cases
| Use Case | Description |
|---|---|
| Custom ringback | Replace standard ring with music or branding |
| Legal notices | ”This call may be recorded” disclaimers |
| Spam screening | Delay answering to deter robocalls |
| Queue position | ”You are caller number 3” before answering |
Limitations
- Only
Speak,Play, andWaitelements are allowed - Call is not “answered” during PreAnswer, so some carriers may timeout
- Recommended to keep PreAnswer duration under 30 seconds
Related
- Audio Output - Speak, Play, DTMF
- Input Collection - GetDigits, GetInput
- Conferencing - Conference, MultiPartyCall
- Audio Streaming - Stream real-time audio