Prerequisites
Before you begin, ensure you have:- Python 3.10 or higher installed
- A Telnyx account with:
- API key
- A phone number configured for Call Control
- ngrok account (free tier works) for public webhook URLs
- Optional: Deepgram API key for speech-to-text
- Optional: OpenAI API key for emotion classification
Installation
Install dependencies
requirements.txt:Configure environment variables
Copy the example environment file and edit it with your credentials:Edit
.env and add your API keys:Start the development server
DispatchAI includes a startup script that launches both the FastAPI server and ngrok tunnels:This script:
- Starts uvicorn on the port specified in your
.envfile (default: 8000) - Launches ngrok with two tunnels (HTTP for
/apiand WebSocket for/ws) - Writes the public URLs to
ops/urls.txt
Note your ngrok URLs
After startup, check You’ll see something like:
ops/urls.txt for your public URLs:These URLs change every time you restart ngrok (unless you have a paid account with reserved domains).
Configure Telnyx webhook
In your Telnyx portal:
- Go to Call Control Applications
- Select your application (or create one)
- Set the Webhook URL to:
https://YOUR_HTTP_URL/api/v1/call/incoming - Save the configuration
Make Your First Call
Now you’re ready to test the system:Listen to the greeting
You’ll hear: “This is Dispatch AI. I’m listening. Please describe your emergency.”
Describe an emergency
Speak a sample emergency scenario, for example:
- “Someone’s having a heart attack!”
- “There’s a fire in the building!”
- “I need help, someone broke into my house!”
View the Results
DispatchAI includes debug dashboards for development:Live Calls Dashboard
Monitor active calls in real-time as they stream
Queue Dashboard
View the prioritized dispatch queue
Using the API
You can also query the API directly:Understanding the Results
Each processed call includes:- Risk Level: CRITICAL, ELEVATED, NORMAL, or LOW
- Risk Score: Continuous 0-1 score based on distress + emotion
- Category: EMS, FIRE, POLICE, or OTHER
- Semantic Tags: Life-threatening indicators (CARDIAC_ARREST, ACTIVE_SHOOTER, etc.)
- Emotion: CALM, TENSE, DISTRESSED, or HIGHLY_DISTRESSED
- Summary: AI-generated description of the emergency
Troubleshooting
Webhook not receiving calls
Webhook not receiving calls
Problem: Telnyx isn’t triggering the webhook when you call.Solutions:
- Verify ngrok is running:
curl https://YOUR_HTTP_URL/health - Check the webhook URL in Telnyx exactly matches:
https://YOUR_HTTP_URL/api/v1/call/incoming - Look for errors in the uvicorn terminal output
- Check Telnyx portal logs for webhook delivery failures
Audio not streaming
Audio not streaming
Problem: Call connects but no audio analysis happens.Solutions:
- Verify
WS_PUBLIC_URLin.envmatches your ngrok WebSocket URL (starts withwss://) - Check that your Telnyx Call Control app is configured for audio streaming
- Look for WebSocket errors in the uvicorn logs
No transcription
No transcription
Problem: Audio processes but transcript is empty.Solutions:
- Check that
DEEPGRAM_API_KEYis set in.env - Verify your Deepgram account has credits
- Ensure you spoke during the call (VAD requires voiced audio)
- Check uvicorn logs for Deepgram API errors
Permission denied on dev_start.sh
Permission denied on dev_start.sh
Problem: Can’t execute the startup script.Solution:
Next Steps
Now that you have DispatchAI running, explore these topics:Architecture
Understand how the system works
Configuration
Customize environment variables
Agent System
Learn about the AI agents
API Reference
Explore the REST API