Overview
The platform uses ElevenLabs’ hosted outbound-call endpoint:Phone calls are made through ElevenLabs’ Twilio integration. You need both an ElevenLabs account and a Twilio-connected phone number.
Prerequisites
Before starting this setup, ensure you have:- An active ElevenLabs account
- A Twilio account with a phone number
- Your
ELEVENLABS_API_KEYalready configured (see Environment Variables)
Step-by-Step Setup
Create or Select a Conversational AI Agent
Log into your ElevenLabs dashboard and navigate to the Conversational AI section.Option A: Create a New Agent
- Click Create New Agent
- Give your agent a name (e.g., “Voice Testing Caller”)
- Configure basic settings (voice selection, language, etc.)
- Select an agent from your list
- Note that the application will override the agent’s prompt at call time
The agent’s default prompt will be replaced by the application, so you can use any existing agent without worrying about its base configuration.
Enable Prompt Overrides
This is a critical step that allows the application to inject custom business descriptions and scenarios at call time.The application sends this override data with every outbound call to ensure the AI stays in character.
- Open your agent’s settings
- Navigate to the Advanced or Developer settings section
- Enable Allow Prompt Overrides (or similar option)
- Save your changes
app.py:73-83
Copy the Agent ID
After creating or configuring your agent:
- Navigate to the agent’s settings or details page
- Find the Agent ID (usually displayed near the top)
- Copy this ID to your clipboard
- Add it to your
.envfile:
Connect a Twilio Phone Number
ElevenLabs needs a Twilio-backed phone number to make outbound calls.In ElevenLabs Dashboard:
- Navigate to Phone Numbers section
- Click Add Phone Number or Import from Twilio
- Follow the prompts to connect your Twilio account
- Select a phone number from your Twilio account
- Complete the import/connection process
Don't have a Twilio phone number yet?
Don't have a Twilio phone number yet?
- Sign up at twilio.com
- Navigate to Phone Numbers → Manage → Buy a number
- Purchase a phone number (costs vary by region)
- Return to ElevenLabs and connect this number
Most Twilio accounts start in trial mode, which allows calls but with some limitations. Upgrade to a paid account for full functionality.
Copy the Phone Number ID
After connecting your Twilio phone number in ElevenLabs:
- Navigate to the Phone Numbers section
- Click on your connected phone number
- Find the Phone Number ID in the settings
- Copy this ID to your clipboard
- Add it to your
.envfile:
Verify Your Configuration
Ensure all three ElevenLabs variables are set in your
.env file:The application validates all three variables before allowing outbound calls:
app.py:239-245
Test Your Setup
Now test the outbound calling functionality:
- Start your Flask application:
- Open http://localhost:5000
-
Fill in:
- Business description (e.g., “Bob’s Pizza - We deliver pizzas in under 30 minutes”)
- Scenario (e.g., “check availability and order a large pepperoni pizza”)
- Phone number in E.164 format (e.g.,
+15551234567)
- Click Start Call
How Outbound Calls Work
When you initiate a call through the platform, here’s what happens:1. Application Builds the Request
app.py:247-255
2. Caller Prompt is Generated
The application creates a dynamic prompt that makes the AI behave like a customer:app.py:57-66
3. First Message is Crafted
app.py:69-70
4. ElevenLabs Makes the Call
The application posts to ElevenLabs:app.py:258
- Uses your configured Twilio number as the caller ID
- Calls the target phone number
- Applies the custom prompt and first message
- Handles the conversation using Conversational AI
Troubleshooting
Error: Missing required environment variables
Error: Missing required environment variables
Problem: You see this error when trying to make a call:Solution:
- Verify your
.envfile contains all three variables - Restart your Flask application after updating
.env - Check for typos in variable names
Error: Phone number must be in E.164 format
Error: Phone number must be in E.164 format
Problem: Your phone number is rejected:Solution:
Phone numbers must:
- Start with
+ - Include country code
- Contain only digits (no spaces, dashes, or parentheses)
- Be 8-15 digits long after the
+
+15551234567✓+442071234567✓
5551234567✗ (missing + and country code)+1 555 123 4567✗ (contains spaces)
Error: ElevenLabs API error (401)
Error: ElevenLabs API error (401)
Problem: Authentication failedSolution:
- Verify your
ELEVENLABS_API_KEYis correct - Check that the key hasn’t expired
- Ensure you copied the entire key without trailing/leading spaces
Error: ElevenLabs API error (403/404) - Agent not found
Error: ElevenLabs API error (403/404) - Agent not found
Problem: The agent ID or phone number ID is invalidSolution:
- Double-check your
ELEVENLABS_AGENT_IDin the ElevenLabs dashboard - Verify your
ELEVENLABS_AGENT_PHONE_NUMBER_IDis correct - Ensure the agent and phone number belong to the same ElevenLabs account as your API key
Call initiated but AI doesn't follow the business scenario
Call initiated but AI doesn't follow the business scenario
Problem: The AI uses its default prompt instead of your business descriptionSolution:
- Ensure prompt overrides are enabled on your ElevenLabs agent
- Check the agent settings in the ElevenLabs dashboard
- If recently enabled, try creating a test call again
Could not reach ElevenLabs error
Could not reach ElevenLabs error
Problem: Network or connectivity issueSolution:
- Check your internet connection
- Verify
ELEVENLABS_API_BASEif you set a custom value - Check if ElevenLabs API is experiencing downtime (status.elevenlabs.io)
Advanced Configuration
Custom API Base URL
If you need to use a custom ElevenLabs endpoint (for proxies, testing, etc.):app.py:20
API Request Details
The application makes requests with these headers:app.py:101-108
app.py:112
Call Response Data
When a call is successfully initiated, the application returns:call_sid: Twilio’s unique identifier for the call (can be used to track call status in Twilio)conversation_id: ElevenLabs conversation ID (can be used to retrieve call transcripts)raw: Complete response from ElevenLabs API for debugging
app.py:269-270
Next Steps
Environment Variables
Complete reference for all configuration options
API Reference
Explore the API endpoints for making calls