Twilio uses WebSocket media streams for real-time audio. When a call connects, Twilio opens a WebSocket to Rapida carrying μ-law encoded audio at 8kHz. Rapida handles all codec conversion and resampling transparently.
How It Works
Prerequisites
Twilio Account
An active Twilio account with at least one phone number
Rapida Account
An active Rapida account with a configured voice assistant
Step 1: Set Up Provider Credentials
First, store your Twilio API credentials in Rapida so the platform can authenticate with Twilio for outbound calls and webhook validation.Navigate to External Integrations
Go to Integration > Tools in the Rapida dashboard. You will see a grid of available external integrations.

Enter Your Twilio Credentials

| Field | Description | Where to Find |
|---|---|---|
| Key Name | A friendly name for this credential (e.g., “Production Twilio”) | Your choice |
| Account Token | Your Twilio Auth Token | Twilio Console → Auth Token |
| Account SID | Your Twilio Account SID | Twilio Console → Account SID |
Step 2: Configure Phone Deployment
With credentials saved, configure your assistant’s phone deployment to use Twilio.Select Twilio as Telephony Provider
In the Telephony section:
- Select Twilio from the telephony provider dropdown
- Choose the Twilio credential you created in Step 1 from the Credential dropdown
- Enter your Phone number — this is the Twilio phone number that will receive inbound calls and serve as the caller ID for outbound calls (e.g.,
+15551234567)
Configure Experience Settings
Set up the conversation experience:
| Setting | Description | Default |
|---|---|---|
| Greeting | The first message the AI speaks when answering | (optional) |
| Error Message | Message spoken when an error occurs | (optional) |
| Idle Timeout | Seconds before prompting an idle caller | 30 |
| Idle Message | Message spoken when caller is idle | "Are you there?" |
| Idle Timeout Retries | How many times to retry before ending call | 2 |
| Max Call Duration | Maximum call length in seconds | 300 |
Configure Audio Providers
Select your Speech-to-Text (STT) and Text-to-Speech (TTS) providers. These determine how audio is transcribed and synthesized during the call.
For Twilio calls, audio arrives in μ-law 8kHz format. Rapida automatically resamples to 16kHz for the STT provider and converts TTS output back to μ-law for Twilio.
Step 3: Configure Your Twilio Phone Number
Point your Twilio phone number’s webhook to Rapida so incoming calls are routed to your AI assistant.Open Twilio Console
Go to Twilio Console → Phone Numbers → Active Numbers and select your phone number.
Set Voice Webhook
Under Voice Configuration, set:
Replace
| Field | Value |
|---|---|
| A call comes in | Webhook |
| URL | https://websocket-01.in.rapida.ai/v1/talk/twilio/call/{your-assistant-id}?x-api-key={your-api-key} |
| HTTP Method | POST |
{your-assistant-id} with your Rapida assistant ID.Set Status Callback (Optional)
To receive call lifecycle events (ringing, answered, completed):
| Field | Value |
|---|---|
| Status Callback URL | https://websocket-01.in.rapida.ai/v1/talk/twilio/ctx/{contextId}/event?x-api-key={your-api-key} |
| Status Callback Events | initiated, ringing, answered, completed |
The status callback URL uses a
contextId returned during the call setup. Twilio sends events to this URL automatically when configured in TwiML.Making Outbound Calls
Once your phone deployment is configured, you can initiate outbound calls using the Rapida API or SDKs.- Python
- Node.js
- cURL
Features
| Feature | Description |
|---|---|
| Inbound Calls | Customers call your Twilio number and speak with your AI assistant |
| Outbound Calls | Initiate calls programmatically via SDK or API |
| Real-time Streaming | Bidirectional audio via Twilio Media Streams (WebSocket) |
| Call Recording | Automatic conversation capture for review and compliance |
| Status Callbacks | Receive call lifecycle events (ringing, answered, completed) |
| Send and receive WhatsApp messages via Twilio | |
| Global Numbers | Use Twilio phone numbers from 100+ countries |
Troubleshooting
Calls go to voicemail instead of Rapida
Calls go to voicemail instead of Rapida
- Verify the webhook URL in your Twilio phone number configuration
- Ensure the URL uses
https://and the correct assistant ID - Check that your Rapida API key is valid
One-way audio or no audio
One-way audio or no audio
- Verify your Twilio credential (Account SID + Auth Token) is correct in Rapida
- Check that your STT and TTS providers are configured in the phone deployment
- Ensure the assistant has an active version with a valid LLM provider
Outbound calls fail
Outbound calls fail
- Verify the Twilio credential is connected in Integration > Tools
- Ensure the
from_numberis a valid Twilio phone number in your account - Check that the phone deployment is configured and saved
Status callbacks not received
Status callbacks not received
- Ensure the status callback URL is configured in Twilio console
- Verify the URL format:
https://websocket-01.in.rapida.ai/v1/talk/twilio/ctx/{contextId}/event?x-api-key={your-api-key} - Check Twilio’s Debugger for webhook errors
Related Resources
Create an Assistant
Build your voice AI assistant
Phone Deployment
Overview of phone deployment options
Outbound Call API
API reference for creating calls
Conversation Logs
View call history and transcripts