Overview
This quickstart guide will walk you through setting up the AI Voice Testing Platform and running your first test conversation. You’ll be up and running in just a few minutes.For web chat testing, you only need OpenAI and ElevenLabs API keys. Phone calling requires additional ElevenLabs Conversational AI setup.
Prerequisites
Before you begin, ensure you have:- Python 3.8 or higher installed
- An OpenAI API key (get one here)
- An ElevenLabs API key (sign up here)
Step 1: Install Dependencies
Create a virtual environment
Navigate to your project directory and create a Python virtual environment:This isolates your project dependencies from your system Python installation.
Step 2: Configure Environment Variables
Step 3: Run the Application
Start the Flask development server:The app runs on port 5000 by default. If this port is in use, you can change it in
app.py:277.Step 4: Start Your First Conversation
Open the web interface
Navigate to http://localhost:5000 in your browser.
Define a caller scenario
Specify what the AI caller should try to accomplish:Example:If you leave this blank, the default scenario is: “check availability, complete a typical customer task, and avoid speaking to a human if possible”
Start the conversation
Click Start conversation. The AI will initiate the chat with a greeting based on your scenario.The AI caller will say something like:
Respond as your business
Type your response as if you’re the business’s phone system or operator:Example:The AI will:
- Generate a conversational response using OpenAI GPT-4o-mini
- Synthesize speech using ElevenLabs TTS
- Return both text and audio to your browser
Understanding the Chat Flow
Here’s what happens behind the scenes when you send a message:- Context Building - Your message is added to the conversation history maintained in Flask session (
app.py:191-195) - Prompt Construction - The system builds a caller prompt using
build_caller_prompt()that includes your business description and scenario (app.py:57-66) - AI Response - OpenAI’s
gpt-4o-minimodel generates a response (app.py:204-208) - Voice Synthesis - ElevenLabs converts the text to speech using the
eleven_turbo_v2_5model with voice IDJBFqnCBsd6RMkjVDRZzb(app.py:132-136) - Response Delivery - Both text and base64-encoded audio are returned to the browser (
app.py:223)
Testing Outbound Phone Calls (Optional)
To test real phone calls, you need to configure ElevenLabs Conversational AI:Create an ElevenLabs Conversational AI agent
- Log into your ElevenLabs dashboard
- Navigate to Conversational AI
- Create a new agent or select an existing one
- Enable prompt overrides - This allows the app to inject your business description at call time
- Copy the Agent ID
Connect a Twilio phone number
- In ElevenLabs, import or connect a Twilio-backed phone number
- Copy the Phone Number ID
- This number will be used as the caller ID for outbound calls
Make a test call
Back in the web interface:
- Enter your business description and scenario
- Enter a destination phone number in E.164 format (e.g.,
+15551234567) - Click Start call
/v1/convai/twilio/outbound-call endpoint (app.py:258), which initiates a real phone call using the same caller context as web chat.API Endpoints Reference
The platform exposes these endpoints:| Endpoint | Method | Purpose |
|---|---|---|
/ | GET | Serves the main web interface (app.py:141) |
/api/context | POST | Sets business description and initializes session (app.py:164) |
/api/chat | POST | Sends a message and receives AI response with audio (app.py:178) |
/api/call | POST | Initiates an outbound phone call (app.py:226) |
/tts | POST | Standalone text-to-speech conversion (app.py:145) |
Next Steps
Installation Guide
Learn about production deployment and advanced configuration
API Reference
Explore detailed API documentation and integration options
Troubleshooting
”ELEVENLABS_API_KEY not set in .env”
Make sure your.env file is in the same directory as app.py and contains valid API keys.
”Missing required environment variables”
For phone calls, you must setELEVENLABS_AGENT_ID and ELEVENLABS_AGENT_PHONE_NUMBER_ID in addition to the API keys.
”Phone number must be in E.164 format”
Phone numbers must start with+ followed by country code and number. For example:
- US:
+15551234567 - UK:
+447911123456
app.py:24.
No audio in web chat
If you receive text responses but no audio, check:- Your
ELEVENLABS_API_KEYis valid - Your ElevenLabs account has sufficient credits
- Browser console for any audio playback errors