Skip to main content
Twilio is a cloud communications platform that provides programmable voice, messaging, and video services. Rapida integrates with Twilio to enable AI-powered phone conversations — both inbound (customers call your Twilio number) and outbound (your assistant calls customers).
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
You will need your Twilio Account SID and Auth Token, which you can find on the Twilio Console dashboard.

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.
1

Navigate to External Integrations

Go to Integration > Tools in the Rapida dashboard. You will see a grid of available external integrations.External Integrations Page
2

Select Twilio

Find the Twilio card and click “Setup Credential”.
3

Enter Your Twilio Credentials

Twilio CredentialsA modal will appear. Fill in the following fields:
FieldDescriptionWhere to Find
Key NameA friendly name for this credential (e.g., “Production Twilio”)Your choice
Account TokenYour Twilio Auth TokenTwilio Console → Auth Token
Account SIDYour Twilio Account SIDTwilio Console → Account SID
Click “Configure” to save.
4

Verify Connection

After saving, the Twilio card should display “Connected”. Click on it to see credential details, last updated time, and management options.

Step 2: Configure Phone Deployment

With credentials saved, configure your assistant’s phone deployment to use Twilio.
1

Open Your Assistant

Navigate to Assistants and select the assistant you want to deploy via phone.
2

Go to Phone Deployment

Click “Deploy”“Phone” to open the phone deployment configuration page.
3

Select Twilio as Telephony Provider

In the Telephony section:
  1. Select Twilio from the telephony provider dropdown
  2. Choose the Twilio credential you created in Step 1 from the Credential dropdown
  3. 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)
4

Configure Experience Settings

Set up the conversation experience:
SettingDescriptionDefault
GreetingThe first message the AI speaks when answering(optional)
Error MessageMessage spoken when an error occurs(optional)
Idle TimeoutSeconds before prompting an idle caller30
Idle MessageMessage spoken when caller is idle"Are you there?"
Idle Timeout RetriesHow many times to retry before ending call2
Max Call DurationMaximum call length in seconds300
5

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.
6

Save Deployment

Click “Deploy” to save. Your assistant is now ready to handle phone calls via 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.
1

Open Twilio Console

Go to Twilio Console → Phone Numbers → Active Numbers and select your phone number.
2

Set Voice Webhook

Under Voice Configuration, set:
FieldValue
A call comes inWebhook
URLhttps://websocket-01.in.rapida.ai/v1/talk/twilio/call/{your-assistant-id}?x-api-key={your-api-key}
HTTP MethodPOST
Replace {your-assistant-id} with your Rapida assistant ID.
3

Set Status Callback (Optional)

To receive call lifecycle events (ringing, answered, completed):
FieldValue
Status Callback URLhttps://websocket-01.in.rapida.ai/v1/talk/twilio/ctx/{contextId}/event?x-api-key={your-api-key}
Status Callback Eventsinitiated, 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.
4

Save

Click Save in the Twilio console. Your phone number is now connected to Rapida.

Making Outbound Calls

Once your phone deployment is configured, you can initiate outbound calls using the Rapida API or SDKs.
from rapida import Rapida

client = Rapida(api_key="rpd-xxx-your-key")

call = client.calls.create(
    assistant_id=123456789,
    to_number="+15551234567",
    from_number="+15559876543",  # optional, uses deployment default
    metadata={"campaign": "follow-up"},
)

print(f"Call queued: conversation_id={call.conversation.id}")

Features

FeatureDescription
Inbound CallsCustomers call your Twilio number and speak with your AI assistant
Outbound CallsInitiate calls programmatically via SDK or API
Real-time StreamingBidirectional audio via Twilio Media Streams (WebSocket)
Call RecordingAutomatic conversation capture for review and compliance
Status CallbacksReceive call lifecycle events (ringing, answered, completed)
WhatsAppSend and receive WhatsApp messages via Twilio
Global NumbersUse Twilio phone numbers from 100+ countries

Troubleshooting

  • 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
  • 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
  • Verify the Twilio credential is connected in Integration > Tools
  • Ensure the from_number is a valid Twilio phone number in your account
  • Check that the phone deployment is configured and saved
  • 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

For more information on Twilio’s platform, visit the Twilio Developer Documentation.