How lokeyadav/maya---collections-ai-voice-agent works
Purpose and Entry Points
This repository defines “Maya,” an outbound collections voice agent for Kapture Finance. The runtime starts in Vapi.ai: configure the assistant with vapi/system_prompt.txt, register tools from vapi/tool_definitions.json, and direct tool webhooks to the Express service in mock-server/server.js (/webhook, port 3000).
Voice-Orchestration Layer
Vapi coordinates telephony/WebRTC, turn-taking, tool calls, and audio delivery. Its provider pipeline is Deepgram Nova-2 for multilingual STT, OpenAI GPT-4o for dialogue reasoning, and ElevenLabs or Cartesia for TTS. This layer is externally configured rather than implemented in code; repository artifacts define its behavior:
• vapi/system_prompt.txt
• vapi/tool_definitions.json
Compliance-Governed Conversation State
The system prompt is the primary control plane. It requires identity authentication before disclosure of debt details, supports English by default with conditional Hindi/Hinglish responses, and governs disposition, payment, dispute, hardship, and opt-out behavior. The critical boundary is pre-verification: no loan/EMI/overdue information may be spoken until verify_customer succeeds.
• vapi/system_prompt.txt
• vapi/tool_definitions.json
Tool Contract and Backend Boundary
Five Vapi function schemas form the contract between LLM orchestration and backend actions: verification, promise-to-pay logging, payment-link sending, human escalation, and call disposition. Vapi invokes the public webhook; the backend must tolerate Vapi’s request envelope and return tool results.
• vapi/tool_definitions.json
• mock-server/server.js
Webhook Execution and Messaging Simulation
The Node.js/Express server is the only application runtime in the repo. It exposes both /webhook and /, applies an ngrok warning-bypass header, routes tool calls, and simulates CRM/workflow outcomes through logging. send_payment_link additionally calls a mock SMS/WhatsApp gateway with a fixed recipient and payment deep link, returning a delivery-style success response.
• mock-server/server.js
• mock-server/package.json
• mock-server/.env.example
Deployment and External Infrastructure
Local deployment runs Express on port 3000; ngrok, Render, or LocalTunnel exposes it to Vapi over HTTPS. Required external services are Vapi.ai, Deepgram, OpenAI, ElevenLabs/Cartesia, and a production replacement for the mock messaging/CRM integrations. Environment variables are intended to be supplied outside source control.
• mock-server/server.js
• mock-server/.env.example
Validation and Design Reference
The acceptance model centers on identity gating, compliant dispositions, PTP extraction, escalation, DNC behavior, and bilingual parsing. The test matrix encodes representative end-to-end paths, while the high-level design documents production expectations such as transcript compliance checks, LLM-based evaluation, and latency monitoring.
• tests/test_cases.json
• docs/HLD_Document.md
Main entry points: server.js Vapi Webhook Adapter · system_prompt.txt Maya System Prompt · tool_definitions.json Tool Definitions · .env.example Environment Variables
Components 16
Vapi Voice Orchestration
- Vapi.ai · Coordinates calls, turns, tools, and audio.
- Maya System Prompt · Enforces verification before debt disclosure and compliant call handling.
vapi/system_prompt.txt - Tool Definitions · Defines verification, PTP, payment, escalation, and disposition tools.
vapi/tool_definitions.json - STT / LLM / TTS · Deepgram, GPT-4o, and ElevenLabs or Cartesia provide the voice pipeline.
Webhook Runtime
- Express Server · Runs on port 3000 and exposes root plus webhook endpoints.
mock-server/server.js - Vapi Webhook Adapter · Accepts Vapi envelopes and returns tool results.
mock-server/server.js - Tool Call Router · Routes the five function calls to simulated backend actions.
mock-server/server.js - CRM / Workflow Simulation · Logs verification, PTP, escalation, and disposition outcomes.
mock-server/server.js - Mock SMS / WhatsApp Gateway · Sends the fixed-recipient payment deep link simulation.
mock-server/server.js - Environment Variables · Externalizes runtime and integration settings.
mock-server/.env.example - Server Dependencies
mock-server/package.json
Validation & Design
- Acceptance Test Matrix · Covers identity gating, PTP, escalation, DNC, and bilingual paths.
tests/test_cases.json - High-Level Design · Defines compliance evaluation and latency-monitoring expectations.
docs/HLD_Document.md
Other components
- Borrower
- HTTPS Tunnel or Hosting · ngrok, Render, or LocalTunnel exposes the local webhook.
- Production CRM & Messaging · Replaces simulated CRM and messaging behavior in production.
Connections 19
- Borrower → Vapi.ai: voice call
- Maya System Prompt → Vapi.ai: controls dialogue
- Tool Definitions → Vapi.ai: registers tools
- STT / LLM / TTS → Vapi.ai: speech and reasoning
- Vapi.ai → HTTPS Tunnel or Hosting: tool webhook
- HTTPS Tunnel or Hosting → Express Server: HTTPS to port 3000
- Express Server → Vapi Webhook Adapter: /webhook
- Vapi Webhook Adapter → Tool Call Router: parsed tool call
- Tool Call Router → CRM / Workflow Simulation: verify, PTP, escalate, dispose
- Tool Call Router → Mock SMS / WhatsApp Gateway: send_payment_link
- CRM / Workflow Simulation → Vapi Webhook Adapter: tool result
- Mock SMS / WhatsApp Gateway → Vapi Webhook Adapter: delivery result
- Vapi Webhook Adapter → Vapi.ai: tool response
- Environment Variables → Express Server: runtime settings
- Server Dependencies → Express Server: dependencies
- CRM / Workflow Simulation → Production CRM & Messaging: production replacement
- Mock SMS / WhatsApp Gateway → Production CRM & Messaging: production replacement
- Acceptance Test Matrix → Maya System Prompt: validates policy paths
- High-Level Design → Vapi.ai: production expectations