Skip to main content

Bot stream with Legs API

Start a bidirectional AgentStream session from Legs actions — with an optional greeting while the bot warms up.

For the full outbound/inbound ExoML path, see Programmable Voice with AgentStream.

Patterns​

GoalPattern
Bot-first / tech supportleg_answered → start_stream
Sales / collections (no dead air)leg_answered → start_stream + start_say → on stream_started → stop_say
Per-call stream URLDecide url in your service at runtime

Authentication​

HTTP Basic Auth. Content-Type: application/json

Base URL: https://cpaas-api.in.exotel.com/v2/accounts/{account_sid}
(Singapore: cpaas-api.exotel.com)


Start stream​

Request parameters​

ParameterRequiredTypeDescription
directionYesStringbidirectional
urlYesStringBot WebSocket URL
content_typeNoStringe.g. audio/x-mulaw;rate=8000

Example request​

curl -u '<api_key>:<api_token>' -X POST \
'https://cpaas-api.in.exotel.com/v2/accounts/<account_sid>/legs/<leg_sid>/actions/start_stream' \
-H 'Content-Type: application/json' \
-d '{
"direction": "bidirectional",
"url": "wss://bot.example.com/stream",
"content_type": "audio/x-mulaw;rate=8000"
}'

Try It​


Parallel greeting​

Start say​

curl -u '<api_key>:<api_token>' -X POST \
'https://cpaas-api.in.exotel.com/v2/accounts/<account_sid>/legs/<leg_sid>/actions/start_say' \
-H 'Content-Type: application/json' \
-d '{ "text": "Connecting you now.", "loop": 0 }'

Try It​

Stop say​

curl -u '<api_key>:<api_token>' -X POST \
'https://cpaas-api.in.exotel.com/v2/accounts/<account_sid>/legs/<leg_sid>/actions/stop_say'

Try It​

After stream starts​

Your bot receives the same WebSocket protocol events as Voicebot applet sessions.