Hybrid AI + Rule Engine

AI Hybrid Voice Caller

Intelligent automated phone calling system for medical appointment reminders and scheduling. Powered by natural language AI with rule-based efficiency.

0 AI Providers
0 API Endpoints
0 Key Features
Go To API Click to Explore
System Design

Architecture Overview

A modular, event-driven architecture designed for reliability and scalability

🚀
API Request
POST /api/v1/calls/start
📞
Twilio
Voice API
Rule Engine
Fast Path
or
🧠
AI Fallback
Smart Path
🗄️
MongoDB
Patient Data
Integrations

APIs & Services

Powered by industry-leading cloud services and AI providers

Twilio
Voice API

Initiates outbound calls with Amazon Polly Neural voices for natural-sounding TTS

  • Outbound calls worldwide
  • Neural voice (Polly.Joanna)
  • Real-time speech recognition
  • Webhook event handling
TWILIO_PHONE_NUMBER: +1931345****
Google Gemini
Primary AI

Context-aware conversational AI that understands patient info and appointments

  • Natural language understanding
  • Context-aware responses
  • Real-time data access
  • TTS audio generation
MODEL: gemini-2.0-flash-live-001
Mistral AI
Fallback #1

Fast, cost-effective backup when Gemini fails or hits rate limits

  • Fast response times
  • Cost-effective
  • Reliable backup
  • Same capabilities
MODEL: mistral-small-latest
OpenAI
Fallback #2

Third fallback option if both Gemini and Mistral fail

  • GPT-4o-mini model
  • High reliability
  • Broad capabilities
  • Optional config
MODEL: gpt-4o-mini
MongoDB Atlas
Database

Stores all persistent data including patients, appointments, and call logs

👤 patients Name, phone, email
📅 appointments Patient, doctor, date, status
🕐 available_slots Open booking slots
📞 calls Call history & logs
Decision Making

Hybrid Decision Engine

Rule-based efficiency meets AI intelligence

Rule Engine

Fast Path

Handles clear, predictable responses instantly without AI latency

APPROVE "yes", "confirm", "okay" Confirm & end
REJECT "no", "cancel" Note & end
SCHEDULE "book for tomorrow" Book in DB
END_CALL "goodbye", "bye" End call
UNKNOWN Anything else → AI Fallback
🧠

AI Fallback

Smart Path

For complex or unclear responses requiring contextual understanding

Patient "What time did you say my appointment was?"
Rule Engine: UNKNOWN AI Fallback triggered
AI Response "Your appointment is on Friday at 10 AM with Dr. Anil Kumar. Would you like to confirm?"
Auto-Fallback Chain:
Gemini Mistral OpenAI Graceful Error
Process

Call Flow

End-to-end journey of an automated appointment reminder call

1

API Request

POST request initiates call

POST /api/v1/calls/start { "to_phone": "+91...", "context": "appointment reminder" }
2

Twilio Initiates Call

Outbound call placed to patient

3

Patient Answers

Webhook triggered: POST /api/v1/webhooks/voice

4

Personalized Greeting

AI speaks greeting with patient details

"Hello Priya! This is an automated reminder from CareFirst Clinic. You have an appointment with Dr. Anil Kumar on Friday, January 24 at 10:00 AM..."
5

Patient Responds

Speech captured and processed

6

Decision & Action

Rule engine or AI determines action, updates database

Reference

API Endpoints

RESTful API for managing calls and handling webhooks

Method Endpoint Description
GET /api/v1/health Health check endpoint
POST /api/v1/calls/start Initiate outbound call
GET /api/v1/calls/history Get call history
POST /api/v1/webhooks/voice Twilio voice webhook
GET /api/v1/audio/{filename} Serve generated audio files
Features

Key Capabilities

Production-ready features for automated voice calling

Outbound automated calls Working
Personalized greetings Working
Natural voice (Polly Neural) Working
Speech recognition Working
Rule-based intent detection Working
AI fallback for complex queries Working
Auto-switch AI providers Working
Real-time MongoDB access Working
Appointment booking Working
Call logging Working
⚠️ Gemini TTS (native audio) Requires paid tier
Getting Started

Quick Start

Get up and running in minutes

1

Install Dependencies

pip install -r requirements.txt
2

Seed Test Data

python scripts/seed_schedule_data.py
3

Start Server

uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
Pricing

Cost Considerations

Transparent pricing from all service providers

Service Free Tier Paid
📞 Twilio Trial credits (~$15) ~$0.013/min outbound
💎 Gemini Limited (rate limited) Pay-as-you-go
🌀 Mistral Limited Pay-as-you-go
🤖 OpenAI None Pay-as-you-go
🍃 MongoDB Atlas 512MB free Scales with usage
Going...