How shelunagori/ai-voice-calling-collections-agent works
This is a real-time voice collections proof of concept: an operator starts a browser or PSTN session; caller speech is interpreted as typed proposals, then deterministic phase and policy checks govern identity verification, disclosure, repayment, consent, transfer, and contact suppression. The voice runtime handles turn-taking and playback, while audit and persistence preserve outcomes for the operator. The map includes documented evaluation and NLU post-training capabilities. Some integrations are shown from README-level descriptions because their implementation files were not sampled.
Main entry points: session.py Voice session · understanding.py Utterance understanding · session_service.py Session service · controller.py Conversation controller
Components 27
Operator console
- Web console
frontend/app/telephony/page.tsx - Operator routes
frontend/app/api/operator/calls/route.ts - Session audit UI
frontend/components/audit/SessionDetailView.tsx
Conversation runtime
- REST routes
backend/app/api/routes.py - Telephony webhooks
backend/app/api/telephony.py - Browser voice socket
backend/app/api/ws_browser.py - Session service
backend/app/api/session_service.py - Runtime assembly
backend/app/runtime.py - Voice session
backend/app/voice/session.py - Audio and turns
backend/app/voice/audio.py
Collections domain
- Conversation controller
backend/app/domain/controller.py - Policy rules
backend/app/domain/policy.py - Phase action contract
backend/app/domain/turn_context.py - Utterance understanding
backend/app/domain/understanding.py - Rules parser
backend/app/domain/nlu_rules.py - Response realization
backend/app/domain/realizer.py
Providers and persistence
- Provider interfaces
backend/app/providers/base.py - Cartesia speech
backend/app/providers/cartesia.py - Cloudflare LLM
backend/app/providers/cloudflare_llm.py - Repository
backend/app/persistence/repository.py - PostgreSQL
backend/app/persistence/tables.py - Audit and metrics
backend/app/domain/audit.py
Evaluation and training
- Evaluation suite
backend/app/evaluation/runner.py - NLU training data
backend/app/training/build_dataset.py
Other components
- Operator
- Caller
- Twilio PSTN
backend/app/providers/twilio.py
Connections 29
- Operator → Web console: starts calls
- Web console → Operator routes: requests calls
- Web console → REST routes: uses backend
- REST routes → Session service: opens sessions
backend/app/api/routes.py - Telephony webhooks → Session service: opens calls
- Browser voice socket → Session service: opens sessions
- Session service → Repository: loads and records
backend/app/api/session_service.py - Session service → Runtime assembly: builds session
backend/app/api/session_service.py - Runtime assembly → Voice session: creates session
backend/app/runtime.py - Voice session → Audio and turns: processes turns
- Caller → Voice session: speaks
- Voice session → Utterance understanding: interprets text
backend/app/voice/session.py - Utterance understanding → Rules parser: parses utterance
backend/app/domain/understanding.py - Utterance understanding → Cloudflare LLM: requests interpretation
- Utterance understanding → Phase action contract: uses phase context
backend/app/domain/understanding.py - Voice session → Conversation controller: applies outcome
backend/app/voice/session.py - Conversation controller → Policy rules: checks proposals
backend/app/domain/controller.py - Conversation controller → Phase action contract: constrains actions
backend/app/domain/controller.py - Conversation controller → Response realization: plans replies
backend/app/voice/session.py - Voice session → Response realization: realizes response
backend/app/voice/session.py - Voice session → Cartesia speech: streams speech
- Voice session → Twilio PSTN: sends call audio
- Telephony webhooks → Twilio PSTN: controls calls
- Audit and metrics → Repository: records events
backend/app/api/session_service.py - Repository → PostgreSQL: reads and writes
backend/app/persistence/repository.py - REST routes → Repository: serves session data
backend/app/api/routes.py - Session audit UI → REST routes: views audit
- Evaluation suite → Utterance understanding: benchmarks NLU
- NLU training data → Cloudflare LLM: formats model data
backend/app/providers/cloudflare_llm.py