Configuration File
All settings are stored in.env at the project root:
Required Variables
These variables are essential for core functionality:Server Configuration
Port number for the uvicorn server.Referenced in:
.env
app/core/config.py:6Telnyx (Telephony Provider)
Telnyx REST API key for call control operations.Where to get it:
.env
- Log in to Telnyx Portal
- Navigate to API Keys under Settings
- Create a new API key with Call Control permissions
- Answering incoming calls (
app/main.py:184) - Starting audio streams (
app/main.py:202) - Text-to-speech greeting (
app/main.py:190)
app/main.py:27, app/core/config.py:4Webhook signature secret for verifying incoming Telnyx events.Referenced in:
.env
This is optional during development but required in production to prevent webhook spoofing.
.env.example:6Deepgram (Speech-to-Text)
Deepgram API key for real-time transcription and batch audio processing.Where to get it:
.env
- Sign up at Deepgram Console
- Create a new API key with Nova-2 model access
- Ensure sufficient credits for live streaming
- Live transcription via WebSocket (
app/agents/stt_client.py) - Batch transcription of recorded calls (
app/main.py:324-347) - Emotion sentiment analysis (
app/agents/emotion.py:119-251)
app/main.py:29, app/agents/emotion.py:11ngrok (Development Tunnels)
ngrok authentication token for creating persistent public tunnels.Where to get it:
.env
- Sign up at ngrok Dashboard
- Copy your authtoken from the Getting Started page
app/core/config.py:5, scripts/dev_start.sh:23-44Override for the public HTTP URL (auto-detected from ngrok if not set).Use this in production when deploying to a fixed domain.Referenced in:
.env
.env.example:10Public WebSocket URL for Telnyx audio streaming.Auto-configured in dev mode:
The
.env
dev_start.sh script automatically generates this from ngrok.Production setup:
Point this to your WebSocket endpoint behind a reverse proxy (nginx, Caddy, etc.)Referenced in: app/main.py:28, app/main.py:206Optional Variables
These enhance functionality but aren’t required:OpenAI (LLM Services)
OpenAI API key for advanced emotion classification and call summarization.Where to get it:
OpenAI API KeysFallback behavior:
If not set, DispatchAI uses heuristic-based emotion detection and simple transcript summaries.
.env
- Emotion:
app/agents/emotion.py:254-331(falls back to_analyze_emotion_heuristic) - Summary:
app/agents/summary.py:14-38(falls back to first-sentence extraction)
app/agents/emotion.py:9, app/agents/summary.py:6OpenAI model for emotion classification.Referenced in:
.env
app/agents/emotion.py:10Provider Selection
Choose the emotion detection provider.Options:Provider comparison:
Implementation:
heuristic- Rule-based keyword matching (no API key required)deepgram- Deepgram sentiment analysisopenai- OpenAI LLM classification
.env
| Provider | Speed | Accuracy | Cost | API Key Required |
|---|---|---|---|---|
| heuristic | ⚡️ Instant | Medium | Free | No |
| deepgram | Fast | High | Low | DEEPGRAM_API_KEY |
| openai | Slower | Highest | Medium | OPENAI_API_KEY |
app/agents/emotion.py:334-351Referenced in: app/agents/emotion.py:8Environment Settings
Application environment mode.Options:Referenced in:
dev- Development mode with debug logging and in-memory storageprod- Production mode (future: enables database persistence)
.env
app/main.py:82PostgreSQL connection string (future use).Referenced in:
.env
Currently unused. DispatchAI uses in-memory storage (
InMemoryCallStore).app/main.py:83S3 bucket name for storing call recordings (future use).Referenced in:
.env
app/main.py:84Configuration Loading
DispatchAI loads configuration using pydantic Settings:app/core/config.py
- Case-insensitive:
PORT,port, andPortall work - Type validation: Invalid types raise errors at startup
- Automatic loading: Reads from
.envviapython-dotenv
ngrok Configuration
Theops/ngrok.yml file defines tunnel configuration:
ops/ngrok.yml
- api tunnel - For HTTP webhook endpoints
- ws tunnel - For WebSocket audio streaming
Example Configurations
Minimal Development Setup
.env
Full Production Setup
.env
Testing Without API Keys
.env
Validation
To verify your configuration:Security Best Practices
Use secrets management in production
Use secrets management in production
Don’t commit
.env files. Use platform secrets:- AWS: AWS Secrets Manager or Parameter Store
- GCP: Secret Manager
- Kubernetes: Sealed Secrets or External Secrets Operator
- Docker: Docker secrets
Rotate API keys regularly
Rotate API keys regularly
Set up a rotation schedule:
- Telnyx: Every 90 days
- OpenAI: Every 180 days
- Deepgram: Every 180 days
Verify webhook signatures
Verify webhook signatures
Always set
TELNYX_WEBHOOK_SECRET in production to prevent spoofed events.Restrict API key permissions
Restrict API key permissions
Use minimum required scopes:
- Telnyx: Call Control only (no billing access)
- OpenAI: Project-scoped keys
- Deepgram: Read-only for on-premise deployments
Next Steps
Telephony Setup
Configure Telnyx webhooks and test your first call
Agent Configuration
Customize NLP agents and classification rules