Skip to main content
Plivo XML controls call behavior. Your 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.

Speak

Text-to-speech during calls. Useful for greetings or fallbacks.

Play

Play audio files (.mp3 or .wav).

Dial

Connect calls to another number, SIP endpoint, or user.

Dial to SIP

Dial to Authenticated SIP (Transfer to Human Agent)

When transferring an AI-handled call to a human agent, the agent’s softphone or contact center software typically sits behind a SIP server that requires authentication. Pass credentials on the <User> element so Plivo can authenticate with the remote SIP provider.
When the remote provider responds with 407 Proxy Authentication Required, Plivo automatically computes the digest response and re-sends the INVITE with authentication headers. If authentication fails, the call ends with hangup cause sip_auth_failed (code 4240). If the provider doesn’t respond, the call ends with sip_auth_timeout (code 4250). Your hangup callback receives these values in HangupCauseName and HangupCauseCode, so your agent application can detect and handle failed handoffs (e.g., retry with a different endpoint, fall back to a phone number, or inform the caller). You can also initiate an authenticated transfer programmatically via the Make Call API using sip_auth_username and sip_auth_password — useful for server-initiated warm transfers. The same <User sipAuthUsername=... sipAuthPassword=...> pattern works regardless of whether the parent call came from an AI agent, a classic XML app, or an inbound PSTN call. Plivo sends an initial INVITE without credentials. If the agent PBX responds with 401 Unauthorized or 407 Proxy Authentication Required, the outbound SBC re-sends the INVITE with the supplied credentials. For complete details on SIP authentication options, flow diagrams, and security best practices, see SIP Authentication.

extraHeaders and SIP Authentication

When using <Stream extraHeaders="..."> on an inbound leg that uses SIP authentication, the same raw-mode rendering rules apply: customer-supplied headers are emitted without the X-PH- prefix. Headers with reserved prefixes (PH-, Plivo, FS-, SipAuth, ZT-, Twilio) and the name ClientRegion are silently dropped. See SIP Authentication for the full list.

Hangup

End the call.

Redirect

Fetch and execute XML from a different URL. Useful for dynamic call flows.

Wait

Pause execution for a specified duration.

GetDigits

Collect DTMF input from the caller. Useful for IVR before connecting to AI.

Record

Record call audio. Useful for compliance or training.

Common Patterns

AI Agent with Greeting

IVR Before AI Agent

Transfer to Human

When your AI agent needs to transfer to a human: