Build a Twilio Voice + ElevenLabs Agents Integration
Time to read:
Build a Twilio Voice + ElevenLabs Agents Integration
If you’ve heard of ElevenLabs, you’re probably familiar with their Text-to-Speech (TTS) service. Not only do they provide high-quality voice synthesis, but they also offer AI agents that can engage in natural conversations. This tutorial shows you how to connect your Twilio phone number to an ElevenLabs AI agent for voice communication, using Twilio to handle phone calls.
By the end of this guide, you'll have a working integration that can receive inbound calls on a Twilio number and route them to your ElevenLabs agent.
Prerequisites
Before you begin, make sure you have the following:
- A Twilio account - Sign up with Twilio for free here
- A Twilio number - Read our docs here on how to obtain a Twilio number
- An ElevenLabs Account - Sign up here
What You'll Build
This voice application will route all inbound calls from your Twilio number to your ElevenLabs agent using ElevenLabs' native Twilio integration. You'll start by importing your Twilio account information into ElevenLabs, then import your Twilio number, then link it to an agent on your ElevenLabs account. If you don't have an agent available to use, we'll show you how to set up a demo one.
Let's get started!
Create an ElevenLabs Agent
Once you’re signed into ElevenLabs, head over to their Agents platform. If it’s your first time on the platform and you haven’t created an agent, the following pop-up will show up to guide you on creating an agent.
Follow the steps to create an agent.
In some cases the modal won’t pop-up, if this is the case for you, click on the Agents tab on the left side of your dashboard and you’ll see the following screen:
Select one of the provided agents (or you can start from blank) and click Create agent.
Add Twilio Number and Credentials to ElevenLabs
Now that you’ve created an agent for your voice application, the next step is to integrate it with your Twilio number.
First, you’ll need to fetch your Twilio credentials. Open a new tab, head over to your Twilio Console and scroll down to the Account Info section to locate your Account SID and your Twilio phone number:
Keep this tab up as you’ll need to add them to your ElevenLabs account.
Next, navigate back to your ElevenLabs tab and head over to the Telephony > Phone Numbers section on the left tab:
Click on + Import number button and then the From Twilio button from the dropdown and you’ll see a sidebar modal pop up to import your credentials from Twilio:
On the sidebar, enter your Twilio Phone number, Account SID, and Auth Token in its respective fields from your Twilio tab. Once imported, feel free to give it a Label and click Import.
Connect ElevenLabs Agent to your Twilio Number
Once your phone number has been added, you’ll see the following screen:
The next step is to link your newly added number with your ElevenLabs agent. Click on the No agent dropdown and select your agent from the list.
Your phone number should now be connected to your agent. Let’s test it out!
Test your Integration
You can test out your integrated agent either through an outbound call or inbound call. For an outbound call, click on the Outbound call button on the top right of the screen and you’ll see the following menu:
Select the agent, enter your phone number and click Send Test Call to receive a call from your agent.
You can also test through an inbound call by just calling your Twilio phone number and you’ll be connected to your agent.
What's Next?
You've successfully built a voice integration that connects your Twilio phone number to an ElevenLabs AI agent!
Now that you have a working agent linked to your Twilio phone number, you can enhance your agent's capabilities further:
- Add a knowledge base to your ElevenLabs agent to provide more specialized and accurate responses for your use case. You can upload documents, FAQs, or product information that your agent can reference during conversations.
- Personalize your agent's behavior by adding context variables or overrides.
- Customize your agents voice by controlling pronunciation, speed, and more to create a more natural and engaging voice experience
Dhruv Patel is a Developer on Twilio’s Developer Voices team. You can find Dhruv working in a coffee shop with a glass of cold brew or he can either be reached at dhrpatel [at] twilio.com .
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.