All posts

One API call. Your AI bot is on the phone.

Saurabh Sharma
Saurabh Sharma
·

We launched Connect Voice AI API. If you’re building outbound voice agents with Exotel, this changes how you work.

The problem we were solving

The previous way to wire an outbound call to a voice bot required three steps: build a Flow in Exotel’s Flow Builder, add a media streaming node inside it pointing at your WebSocket server, then trigger the flow via the outbound calls API. Three things to configure, three places they could break. When a call failed, you were debugging across Flow Builder, streaming config, and your WebSocket server simultaneously.

We heard this from multiple teams: “I’m not building an IVR. I’m building a bot. Why do I need a flow?”

They were right. So we removed the requirement.

What Connect Voice AI API does

One POST request dials a number and opens a bidirectional audio stream directly to your WebSocket server. No flow required.

curl -X POST ‘https://<api_key>:<api_token>@api.in.exotel.com/v1/Accounts/<AccountSid>/Calls/connect’ \
-F ‘From=+91XXXXXXXXXX’ \
-F ‘CallerId=0XXXXXXXXXX’ \
-F ‘StreamUrl=wss://your-bot.example.com/media’ \
-F ‘StreamType=bidirectional’
  • From — customer’s number in international format
  • CallerId — your Exotel virtual number
  • StreamUrl — your bot’s WebSocket endpoint (ws:// or wss://)
  • StreamType=bidirectional — full-duplex: you receive caller audio and send bot audio on the same connection

Use api.in.exotel.com for India (Mumbai), api.exotel.com for Singapore.

The API returns a Call object immediately with a Sid. The call is still connecting at that point — use StatusCallback to track what actually happened.

Audio format

Exotel sends raw PCM or mulaw at 8 kHz by default. Append sample-rate to your StreamUrl if your model expects something different:

StreamUrl=wss://your-bot.example.com/media?sample-rate=16000

Supported values: 8000, 16000, 24000.

Optional parameters worth knowing

Record=true — records the call. RecordingUrl arrives in your terminal status callback once the call ends.

RecordingChannels — single merges both sides into one track; dual records caller and bot separately. Use dual if you’re building analysis pipelines that need to distinguish speaker turns.

TimeLimit — maximum call duration in seconds, up to 14,400 (4 hours). Set this for automated campaigns.

StatusCallback — webhook for call state updates. Filter with StatusCallbackEvents[]: answered, terminal, ringing. Available for leg1 only.

CustomField — up to 128 characters of metadata attached to the call record. Carry a customer ID or campaign ID through to your callback without maintaining a separate mapping table.

StreamName — label for the stream, up to 32 characters. Useful for logging in multi-stream setups.

Your bot ends the call by closing the WebSocket connection.

Call status values

Status Meaning
queued Call is being prepared
in-progress Call is active
completed Call ended normally
failed Call could not be placed
busy Number was busy
no-answer Number did not answer

Two APIs, one decision

Connect Voice AI API is one of two ways to connect a bot to an Exotel call. The other — Connect Voice AI with Flow API — uses the same endpoint but takes a url pointing to an Exotel Flow instead of a streamUrl. The Flow wraps the conversation and lets you add IVR menus, compliance recordings, DTMF collection, and bot-to-agent handoffs.

Connect Voice AI API Connect Voice AI with Flow API
Core param StreamUrl — direct to bot url — Exotel Flow URL
Use when Bot handles the entire call IVR, compliance disclosure, human handoff
Bot control Bot decides everything Flow controls the wrapper; bot handles the conversation

Bot dials, converses, hangs up — use this API. Need a pre-call compliance recording or a mid-call “press 1 for an agent” — use the Flow API.

What a real deployment looks like

Outbound collections bot:

  1. Backend pulls customers due for follow-up
  2. POST to Calls/connect for each: StatusCallback, CustomField=your_customer_id, Record=true
  3. Customer picks up → WebSocket opens → bot handler starts the conversation
  4. Bot closes WebSocket when done
  5. Terminal status callback fires with duration and RecordingUrl
  6. Backend logs outcome against the customer record

Fully testable with a single number and a local WebSocket server before you run it at scale. The full StreamUrl including query parameters must stay under 600 characters.

This feature must be enabled on your account before use. Contact hello@exotel.com or Exotel Communityto get started.

Full docs: Connect Voice AI API