answer_url returns XML instructions that Plivo executes. This page covers the essential elements for AI voice agents.
Response
The root element for all Plivo XML. Every response must be wrapped in<Response>.
Stream
Stream real-time audio over WebSocket. See Audio Streaming XML for full details.| Attribute | Default | Description |
|---|---|---|
bidirectional | false | Enable two-way audio |
keepCallAlive | false | Wait for stream to end before continuing |
audioTrack | inbound | inbound, outbound, or both |
Speak
Text-to-speech during calls. Useful for greetings or fallbacks.| Attribute | Default | Description |
|---|---|---|
voice | WOMAN | WOMAN or MAN |
language | en-US | Language code (e.g., en-GB, es-ES) |
loop | 1 | Number of times to repeat |
Play
Play audio files (.mp3 or .wav).| Attribute | Default | Description |
|---|---|---|
loop | 1 | Number of times to repeat |
Dial
Connect calls to another number, SIP endpoint, or user.| Attribute | Default | Description |
|---|---|---|
callerId | - | Caller ID to display |
timeout | 30 | Ring timeout in seconds |
action | - | URL to call when dial completes |
method | POST | HTTP method for action URL |
Dial to SIP
Hangup
End the call.| Attribute | Description |
|---|---|
reason | Optional: rejected, busy |
schedule | Seconds to wait before hanging up |
Redirect
Fetch and execute XML from a different URL. Useful for dynamic call flows.| Attribute | Default | Description |
|---|---|---|
method | POST | GET or POST |
Wait
Pause execution for a specified duration.| Attribute | Default | Description |
|---|---|---|
length | 1 | Seconds to wait |
silence | false | If true, no hold music |
beep | false | Play beep after waiting |
GetDigits
Collect DTMF input from the caller. Useful for IVR before connecting to AI.| Attribute | Default | Description |
|---|---|---|
action | - | URL to send digits to |
timeout | 5 | Seconds to wait for input |
numDigits | 99 | Max digits to collect |
finishOnKey | # | Key that ends input |
retries | 1 | Number of retry attempts |
Record
Record call audio. Useful for compliance or training.| Attribute | Default | Description |
|---|---|---|
action | - | URL called when recording ends |
maxLength | 60 | Max recording duration in seconds |
fileFormat | mp3 | mp3 or wav |
transcriptionType | - | Set to auto for transcription |
Common Patterns
AI Agent with Greeting
IVR Before AI Agent
Transfer to Human
When your AI agent needs to transfer to a human:Related
- Audio Streaming XML - Stream element reference
- API Reference - Calls and Streams API
- Voice XML Overview - Complete XML reference