Twilio outbound calls
Build an outbound calling AI agent with Twilio and ElevenLabs.
In this guide you will learn how to build an integration with Twilio to initialise outbound calls to your prospects and customers.
What You’ll Need
- An ElevenLabs account.
- A configured ElevenLabs Conversational Agent (create one here).
- A Twilio account with an active phone number.
- Node.js 16+
- ngrok for local development.
Agent Configuration
Before integrating with Twilio, you’ll need to configure your agent to use the correct audio format supported by Twilio.
Configure TTS Output
- Navigate to your agent settings.
- Go to the Voice section.
- Select “μ-law 8000 Hz” from the dropdown.

Implementation
Javascript
Looking for a complete example? Check out this Javascript implementation on GitHub.
Testing
- In another terminal, run
ngrok http --url=<your-url-here> 8000
. - Make a request to the
/outbound-call
endpoint with the customer’s phone number, the first message you want to use and the custom prompt:
- You will see the call get initiated in your server terminal window and your phone will ring, starting the conversation once you answer.
Troubleshooting
Connection Issues
If the WebSocket connection fails:
- Verify your ngrok URL is correct in Twilio settings
- Check that your server is running and accessible
- Ensure your firewall isn’t blocking WebSocket connections
Audio Problems
If there’s no audio output:
- Confirm your ElevenLabs API key is valid
- Verify the AGENT_ID is correct
- Check audio format settings match Twilio’s requirements (μ-law 8kHz)
Security Best Practices
Follow these security guidelines for production deployments:
- Use environment variables for sensitive information - Implement proper authentication for your endpoints - Use HTTPS for all communications - Regularly rotate API keys - Monitor usage to prevent abuse