Prerequisites
- A Twilio account
- Access to purchase a phone number
- A publicly accessible domain for webhooks
Creating a Twilio Account
Sign up for Twilio
Go to twilio.com and create a new account. You’ll need to verify your email and phone number.
Getting Your Credentials
Navigate to Account Dashboard
Once logged in, go to your Twilio Console.
Store your Auth Token securely. Never commit it to version control or share it publicly.
Purchasing a Phone Number
Go to Phone Numbers section
In the Twilio Console, navigate to Phone Numbers > Manage > Buy a number.
Select capabilities
Choose a number with the following capabilities:
- Voice: Required for making and receiving calls
- SMS: Optional, but useful for notifications
Choose your number
Search for numbers by country, area code, or specific digits. Once you find a suitable number, click Buy.
Configuring Environment Variables
Add the following to your.env file:
TwiML Configuration for WebSocket Streaming
Highway uses TwiML (Twilio Markup Language) to connect calls to a WebSocket stream. The configuration is handled programmatically in your backend:routes.js
Key TwiML Elements
<Connect>: Establishes the WebSocket connection<Stream>: Specifies the WebSocket URL for bi-directional audio streaming<Record>: Enables call recording with transcription<Hangup>: Ends the call when the stream closes
The WebSocket URL must be accessible over HTTPS/WSS in production. Use a service like ngrok for local development.
Testing the Integration
Webhook Setup
Transcription Callback
The transcription callback receives the transcribed text after the call ends:Call Recording and Transcription
Highway automatically enables recording and transcription:Recording Features
- Automatic transcription: Twilio converts speech to text
- Callback URL: Receives transcription results when ready
- Recording access: View and download recordings from the Twilio console
Accessing Recordings
Troubleshooting
Common Issues
Call not connecting- Verify your Twilio credentials are correct
- Check that your phone number has voice capabilities
- Ensure the WebSocket URL is accessible
- Confirm the WebSocket connection is established
- Check that the audio format is set to
g711_ulaw - Verify firewall settings allow WebSocket connections
- Ensure the callback URL is publicly accessible
- Check webhook logs in the Twilio console
- Verify the endpoint returns a 200 status code
Next Steps
- Configure OpenAI for real-time voice processing
- Set up Supabase for data storage
- Review Architecture to understand the complete process