Things you’ll need
- An active Exotel account with voice streaming enabled
- One or more Exotel provisioned phone numbers
- A public-facing server or tunneling service like ngrok (for dial-out only)
- API keys for speech-to-text, text-to-speech, and LLM services
Exotel Dial-in Example
Complete dial-in implementation using Exotel Voice Streaming over WebSocket
Exotel Dial-out Example
Outbound calling using Exotel Voice Streaming with WebSocket transport
Phone Number Setup
You’ll need Exotel phone numbers for both dial-in and dial-out functionality:- Visit exotel.com and purchase phone numbers
- Complete KYC verification if required
- Ensure voice streaming is enabled on your account (contact Exotel support if needed)
Environment Setup
Configure your environment variables for Exotel and AI services:.env
Dial-in
Dial-in allows users to call your Exotel number and connect to your Pipecat bot via WebSocket Voice Streaming. Unlike other providers, Exotel automatically provides caller information (to/from numbers) in the WebSocket messages, so no custom server is needed for basic dial-in functionality.How It Works
Here’s the sequence of events when someone calls your Exotel number:- Exotel receives an incoming call to your phone number
- Exotel executes your App Bazaar flow which includes a Voicebot applet
- Exotel opens a WebSocket to your server with real-time audio and call metadata
- Your bot processes the audio using the Pipecat pipeline
- The bot responds with audio sent back to Exotel over WebSocket
- Exotel plays the audio to the caller in real-time
Set up your App Bazaar flow
Exotel uses App Bazaar to configure call flows. For dial-in, you create an app with a Voicebot applet that establishes a WebSocket connection directly to your bot:- Navigate to App Bazaar in your Exotel dashboard
- Create a new app or edit an existing one
- Add a Voicebot applet (not “Stream” or “Passthru”)
- Configure the WebSocket URL:
wss://your-server.com/ws
- Add a Hangup applet at the end to properly terminate calls
Call Start → [Voicebot Applet] → [Hangup Applet]
Custom Data Limitations
Currently, there are limitations with passing custom data through query
parameters in Exotel’s WebSocket URLs. While the platform theoretically
supports query parameters, they may be stripped during call processing. This
is an ongoing limitation that may be addressed in future Exotel updates.
- Use different WebSocket endpoints for different call types
- Configure multiple App Bazaar flows for different scenarios
- Handle customization based on the called number (available in WebSocket messages)
Configure your Pipecat bot for dial-in
Your bot receives the WebSocket connection and automatically gets call information from Exotel’s WebSocket messages. The key components are: WebSocket Parsing: Pipecat’s built-in parser extracts call data from Exotel’s WebSocket messages:bot.py
bot.py
bot.py
Complete Bot Implementation
See the full bot.py with WebSocket parsing, transport setup, and pipeline
configuration
Set up Exotel phone number
Configure your Exotel phone number to use your App Bazaar flow:- Go to the Exotel Dashboard
- Navigate to ExoPhones
- Find your phone number and click the edit icon
- Under “App”, select your App Bazaar flow
- Save the configuration
Run the Example
For dial-in, you can run your bot directly without a separate server:Complete Setup Instructions
See the full README with step-by-step setup, App Bazaar configuration, and
testing
Dial-out
Dial-out allows your bot to initiate calls to phone numbers using Exotel’s outbound calling capabilities with WebSocket Voice Streaming.How It Works
Here’s the sequence of events for dial-out calls:- Your application triggers a dial-out (via API call or user action)
- Server initiates an Exotel call using the Voice API
- Exotel establishes the call and opens a WebSocket connection
- Your bot joins the WebSocket and sets up the pipeline
- The recipient answers and is connected to your bot
- The bot handles the conversation with real-time audio streaming
Set up your server for dial-out
The dial-out server creates outbound calls and manages WebSocket connections. When you trigger a dial-out call, your server:- Receives the dial-out request with target phone number and parameters
- Creates an Exotel call using the Voice API with a callback URL
- Accepts the WebSocket connection from Exotel
- Parses call data from the WebSocket messages
- Runs the Pipecat bot with the call information
Complete Server Implementation
See the full FastAPI server code with outbound call creation and WebSocket
handling
Configure your Pipecat bot for dial-out
The dial-out bot configuration is similar to dial-in, with Exotel automatically providing call information. Note the Custom Data Limitations section above. Call Information: Extract call details from Exotel’s WebSocket messages:bot.py
bot.py
Complete Bot Implementation
See the full bot.py with outbound call handling and call information usage
Run the Example
To test dial-out functionality:- Start your server: Run your FastAPI server
- Trigger a call: Make an API request to start an outbound call
- Answer your phone: The bot will call the specified number
- Talk to your bot: Have a conversation with your AI agent
Complete Setup Instructions
See the full README with step-by-step setup, API usage, and outbound call
configuration
Key Features
Audio Format and Sample Rate
Exotel Voice Streaming uses 8kHz mono audio with 16-bit PCM encoding. Configure your pipeline accordingly:Built-in Call Information
Like Telnyx, Exotel automatically includes comprehensive call information (to/from numbers, account details) in the WebSocket messages, eliminating the need for custom webhook servers in basic dial-in scenarios.Deployment
Local Development
Use ngrok to expose your local server for testing:Pipecat Cloud Deployment
For production deployment without managing your own infrastructure, use Pipecat Cloud:Exotel WebSocket on Pipecat Cloud
Deploy Exotel WebSocket bots with automatic scaling and managed infrastructure
Self-Hosted Production Deployment
For fully self-hosted production deployment, ensure your servers are:- Publicly accessible with HTTPS
- Able to handle concurrent WebSocket connections
- Properly configured with Exotel API credentials
- Implementing proper error handling and logging
Next Steps
- Explore the complete examples for full implementations
- Learn about Daily + Twilio SIP integration for advanced telephony scenarios
- Check out Daily PSTN integration for direct phone number provisioning