Why ngrok is Required
Twilio, Vonage, and Exotel use a two-step call setup:- They send an HTTP POST webhook to your server when a call arrives
- They open a WebSocket to your server to stream bidirectional audio
You need a single ngrok tunnel pointing to port
8080 (the Nginx gateway). All webhook and WebSocket traffic flows through Nginx and is proxied to assistant-api.Prerequisites
| Tool | Version | Install |
|---|---|---|
| ngrok | v3+ | ngrok.com/download |
| Rapida stack | running | make up-all |
Step-by-Step Setup
Install and authenticate ngrok
Start the tunnel
https:// URL — this is your PUBLIC_ASSISTANT_HOST.The free tier generates a random URL on each restart. To get a stable URL across restarts, use a paid ngrok plan with a reserved domain.
Update media URL in the UI config
Edit The
ui/src/configs/config.development.json:media field is the public URL the browser and telephony providers use for WebSocket connections.Verify the tunnel is proxying correctly
Configuring Twilio for Local Testing
With ngrok running, point your Twilio phone number’s webhook to:- Inbound call
- Outbound call
- Open Twilio Console → Phone Numbers → Active Numbers
- Select your number
- Under Voice Configuration, set:
| Field | Value |
|---|---|
| A call comes in | Webhook |
| URL | https://abc123.ngrok-free.app/v1/talk/twilio/call/{assistantId} |
| HTTP Method | POST |
- Call the number — Twilio posts the webhook to ngrok, which forwards to your local assistant-api
Configuring Vonage for Local Testing
Point your Vonage Application’s Answer URL to:- Open Vonage Dashboard → Applications → select your app
- Under Capabilities → Voice → Answer URL, set the URL above
- Set Event URL to:
https://abc123.ngrok-free.app/v1/talk/vonage/ctx/{contextId}/event
Configuring Exotel for Local Testing
In your Exotel App (applet), set the webhook URL to:Two Configurations Always Need Updating
When your ngrok URL changes (e.g., after a free-tier restart), update both of these:| File | Field | Value |
|---|---|---|
docker/assistant-api/.assistant.env | PUBLIC_ASSISTANT_HOST | abc123.ngrok-free.app (no https://) |
ui/src/configs/config.development.json | connection.media | https://abc123.ngrok-free.app (with https://) |
Stable URLs (Recommended for Team Development)
Using a random URL is inconvenient for team development since the webhook URL in Twilio/Vonage must be updated every time ngrok restarts. Options for a stable URL:| Option | Description |
|---|---|
| ngrok reserved domain | Paid ngrok plan — assign a fixed subdomain |
| ngrok static domain | Free tier offers one free static domain: ngrok http --domain=your-name.ngrok-free.app 8080 |
| Cloudflare Tunnel | Free alternative — cloudflared tunnel --url http://localhost:8080 |
Troubleshooting
Webhook returns 502 Bad Gateway
Webhook returns 502 Bad Gateway
The Rapida stack is not running. Verify:
Audio connects but there is no voice / silence
Audio connects but there is no voice / silence
PUBLIC_ASSISTANT_HOST is still set to the old ngrok URL or to localhost. Update it to the new ngrok hostname and run make rebuild-assistant.ngrok shows 'ERR_NGROK_3200: tunnel not found'
ngrok shows 'ERR_NGROK_3200: tunnel not found'
The tunnel is not running. Start it again:And update both
PUBLIC_ASSISTANT_HOST and connection.media with the new URL.Twilio error: 'Not a valid https URL'
Twilio error: 'Not a valid https URL'
Twilio requires HTTPS. ngrok provides HTTPS automatically. Do not use the
http:// version of the URL — always use the https://abc123.ngrok-free.app URL in Twilio’s console.