Multi-tenant AI voice agent platform
A multi-tenant AI voice agent platform where inbound phone calls are handled by an AI agent that can check availability, create bookings, process orders, and escalate to humans. Built as a full-stack product: Python voice agent, TypeScript API with 22 route modules, Next.js dashboard, and 19 database migrations.
Inbound SIP calls from SignalWire hit a LiveKit room. The Python agent connects, extracts sip.trunkPhoneNumber to identify the tenant, fetches per-tenant config (system prompt, voice settings, operating hours, escalation rules) from the API, then starts an AgentSession.
The voice pipeline uses Deepgram Nova-3 for STT (multilingual), OpenAI gpt-4.1-mini as the reasoning LLM, and Cartesia Sonic-3 for TTS. Silero VAD is prewarmed at process startup for fast voice activity detection.
Six function tools (check_availability, create_booking, create_order, transfer_to_human, end_call, log_note) all route through a single _call_tool() helper that POSTs to /internal/voice-tools/:action on the API. Business logic lives centrally in the API, not in the agent.
Multi-tenant isolation: tenant lookup by phone_number (unique, indexed). All tables (calls, bookings, callback_queue, sms_messages) have tenant_id FK with CASCADE delete. Per-tenant system prompts, voice config (Cartesia voice_id), greetings, and escalation settings.
Duration watchdog enforces max call length: warns at T-2min, final warning at T-30s, force SIP REFER transfer at T-0. Call logging is fire-and-forget with 5s timeout to avoid blocking session teardown.