An AI-powered voice agent system for automated patient feedback collection via phone calls. Built with FastAPI, Pipecat, OpenAI Realtime API, Twilio, MongoDB, Redis, and Celery. Supports English, Spanish, French, Haitian Creole, and multi-geography deployment.
- Automated AI voice calls with Twilio and OpenAI Realtime
- Multilingual support: English, Spanish, French, Haitian Creole
- Flexible queue modes: Forever, Batch, Manual
- Nexus integration for subject synchronization
- Async-first: all DB, Redis, and HTTP operations are async
- State machine: FlowManager handles the 6-stage conversation flow
- Environment config:
ENVIRONMENTselectsconfig/.env.local,config/.env.uat, orconfig/.env.prod
- API:
backend/app/main.py(uvicorn backend.app.main:app) - Celery:
backend/app/celery_app.py - Voice pipeline:
backend/app/domains/patient_feedback/voice_pipeline.py
POST /api/v1/auth/login- JWT loginGET /api/v1/health/liveandGET /api/v1/health/ready- health probesGET /api/v1/geographiesandPOST /api/v1/geographies- geography managementGET /api/v1/queuesandPOST /api/v1/queues- call queue managementGET /api/v1/recipientsandPOST /api/v1/recipients- recipient management
queue_processor.py- periodic queue processingvoice_call.py- call initiation and Twilio webhook handlingrecording_download.py- Twilio recording download and S3 uploadsplit_recording.py- audio file processingtranscript_translation.py- transcript translationnexus_sync.py- Nexus subject and result synchronization
git clone https://github.com/shryesth/ai-voice-agent.git
cd ai-voice-agent
cp config/.env.local.example config/.env.local
# Edit config/.env.local with your credentials
docker compose -f docker-compose.dev.yml uppytest -m "not slow" # Exclude slow testsblack backend/ tests/ # Format
ruff check backend/ tests/ # Lint
mypy backend/ # Type checkcelery -A backend.app.celery_app worker --loglevel=info
celery -A backend.app.celery_app beat --loglevel=info
celery -A backend.app.celery_app flower --port=5555- Development:
docker-compose.dev.yml - UAT:
docker-compose.uat.yml - Production:
docker-compose.production.yml - CapRover:
git push caprover main
- JWT authentication with role-based access control
- Patient phone numbers are redacted for non-admin users
- Environment-based configuration; never commit credentials
- CORS is relaxed for dev and UAT, strict for production
- CLAUDE.md - architecture, commands, and patterns
- config/README.md - configuration details
- specs/001-patient-feedback-api/ - feature specs, data models, and contracts
For issues or questions:
- Check CLAUDE.md for architecture and commands
- Review config/README.md for configuration
- Check specs for feature details
- Review git history for recent changes
- Check Docker logs for runtime errors
ai-voice-agent/
|-- backend/
| `-- app/
| |-- api/v1/ # REST API endpoints
| |-- core/ # config, database, security
| |-- domains/ # feature-specific logic
| | |-- patient_feedback/ # patient feedback flows
| | `-- supervisor/ # supervisor features
| |-- models/ # MongoDB document models
| |-- schemas/ # Pydantic request/response schemas
| |-- services/ # business logic
| |-- tasks/ # Celery async tasks
| |-- infrastructure/ # S3 storage and integrations
| |-- main.py # FastAPI app entry point
| `-- celery_app.py # Celery configuration
|-- tests/ # test suite
|-- config/ # environment configuration
|-- docker/ # Docker build files
|-- docker-compose.*.yml # Docker Compose files
|-- CLAUDE.md # development guide
`-- README.md # this file
- Conversation stages
- Greeting
- Confirm Identity
- Collect Satisfaction Rating (1-10)
- Completion
- Voice components
- VAD: OpenAI server-side voice activity detection
- Speech-to-Text: OpenAI Realtime API
- LLM: OpenAI gpt-4o-realtime-preview
- Text-to-Speech: OpenAI Realtime API
- Transport: Twilio Media Streams over WebSocket
- Prometheus metrics are available at
/metrics - Alert groups are defined in
prometheus-alerts.yml- DLQ Count High/Critical
- Queue Depth High
- Queue Processor Stalled
- Main branch:
main(production-ready) - Development branch:
develop(active development) - Feature branches:
feature/<name> - Commit style: conventional commits such as
feat:,fix:, andrefactor:
- Create a feature branch:
git checkout -b feature/your-feature - Make changes and commit:
git commit -m "feat: description" - Push the branch:
git push origin feature/your-feature - Open a pull request to
develop - Ensure tests pass and coverage is maintained
- Pipecat Documentation - Voice pipeline framework
- OpenAI Realtime API - Real-time voice AI
- Twilio Media Streams - WebSocket audio streaming
- FastAPI Documentation - Web framework
- Celery Documentation - Task queue system
MIT License