Skip to main content
Twilio sends a webhook when a call arrives. Rapida responds with TwiML that opens a bidirectional Media Stream (WebSocket) carrying μ-law 8kHz audio.

Vault Credentials

In the Rapida dashboard go to Credentials → Create Credential, select provider type Twilio:
KeyDescription
account_sidTwilio Account SID (ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
account_tokenTwilio Auth Token

Setup

1

Set the required env var

# docker/assistant-api/.assistant.env
PUBLIC_ASSISTANT_HOST=your-hostname.com   # HTTPS only, no protocol prefix
For local development, replace with your ngrok domain — see the ngrok guide.
2

Configure the Twilio phone number webhook

In Twilio ConsolePhone Numbers → Manage → Active numbers, select your number:
FieldValue
Voice webhook (HTTP POST)https://{PUBLIC_ASSISTANT_HOST}/v1/talk/twilio/call/{assistantId}
Status callback URLhttps://{PUBLIC_ASSISTANT_HOST}/v1/talk/twilio/ctx/{contextId}/event
Replace {assistantId} with the numeric assistant ID from the Rapida dashboard.
3

Attach vault credential to the assistant

In the assistant’s Phone Deployment, select the Twilio vault credential you created.
4

Test inbound call

Call your Twilio number. Rapida responds with:
<Response>
  <Connect>
    <Stream url="wss://{PUBLIC_ASSISTANT_HOST}/v1/talk/twilio/ctx/{contextId}"
            name="{assistantId}__{conversationId}"
            statusCallback="https://{PUBLIC_ASSISTANT_HOST}/v1/talk/twilio/ctx/{contextId}/event"
            statusCallbackEvent="initiated ringing answered completed">
      <Parameter name="assistant_id" value="{assistantId}"/>
      <Parameter name="client_number" value="{callerNumber}"/>
    </Stream>
  </Connect>
</Response>
PUBLIC_ASSISTANT_HOST must be an HTTPS hostname. Twilio rejects plain HTTP webhooks and WebSocket connections. Use wss:// (WebSocket Secure), not ws://.

Outbound Calls

Rapida calls client.Api.CreateCall via the Twilio Go SDK. The StatusCallback, StatusCallbackEvent, and Twiml are constructed automatically from PUBLIC_ASSISTANT_HOST. No additional configuration is required beyond the vault credential.

Audio Spec

PropertyValue
Encodingμ-law (PCMU) 8-bit
Sample rate8000 Hz
ChannelsMono
TransportBase64-encoded JSON frames (Media Streams spec)