Connect Voice AI with AgentStream
7 min
use exotel agentstream https //docs exotel com/exotel agentstream to stream live call audio to your bot over websocket, and play bot audio back to the caller this page gets you from zero to a working outbound test call pick one provider guide when you are ready to wire a full voice agent api reference connect voice ai api https //docs exotel com/exotel agentstream/connect voice ai api how it works caller ←→ exotel ←wss pcm→ your bot (public wss\ //) you run a bot that speaks the agentstream events connected , start , media , stop (and optionally mark / clear ) you expose that bot as a public wss\ // url (tls) you place a call with connect voice ai ( streamtype=bidirectional , streamurl = your bot) telephony default on agentstream is 8 khz, 16 bit pcm, mono always pass the sample rate your bot expects on the streamurl query string when the bot documents it (usually ?sample rate=8000 ) before you start you need notes exotel account account sid, api key, api token, exophone (callerid) a phone number to call e 164, for example +91… public wss cloudflared, ngrok, or your own https load balancer python 3 10+ for the sample bots and place connect call py clone the sample repo git clone https //github com/exotel/agent stream git cd agent stream cp shared/env exotel example shared/ env exotel \# edit shared/ env exotel with exotel account sid, exotel api key, \# exotel api token, exotel caller id pick a provider (about 15 minutes each) guide mode default port streamurl elevenlabs # speech to speech (convai) 10002 wss\ //host/v1/convai/conversation/exotel openai realtime # speech to speech (realtime ga) 5000 wss\ //host/?sample rate=8000 sarvam # stt → tts (saaras / bulbul) 8000 wss\ //host/ws?sample rate=8000 replace host with your tunnel hostname (no https // prefix on streamurl — use wss\ // ) place a connect call (shared helper) from the repo root, after your bot and tunnel are up set a && source shared/ env exotel && set +a python shared/place connect call py \\ \ to +91xxxxxxxxxx \\ \ stream url "wss\ //your host/…see table above…" endpoint used by the helper post /v1/accounts/{accountsid}/calls/connect auth http basic (api key / api token) field required description from yes callee in e 164 callerid yes your exophone streamurl yes bot wss url (keep under 600 characters) streamtype yes bidirectional go live checklist (any provider) bot listens on a stable host with a valid tls certificate (not a disposable laptop tunnel for production) secrets live in environment variables or a secret store — never in git streamurl path and sample rate match the provider readme exactly you verified pitch (not slow/deep) and at least one full user turn on a real handset you read agentstream wss errors and handling docid\ s fw4sf8jcmzgaofplv3b for disconnect and timeout behaviour next elevenlabs conversational ai # openai realtime # sarvam stt/tts #
