How It Works
Caller dials your external number
The call lands at your existing provider (the carrier where your number lives).
Provider routes the call to Plivo
Either as a forwarded call to a Plivo phone number (Option 1), or as a direct SIP INVITE to your Plivo application’s SIP URI (Option 2).
Plivo authenticates (Option 2 only)
For direct SIP, Plivo verifies the incoming call against your IP ACL or SIP credentials before accepting it.
Plivo executes your Application
The call hits your XML application’s Answer URL. Your server returns XML instructions (e.g.,
<Stream> to connect to a WebSocket-based AI agent).Two Options
| Option | What It Does | Best For |
|---|---|---|
| DID forwarding | Your provider forwards calls from your number to a Plivo number | Quick setup, no SIP knowledge required |
| Direct SIP (recommended) | Your provider sends SIP traffic directly to your Plivo application | Lower cost, lower latency, fewer failure points |
When to Use This
- You have phone numbers with carriers that don’t support porting
- You have geographic numbers (e.g., specific countries) where Plivo doesn’t offer numbers
- You have toll-free or vanity numbers you’ve owned for years and can’t move
- You want to connect existing PBX or contact center extensions to Plivo AI agents
- You’re testing AI voice agents on existing numbers without committing to porting
Option 1: DID Forwarding
The simplest approach. Configure your existing provider to forward all incoming calls to a Plivo phone number.Setup
Buy a Plivo number
Purchase a voice-enabled Plivo number and assign it to your XML application.
Configure forwarding in your provider
In your existing provider’s dashboard, set up call forwarding to route inbound calls to your Plivo number. The exact steps depend on your provider — look for “call forwarding”, “auto-forward”, or “external destination” settings.
Trade-offs
- Pros: Quick to set up, works with any provider that supports forwarding, no SIP knowledge needed
- Cons: Three call legs (caller → provider, provider → Plivo number outbound, Plivo number inbound). Higher cost and latency.
Option 2: Direct SIP (Recommended)
Configure your existing provider to send SIP traffic directly to your Plivo XML application’s SIP URI. Use SIP Authentication to secure the inbound stream.Why Direct SIP Is Recommended
- Lower cost — single Plivo SIP termination charge instead of provider forwarding + Plivo inbound
- Lower latency — eliminates the extra forwarding hop
- Better quality — fewer transcoding steps means cleaner audio
- Fewer failure points — fewer legs means fewer things that can go wrong
Setup
Find your Plivo application's SIP URI
Every Plivo application has a SIP URI in the format:Find your
app_id in the Plivo Console under Voice > Applications, or via the Application API.Create SIP authentication
Choose one auth method:Option A: IP ACL (recommended if your provider has stable outbound IPs)Option B: SIP digest credentials (use if your provider’s IPs change)
Configure your external provider
In your existing provider’s dashboard, configure inbound calls to your number to forward via SIP to:Look for “SIP termination”, “SIP forwarding”, or “external SIP destination” settings.If you’re using credentials, configure your provider with the username and password you created in Step 2.
Connecting to AI Voice Agents
Once your external number routes to a Plivo Application via SIP, your Answer URL can return the<Stream> XML element to connect to a WebSocket-based AI voice agent (Pipecat, LiveKit Agents, or your own framework).
Cost & Latency Comparison
For a typical 5-minute inbound call:| Approach | Legs | Cost Components |
|---|---|---|
| DID forwarding | 3 (caller → provider, provider → Plivo number outbound, Plivo number inbound) | Provider’s outbound forward rate + Plivo inbound rate |
| Direct SIP | 1 (caller → Plivo via SIP) | Plivo’s SIP termination rate only |
Verify It’s Working
After setup, make a test call and check youranswer_url callback for these parameters:
| Parameter | What It Confirms |
|---|---|
SIPAuthType | Auth method that ran (ip_acl, credential, or ip_acl_and_credential) |
SIPAuthUser | The authenticated username (credential auth only) |
SIPSourceIP | The caller’s source IP |
SIPAuthType is missing from the callback, auth is not running — the most common cause is the provider placing a phone number in the Request-URI instead of your app_id.
Security (Direct SIP)
- Always use SIP Authentication — leaving an XML app’s SIP URI open invites toll fraud and abuse
- Prefer IP ACL when possible — if your provider has stable outbound IPs, IP ACL is faster (no challenge/response handshake) and harder to abuse
- Use credentials when IPs are dynamic — if your provider rotates IPs, use SIP digest credentials with a strong password
- Beware of shared IPs — if your provider is on carrier-grade NAT or a shared-IP platform, IP ACL alone is not sufficient. Use
ip_acl_and_credentialfor defense in depth. - Combine both for maximum security — set
sip_auth_typetoip_acl_and_credentialto require both checks - Rate limiting is automatic — Plivo locks out IPs after 10 failed auth attempts in 60 seconds
Troubleshooting
| Issue | Solution |
|---|---|
| All calls get 403 Forbidden | Verify your provider’s outbound SIP IP matches an entry in your IP ACL, or that the credentials match exactly |
Calls succeed but no SIPAuthType in callback | Your provider is placing a phone number in the Request-URI instead of your app_id. Configure the provider to send INVITEs to sip:{app_id}@app.plivo.com. |
| Call rejected with 407 (then drops) | Your provider isn’t responding to the digest challenge. Configure the SIP credentials in your provider’s setup. |
| Auth passes but no XML executes | Check that the Application has a valid answer_url configured, and that your server returns valid XML |
| Calls work intermittently | Your provider may be rotating outbound IPs. Switch to credential auth, or expand your IP ACL CIDR range |
Full API Reference
- SIP Authentication API — Create and manage SIP credentials and IP Access Control Lists
- Application API — Configure
sip_auth_type,credential_uuid,ip_acl_uuidon your Plivo application - Voice Call API — Make outbound calls and retrieve call logs
Related
- Transfer to Human Agent — Route AI-handled calls to a human agent
- SIP Authentication — Full concept guide for IP ACL and credential auth
- Build with Audio Streaming — Connect external numbers to AI voice agents