DvaarikVoice API

Integrations / Plivo

Plivo to an AI voice agent

Stream a Plivo call into an AI voice agent and play the agent's speech back on the same socket. Setu handles the Plivo dialect and hands the voice engine plain PCM16, including the flush that makes barge-in work.

path /plivo · 8 kHz (16 kHz where the account allows L16) · written from the vendor's published reference

What Plivo sends and expects

Wire format
JSON text frames, base64 payload, L16 or μ-law
Sample rate
8 kHz (16 kHz where the account allows L16)
Flush playback on interruption
{"event":"clearAudio","streamId":…}

Carriers queue seconds of audio ahead of the caller. Without this frame, an interrupted caller keeps hearing a sentence the agent gave up on two seconds ago.

The trap

Playback is sent as playAudio rather than media, and the flush event is clearAudio — not clear. Code copied from a Twilio example connects, streams, and then silently fails to interrupt. Prefer L16 where your account allows it: it skips a codec conversion in both directions.

Wiring it up

Return Plivo XML that opens a bidirectional stream against the bridge.

1 · run the bridge

your server
export DVAARIK_API_KEY=dvk_live_...
export AGENT_PROMPT="You are Riya, the receptionist at Sunrise Dental."
npx @dvaarik/setu

2 · point Plivo at it

Plivo config
<Response>
  <Stream bidirectional="true" keepCallAlive="true">
    wss://your-host/plivo
  </Stream>
</Response>

Then call the number. Audio goes to the Voice API, the agent answers from your prompt, and the reply streams back on the same socket — billed from your prepaid balance at ₹1.50 to ₹3.75 a minute depending on the voice grade. Nothing about your Plivo account changes: the number, the trunk and the per-minute connectivity stay billed by Plivo.

Prefer to write it yourself?

You do not have to use the bridge. The protocol reference is one REST call and one WebSocket, and Setu is MIT licensed — the plivo.ts adapter is about a hundred readable lines. Copy it, port it, or read it to find out what the vendor docs left out. There is also a complete Python and FastAPI implementation in the repository's examples folder, covering the whole protocol including barge-in.