How-to

Plivo integration

Integrate Plivo for cost-effective outbound campaigns and inbound call handling with PCM audio streaming.

Prerequisites

  1. Plivo account — Sign up at plivo.com and obtain your Auth ID and Auth Token.
  2. Phone numbers — Purchase Plivo numbers with voice capability in your target regions.
  3. Webhook access — Ensure your Breeze Buddy server is publicly accessible.
  4. Register numbers — Add your Plivo numbers via the Numbers API with provider: "plivo".
Environment VariableDescription
PLIVO_AUTH_IDYour Plivo Auth ID
PLIVO_AUTH_TOKENYour Plivo Auth Token

Outbound calls

calls.create()
Customer Answers
Plivo hits answer_url
Start Recording + AIC
Pod Allocation
WebSocket Audio
  1. API callcalls.create() with answer_url pointing to /plivo/answer
  2. Customer answers — Plivo hits the answer_url webhook
  3. Recording + noise cancellation — Recording starts and AIC noise enhancement is optionally enabled
  4. Pod allocation — Smart Router allocates a dedicated pod (production)
  5. WebSocket stream — XML response establishes a bidirectional PCM audio stream

Answer webhook

POST /plivo/answer
plivo-answer-response.xml
xml
<Response>
  <Stream streamTimeout="86400" keepCallAlive="true"
    contentType="audio/x-l16;rate=8000"
    bidirectional="true"
    url="wss://your-domain.com/agent/voice/breeze-buddy/ws/plivo">
    lead_id
  </Stream>
</Response>

Audio encoding

Plivo uses PCM L16 at 8 kHz — a key difference from Twilio and Exotel which use μ-law encoding.

ParameterValue
EncodingPCM L16 (linear 16-bit)
Sample Rate8000 Hz
Content Typeaudio/x-l16;rate=8000
Stream Timeout86400 seconds (24h)
Bidirectionaltrue

PCM vs μ-law

PCM L16 provides higher fidelity than μ-law at the same sample rate, but uses more bandwidth. The pipeline auto-detects the encoding based on the provider.

Callbacks

POST /plivo/callback/status
POST /plivo/callback/details
POST /plivo/callback/transfer

Warm transfer

Plivo uses calls.transfer() to redirect the active call to a dial-up webhook:

AI triggers transfer
calls.transfer() → /dial-up
Webhook returns Dial XML
Customer bridged to agent
AI disconnects
POST /plivo/dial-up
plivo-dial-response.xml
xml
<Response>
  <Dial callerId="{outbound_number}">
    <Number>{transfer_number}</Number>
  </Dial>
</Response>

Recording

Unlike Twilio’s native record=True, Plivo requires recording to be started explicitly via the API:

plivo_recording.py
python
plivo_client.calls.record(
    call_uuid=call_uuid,
    callback_url=f"{base_url}/plivo/callback/details"
)

Cost Optimization

Plivo generally offers lower per-minute rates than Twilio for voice calls, especially in international markets. Compare pricing for your target regions before selecting a provider.

Next steps

Was this helpful?