Overview
The outbound phone call feature lets you test business phone systems with real voice calls. The same AI agent that powers the web chat can place actual phone calls to any number, behaving as a customer trying to complete a specific task. This mode enables:- End-to-end testing of live phone systems
- IVR flow validation with real voice input
- Load testing customer service lines
- Quality assurance before launching new phone flows
- Realistic testing of voice recognition and call routing
How It Works
The phone call system uses a four-part integration:- Flask backend coordinates the call request with business context
- ElevenLabs Conversational AI provides the voice agent with dynamic prompts
- Twilio handles the actual phone call infrastructure
- OpenAI (via ElevenLabs) powers the conversational intelligence
Architecture
ElevenLabs + Twilio Integration
This platform uses ElevenLabs’ hosted Conversational AI service with Twilio backend for outbound calling.Required Configuration
Three environment variables control phone call functionality:ElevenLabs Setup
Create or Select a Conversational AI Agent
In the ElevenLabs dashboard:
- Navigate to Conversational AI
- Create a new agent or select an existing one
- Copy the Agent ID
- Set
ELEVENLABS_AGENT_IDin your.envfile
The agent’s base configuration is overridden at call time by the platform, so you can use a generic agent for all tests.
Enable Prompt Overrides
For the platform to inject business descriptions and scenarios dynamically:
- Open your agent settings
- Enable “Allow prompt overrides”
- Save the configuration
conversation_config_override.Connect a Twilio Phone Number
In ElevenLabs:
- Go to Phone Numbers
- Import or connect a Twilio-backed phone number
- Copy the Phone Number ID (not the actual phone number)
- Set
ELEVENLABS_AGENT_PHONE_NUMBER_IDin your.env
API Endpoint
The platform uses ElevenLabs’ outbound call endpoint:The function includes comprehensive error handling, capturing both HTTP errors and network failures with detailed messages.
Placing Calls
To place an outbound phone call, you need a business description, optional scenario, and a valid phone number.Phone Number Format
Phone numbers must be in E.164 format:- Starts with
+ - Followed by country code
- Then the subscriber number
- No spaces, dashes, or parentheses
+15551234567(US)+442071234567(UK)+61212345678(Australia)
5551234567(missing +)+1 555 123 4567(contains spaces)(555) 123-4567(wrong format)
Using the Web Interface
Enter Business Context
On the home page, fill in the business description and optional scenario fields (same as for web chat).Example:
- Business description: “A dental clinic with online booking, insurance verification, and reminder calls”
- Scenario: “check appointment availability for next Tuesday”
Enter Phone Number
In the “Phone test” section, enter the destination number in E.164 format:The UI shows a hint about the required format:
Start the Call
Click Start call. The button disables and changes to “Calling…” while the request is processed:
Call Scenarios
Scenarios define what the AI agent is trying to accomplish during the call. They shape the agent’s behavior and goals.Default Scenario
If no scenario is provided, the system uses:Custom Scenarios
Scenarios should be written from the caller’s perspective:| Industry | Scenario Example |
|---|---|
| Healthcare | ”schedule a cleaning appointment for next week” |
| E-commerce | ”track my order and get an estimated delivery date” |
| Banking | ”check my account balance and recent transactions” |
| Restaurant | ”make a reservation for 4 people on Saturday at 7pm” |
| Technical Support | ”reset my password and verify my account is working” |
Building the Caller Prompt
The backend constructs a detailed prompt that instructs the agent on how to behave:First Message
The agent always starts the conversation with a natural greeting based on the scenario:- Scenario: “check appointment availability”
- First message: “Hi, I’m calling because I’d like to check appointment availability.”
API Call Flow
When you trigger a phone call, the backend orchestrates the request to ElevenLabs.Request Handler
The/api/call endpoint processes the call request:
Building the Payload
The backend constructs the ElevenLabs API payload:conversation_initiation_client_data contains the prompt override:
The
conversation_config_override structure tells ElevenLabs to use your custom prompt and first message instead of the agent’s default configuration.Sending the Request
The platform sends the payload to ElevenLabs:Response Format
The backend returns a normalized response:The
call_sid is Twilio’s unique identifier for the call, while conversation_id is ElevenLabs’ internal ID for tracking the AI conversation.Error Handling
The platform includes comprehensive error handling for common failure scenarios.Validation Errors
API Errors
ElevenLabs API errors are caught and forwarded with details:| HTTP Code | Error | Solution |
|---|---|---|
| 401 | Invalid API key | Check ELEVENLABS_API_KEY in .env |
| 404 | Agent not found | Verify ELEVENLABS_AGENT_ID is correct |
| 404 | Phone number not found | Verify ELEVENLABS_AGENT_PHONE_NUMBER_ID is correct |
| 429 | Rate limit exceeded | Wait and retry, or upgrade your ElevenLabs plan |
| 500 | ElevenLabs server error | Check ElevenLabs status page |
Network Errors
Testing Phone Flows
Use these strategies to effectively test your phone systems:Happy Path Testing
Define Success Criteria
Before placing calls, document what a successful interaction looks like:
- Does the agent reach the correct department?
- Can it complete the task without human intervention?
- Does the IVR respond correctly to voice input?
IVR Flow Validation
Test automated phone systems systematically:- Menu Navigation: Can the agent navigate multi-level IVR menus?
- Voice Recognition: Does the IVR correctly interpret the agent’s speech?
- Fallback Handling: What happens when the agent says unexpected things?
- Hold and Transfer: Does the system handle transfers gracefully?
Load Testing
To test call volume capacity:Monitoring and Analytics
After placing calls, use the returned IDs to track results.Call Tracking
The response includes two tracking identifiers:- call_sid: Use in Twilio’s dashboard to view call logs, duration, cost, and recordings
- conversation_id: Use in ElevenLabs’ dashboard to view conversation transcripts and agent behavior
Twilio Dashboard
Access call details at:- Call duration
- Cost
- Status (completed, busy, no-answer, failed)
- Recordings (if enabled)
ElevenLabs Dashboard
Access conversation details in the ElevenLabs Conversational AI section using theconversation_id to view:
- Full conversation transcript
- Agent responses and timing
- Any errors or fallbacks
- Audio recordings
Best Practices
Test in Web Chat First
Before placing phone calls, validate your business description and scenarios in the web chat interface. This helps refine prompts without incurring call costs.
Use Test Numbers
Start with test phone numbers you control to verify the agent’s behavior before testing production systems.
Monitor Costs
Each call incurs costs from:
- ElevenLabs (per minute of AI conversation)
- Twilio (per minute of phone call)
API Reference
POST /api/call
Initiates an outbound phone call with AI agent.
Request body:
Comparing Chat vs Phone
| Feature | Web Chat | Phone Calls |
|---|---|---|
| Speed | Instant responses | Real-time with latency |
| Cost | OpenAI + ElevenLabs TTS | OpenAI + ElevenLabs + Twilio |
| Testing | Interactive, immediate feedback | Async, requires monitoring |
| Realism | Text-based simulation | Actual voice interaction |
| IVR Testing | Cannot test | Full IVR validation |
| Voice Quality | Playback only | Live voice recognition |
| Best For | Rapid prototyping, conversation flow | End-to-end validation, production testing |
Next Steps
- Review web chat testing for pre-call scenario validation
- Set up monitoring dashboards in Twilio and ElevenLabs
- Build automated test suites for regression testing
- Document conversation flows and success criteria
- Integrate call testing into your CI/CD pipeline