Project Overview: The Problem & The Solution
The Problem: Voice is an unforgiving interface. If an AI phone assistant pauses for more than a second or two while waiting on a calendar API or a chain of no-code webhooks, callers think the line dropped and hang up. And once a caller hangs up on a traditional voice bot, that missed connection is gone.
The Solution: I built Nova as a standalone asynchronous Python microservice with zero reliance on third-party automation glues like n8n or Make. To keep the conversation natural while never losing a caller, the service splits every call into two separate pipelines:
- Mid-Call Tools (< 500ms budget, 3.5s timeout fallback): While the caller is speaking with Nova, Retell AI calls HMAC-SHA256 verified endpoints (
/api/v1/retell/tools/check-availability,book-appointment, andurgent-escalation). If a calendar lookup ever takes longer than 3.5 seconds, the service returns a graceful spoken fallback instead of leaving the caller in dead air. - Post-Call Webhook & Missed-Call Recovery (< 50ms ACK): As soon as a call ends,
/api/v1/retell/webhookverifies the signature, returns an immediate200 OKin under 50ms, and hands the rest of the work to FastAPIBackgroundTasks. If the caller hung up without booking, the service automatically sends a follow-up text message with a direct calendar link and logs the call transcript and summary to the database.
System Specs
- Voice EngineRetell AI + ElevenLabs
- Telephony / SMSTelnyx SIP & Twilio
- Toll-Free Line+1 (888) 600-3783
- Voice Turnaround< 800ms
- Mid-Call Tools< 500ms (3.5s Guard)
- Webhook ACK< 50ms (Async Queue)
- RuntimeFastAPI • Python 3.12+
- DeploymentDocker + Nginx VPS
System Architecture Diagram
Carrier-Compliant Toll-Free SMS Opt-In Workflow
Sending automated follow-up texts from a phone number requires passing strict carrier verification. Using Telnyx SIP trunking and a dedicated toll-free number (+1 (888) 600-3783), the same number handles both inbound voice calls and outbound confirmation texts after obtaining verbal opt-in during the call.
Repository Structure
call-agent/
├── Dockerfile # Multi-target container (Hostinger VPS, Cloud Run, Azure)
├── docker-compose.yml # Compose stack with Nginx & Certbot profile
├── requirements.txt # Python 3.12+ dependencies
├── assets/
│ ├── architecture-diagram.png # System architecture & dual-pipeline diagram
│ └── toll-free-opt-in-workflow.jpg # Carrier SMS verbal opt-in workflow diagram
├── docs/
│ ├── architecture_overview.md # Architecture specs & integration guide
│ ├── TELNYX_SETUP_GUIDE.md # SIP trunking & toll-free SMS compliance guide
│ ├── RETELL_WORKSPACE_SETUP_GUIDE.md # Workspace & agent setup SOP
│ ├── NEW_CLIENT_ONBOARDING_GUIDE.md # End-to-end tenant onboarding SOP
│ └── CLIENT_KNOWLEDGE_UPDATE_GUIDE.md
├── nginx/conf.d/call-agent.conf # Nginx reverse proxy & TLS 1.2/1.3 config
├── scripts/
│ ├── init_nginx_ssl.sh # One-command SSL bootstrap script
│ └── provision_client.py # CLI for onboarding tenants & Retell agents
├── tests/test_webhooks.py # Pytest suite for webhooks, tools, and security
└── app/
├── main.py # FastAPI app, lifespan handler, and /health probe
├── config.py # pydantic-settings configuration
├── database.py # Async SQLAlchemy 2.0 (aiosqlite & asyncpg)
├── models.py # Tenant and CallLog database models
├── schemas.py # Pydantic v2 request/response schemas
├── core/security.py # Retell HMAC-SHA256 verification & tenant resolver
├── services/
│ ├── calendar.py # Async availability lookup & appointment booking
│ └── sms.py # Telnyx / Twilio confirmations, alerts & recovery
└── api/
├── tools.py # Mid-call tool endpoints (<500ms budget)
├── webhooks.py # Post-call webhook & BackgroundTasks recovery
└── admin.py # Multi-tenant onboarding endpoints
Try the AI Voice Assistant Live
Nova is connected to my live calendar. Call the toll-free number from your phone to try it out. If you hang up before booking a time, the post-call pipeline will text you a link to my calendar.