DvaarikVoice API

Integrations / Telnyx

Telnyx to an AI voice agent

Fork a Telnyx call's media to an AI voice agent and stream the reply back. Setu handles the Telnyx dialect and hands the voice engine plain PCM16, including the flush that makes barge-in work.

path /telnyx · 8 kHz (PCMU by default; PCMA and L16 also handled) · written from the vendor's published reference

What Telnyx sends and expects

Wire format
JSON text frames, base64 RTP payload; codec from start.media_format.encoding
Sample rate
8 kHz (PCMU by default; PCMA and L16 also handled)
Flush playback on interruption
{"event":"clear"}

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

Telnyx defaults to an MP3 streaming mode and will silently discard raw audio unless the stream is set to rtp. The call connects, the agent thinks it is speaking, and nothing reaches the caller — with no error anywhere to explain it.

Wiring it up

Set the streaming mode to rtp and point the fork at the bridge when you answer the call.

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 Telnyx at it

Set the streaming mode to rtp and point the fork at the bridge when you answer the call. The bridge listens on /telnyx, so the target is wss://your-host/telnyx.

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 Telnyx account changes: the number, the trunk and the per-minute connectivity stay billed by Telnyx.

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 telnyx.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.