AI Telephony Bridge & Analytics for Call Automation
Description
A web-based AI-powered telephony system that integrates Asterisk PBX with OpenAI's Realtime API (GPT-4o Audio) to automate Medicare eligibility qualification calls using real-time voice conversations, finite state machines, and a Next.js enterprise analytics dashboard with live monitoring, call history, and AI-generated business intelligence reports.
Objectives
The primary objective of the AI Telephony Bridge & Analytics for Call Automation is to develop a production-grade, real-time telephony bridge that seamlessly connects Asterisk PBX with OpenAI's Realtime API to automate structured sales qualification calls for Medicare eligibility screening. Key objectives include: 1. Develop a real-time telephony bridge connecting Asterisk PBX calls with AI-powered conversation agents via WebSocket and FastAPI. 2. Implement intelligent dialog management using a deterministic Finite State Machine (FSM) governing nine structured qualification decision slots. 3. Automate Medicare eligibility qualification workflows, reducing the need for manual agent involvement in the qualification stage. 4. Establish real-time audio processing capabilities supporting G.711 µ-law codec and WebRTC standards for bidirectional audio streaming. 5. Build a comprehensive enterprise analytics dashboard (Next.js 14) with live monitoring, a real-time Nerve Center terminal, call history browser, inline audio playback, and an AI-powered Business Intelligence suite. 6. Ensure secure, compliant handling of customer data through JWT-based authentication, bcrypt password hashing, route-level authorization, and comprehensive input validation. 7. Provide a scalable architecture capable of handling multiple concurrent calls, secured via WebSocket Secure (WSS/TLS 1.2+). 8. Validate system correctness through a rigorous pytest/pytest-asyncio test suite comprising 17 test modules and 59 individual test cases, all passing successfully.
Socio-economic benefit
The AI Telephony Bridge addresses critical socio-economic challenges in modern call center operations and healthcare accessibility: 1. Cost Reduction: By automating routine Medicare sales qualification calls, organizations significantly reduce operational costs associated with human agents performing repetitive, scripted qualification tasks. This enables businesses of all sizes to scale their outreach without proportional increases in staffing. 2. Workforce Empowerment: Human agents are freed from repetitive qualification tasks, allowing them to focus on high-value activities requiring empathy, judgment, and complex problem-solving. This improves job satisfaction and makes better use of human talent. 3. Healthcare Access: By automating Medicare eligibility screening, the system helps ensure more individuals are efficiently connected to suitable healthcare coverage, contributing to improved health outcomes in underserved populations. 4. Consistent Quality: The structured FSM-driven dialog eliminates variability in customer interactions, ensuring every caller receives consistent, compliant, and fair treatment regardless of time of day or call volume. 5. Regulatory Compliance: Automated compliance monitoring and structured call management reduce the risk of regulatory violations in sensitive healthcare sales, protecting both businesses and consumers. 6. Data-Driven Decision Making: The enterprise analytics dashboard provides unprecedented visibility into call operations, enabling organizations to identify inefficiencies, improve conversion rates, and make evidence-based operational improvements. 7. Technology Transfer: As a COMSATS capstone project, this system demonstrates how Pakistani engineering talent can build production-grade AI systems, contributing to the local technology ecosystem and building capacity for AI-driven innovation in the country.
Methodologies
The project followed an iterative agile development methodology with the following key approaches: 1. System Architecture Design: The system was designed as a microservice-oriented architecture integrating Asterisk PBX (telephony layer), FastAPI backend (ASGI/Uvicorn), PostgreSQL database, and Next.js 14 frontend. WebSocket protocols were used for bidirectional real-time communication throughout. 2. Finite State Machine (FSM) Design: A deterministic FSM was designed and implemented to govern the structured Medicare qualification dialog across nine decision slots, ensuring consistent and auditable conversation flows. 3. Real-Time Audio Pipeline: G.711 µ-law audio codec handling was implemented using aiortc, with Asterisk MixMonitor used for disk-based call recording. Audio frames are streamed bidirectionally between Asterisk and OpenAI's Realtime API via WebSocket Secure connections. 4. AI Integration: OpenAI's Realtime API (GPT-4o Audio, WSS) was integrated as the conversational AI engine. Upon successful qualification, the system triggers an AMI Redirect command to Asterisk to transfer the caller to a licensed agent, and reports call disposition to ViciDial. 5. Security Implementation: JWT-based authentication (python-jose) with bcrypt password hashing, route-level authorization middleware, and comprehensive input validation were implemented to secure all API endpoints. 6. Enterprise Dashboard Development: A production-grade Next.js 14 dashboard was built featuring real-time analytics (7 live visualizations), a WebSocket-powered Nerve Center telemetry view, a call history browser with chat-bubble transcript viewer, inline audio playback, and an AI Business Intelligence suite using GPT-4o-mini for strategic insight generation with PDF/CSV scorecard dispatch via asynchronous email relay. 7. Quality Assurance: A structured test suite was built using pytest and pytest-asyncio, comprising 17 test modules and 59 individual test cases. All external dependencies (OpenAI API, Asterisk PBX, SMTP relay) were fully mocked to ensure deterministic, repeatable testing. All 59 test cases passed.
Outcome
The AI Telephony Bridge & Analytics for Call Automation successfully achieved all primary project objectives: 1. Working Telephony Bridge: A fully functional real-time telephony bridge was implemented, connecting Asterisk PBX with OpenAI's GPT-4o Audio Realtime API via WebSocket. The system handles live voice calls with bidirectional G.711 µ-law audio streaming, enabling natural AI-driven conversations indistinguishable from human interaction. 2. FSM-Driven Qualification: The deterministic Finite State Machine governing nine Medicare qualification decision slots was successfully implemented and validated. The FSM reliably governs dialog flow, collects structured customer information, and determines qualification outcomes consistently. 3. Automated Call Disposition: Upon successful qualification, the system automatically transfers callers to licensed agents via Asterisk AMI Redirect and reports call disposition to ViciDial, creating a seamless end-to-end automated qualification pipeline. 4. Enterprise Analytics Dashboard: A production-grade Next.js 14 dashboard was delivered featuring: seven real-time analytics visualizations, a WebSocket-powered live Nerve Center event terminal streaming USER_SAID, AI_RESPONSE, and TOOL_CALL events, a call history browser with chat-bubble transcript viewer and inline audio playback, and an AI-powered Business Intelligence suite generating strategic insights and dispatching PDF/CSV performance scorecards via asynchronous email relay. 5. Security & Compliance: Full JWT-based authentication, bcrypt password hashing, route-level authorization, and input validation were implemented and validated, ensuring the system meets enterprise security standards for handling sensitive Medicare call data. 6. Quality Assurance: All 17 test modules and 59 individual test cases in the pytest/pytest-asyncio suite passed successfully, validating correctness of FSM logic, tool guardrails, authentication mechanisms, session management, cleanup routines, disposition logic, and the reporting pipeline. 7. Scalable, Containerized Deployment: The system was containerized using Docker (Dockerfile + docker-compose) for reproducible deployment on Ubuntu 22.04 LTS, with architecture designed to support future cloud scaling on AWS/GCP.
Gallery
More from Computer Science
Ustad Go: An AI-Powered Mobile and Web Ecosystem for Verified Local Service Provision in P…
Ustad Go is a dual-platform solution bridging the gap between skilled local service providers and households.…
Supervisor: Dr. Wasif Nisar
Sales Distribution Hub
The Sales Distribution Hub is a web-based management system designed for Masood & Company to automate and stre…
Supervisor: Dr. Wasif Nisar.
AI Based Road Damage Detection System
AI Based Road Damage Detection System is a smart application that uses YOLOv8 and computer vision techniques t…
Supervisor: Mehwish Mukhtar
EvaluTech: AI-Powered Hiring & Job Platform for Employers and Applicants
EvaluTech is an intelligent recruitment management platform that streamlines the complete hiring lifecycle fro…
Supervisor: Dr. Wasif Nisar