Skip to content

Senthil455/Rupeezy-AI-Voice-RM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rupeezy AI Voice RM

Multilingual Lead Conversion Agent -- AI for Bharat Hackathon, Theme 7

Converts partner leads from 18% to 40%+ conversion rate using an AI voice agent that speaks in Hindi, English, Hinglish, Tamil, Telugu, Marathi, Bengali, and Gujarati -- 24/7, with zero queue delay.


Quick Start (3 Steps)

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • GROQ API key (free tier works)

Step 1 -- Clone & Configure

git clone <repo>
cd rupeezy-ai

# Set your API key
export GROQ_API_KEY=gsk-your-key-here

# OR create backend/.env file:
echo "GROQ_API_KEY=gsk-your-key-here" > backend/.env

Step 2 -- One-Command Start

chmod +x start.sh
./start.sh

Step 3 -- Open Dashboard

http://localhost:5173

API Docs: http://localhost:8000/docs


What This System Does

Problem Our Solution
Leads go cold (avg 3.6hr RM response) AI calls within < 5 minutes, 24/7
RM speaks 1-2 languages Agent speaks 8 Indian languages
1 RM = 1 call at a time Agent handles unlimited parallel calls
18% conversion baseline Target: 40%+ conversion
No audit trail Full transcript + summary for every call

Project Structure

rupeezy-ai/
├── backend/                  # FastAPI Python backend
│   ├── main.py               # App entry point + logging config
│   ├── routes/
│   │   ├── agent.py          # Core AI agent endpoints
│   │   ├── leads.py          # Lead management CRUD + validation
│   │   ├── conversations.py  # Conversation history
│   │   ├── analytics.py      # Dashboard analytics
│   │   └── whatsapp.py       # WhatsApp simulation
│   ├── models/
│   │   └── store.py          # JSON data store with file locking
│   ├── ai/
│   │   ├── prompts/
│   │   │   └── agent_prompt.py   # System prompts + injection guards
│   │   ├── logic/
│   │   │   └── conversation_engine.py  # State machine + LLM calls + retry
│   │   └── scoring/
│   │       └── scorer.py     # Lead qualification engine
│   ├── services/
│   │   └── whatsapp.py       # WhatsApp message service
│   ├── data/                 # JSON data files (auto-created)
│   ├── requirements.txt
│   ├── .env.example
│   ├── .dockerignore
│   └── Dockerfile
│
├── frontend/                 # React + Vite + Tailwind CSS
│   ├── src/
│   │   ├── App.jsx           # Router + layout
│   │   ├── main.jsx          # Entry point
│   │   ├── index.css         # Global styles
│   │   ├── components/
│   │   │   ├── chat/
│   │   │   │   └── ChatInterface.jsx   # AI conversation UI
│   │   │   └── shared/
│   │   │       └── index.jsx           # Reusable components
│   │   ├── pages/
│   │   │   ├── Dashboard.jsx           # KPI dashboard
│   │   │   ├── AgentDemo.jsx           # Interactive demo
│   │   │   └── AllPages.jsx            # Other pages
│   │   ├── services/
│   │   │   └── api.js                  # Axios API layer
│   │   └── hooks/
│   │       └── useLeads.js             # Custom hooks
│   ├── package.json
│   ├── vite.config.js
│   ├── tailwind.config.js
│   ├── .dockerignore
│   └── Dockerfile
│
├── docker-compose.yml        # Docker deployment
├── netlify.toml              # Netlify deployment config
├── start.sh                  # One-command local start
└── README.md

Architecture Overview

+-------------------------------------------------------------+
|                     REACT FRONTEND                          |
|  Dashboard · Agent Demo · Pipeline · Analytics · Handoff   |
+-----------------------------+-------------------------------+
                              | REST API (axios)
+-----------------------------v-------------------------------+
|                   FASTAPI BACKEND                            |
|                                                             |
|  /api/agent/start-call   --> Conversation Engine            |
|  /api/agent/send-message --> LLM (Groq / Llama 3)          |
|  /api/agent/end-call     --> Scorer + Summary               |
|  /api/leads/             --> Lead Management                |
|  /api/analytics/         --> Dashboard Data                 |
|  /api/whatsapp/          --> WhatsApp Simulation            |
+-------------+-----------------------+-----------------------+
              |                       |
+-------------v----------+  +---------v-------------------+
|  Groq API              |  |   JSON Data Store            |
|  (Llama 3 70B)         |  |   (file-locked, deduped)     |
|  + retry logic         |  |   MongoDB-ready              |
+------------------------+  +-----------------------------+

API Endpoints

Agent (Core)

Method Endpoint Description
POST /api/agent/start-call Start AI call with lead
POST /api/agent/send-message Send user message, get AI response
POST /api/agent/end-call End call, score lead, generate summary

Leads

Method Endpoint Description
GET /api/leads/ List all leads
POST /api/leads/ Create single lead (deduped by phone)
POST /api/leads/bulk Import batch
POST /api/leads/seed Seed 20 demo leads
PATCH /api/leads/{id} Update lead (validated fields)

Analytics

Method Endpoint Description
GET /api/analytics/snapshot KPI snapshot
GET /api/analytics/funnel Conversion funnel
GET /api/analytics/rm-queue Hot leads for RM

WhatsApp

Method Endpoint Description
POST /api/whatsapp/send Send (simulated) message
GET /api/whatsapp/log Message history

Supported Languages

Language Script Status
Hindi Devanagari + Roman Full
English Latin Full
Hinglish Mixed Full
Tamil Tamil Full
Telugu Telugu Full
Marathi Devanagari Full
Bengali Bengali Full
Gujarati Gujarati Full

All languages are supported for both LLM conversation and voice input (via Web Speech API).


Lead Scoring Model

Score = Sum(signals)

Hot Signals   (+3 each): "interested", "sign up", "join", "ready", "haan"
Warm Signals  (+1 each): "maybe", "tell me more", "explain"
Cold Signals  (-3 each): "not interested", "remove", "stop"
Engagement    (+2):      > 3 exchanges
Questions     (+2 each): Lead asks clarifying questions
Network mention (+2):    Mentions contacts / clients
Objection resolved (+1): Each handled objection

Thresholds:
  >= 8  --> HOT  (RM immediate handoff)
  4-7   --> WARM (WhatsApp + 48hr follow-up)
  < 4   --> COLD (nurture sequence)

Conversation State Machine

INIT --> GREETING --> PITCH --> QUALIFICATION --> OBJECTION_HANDLING --> CLOSING --> END

The state machine is sentiment-aware:

  • Strong rejection signals skip directly to END, avoiding pushing uninterested leads through the full pitch.
  • High engagement signals (2+ hot signals) extend the QUALIFICATION phase, giving interested leads more time to ask questions.

Data Integrity

File Locking

The JSON data store uses portalocker for cross-platform file-level locking. All write operations use an atomic read-modify-write transaction pattern to prevent data corruption from concurrent API requests.

Lead Deduplication

The create_lead() endpoint checks for existing leads with the same phone number before creating a new record. Duplicate submissions return the existing lead instead of creating a new one.

Input Validation

All API endpoints use Pydantic models for request validation. The PATCH /api/leads/{id} endpoint uses a LeadUpdate model with a field whitelist that prevents clients from overwriting critical fields like id, created_at, or score.


Security

Prompt Injection Protection

User messages are wrapped with XML-style delimiters that reinforce the agent's role and instruct the LLM to treat input as conversational only. A keyword-based filter in the send-message endpoint also intercepts common injection patterns before they reach the LLM.

CORS Configuration

CORS origins are configurable via the CORS_ORIGINS environment variable (comma-separated). Defaults to localhost URLs for development.


Configuration

Edit backend/.env:

GROQ_API_KEY=gsk-...              # Required
CORS_ORIGINS=http://localhost:5173  # Optional (comma-separated)
ELEVENLABS_API_KEY=...             # Optional (production TTS)
META_WHATSAPP_TOKEN=...            # Optional (production WhatsApp)

Model

  • Provider: Groq
  • Model: llama3-70b-8192
  • Benefit: Ultra-fast inference + free tier
  • Retry: Exponential backoff (3 attempts, 1s/2s/4s delays) on transient failures

Logging

The backend uses Python's standard logging module with structured output:

2026-06-23 18:11:51 [INFO] rupeezy: Starting Rupeezy AI Voice RM backend
2026-06-23 18:11:52 [WARNING] rupeezy.store: Data file does not exist: leads.json
2026-06-23 18:11:53 [ERROR] rupeezy.engine: LLM response generation failed after 3 retries, using fallback: ...

Logger hierarchy: rupeezy (main), rupeezy.store (data layer), rupeezy.engine (LLM interaction).


Docker Deployment

# Set API key
export GROQ_API_KEY=gsk-your-key

# Start with Docker
docker-compose up --build

# Access at http://localhost:5173

Both backend and frontend include .dockerignore files to exclude caches, local configs, and unnecessary files from Docker images.


Test the API

# 1. Seed demo leads
curl -X POST http://localhost:8000/api/leads/seed

# 2. Get a lead ID
curl http://localhost:8000/api/leads/

# 3. Start a call
curl -X POST http://localhost:8000/api/agent/start-call \
  -H "Content-Type: application/json" \
  -d '{"lead_id": "LEAD_ID_HERE", "preferred_language": "hindi"}'

# 4. Send a message
curl -X POST http://localhost:8000/api/agent/send-message \
  -H "Content-Type: application/json" \
  -d '{"conversation_id": "CONV_ID", "message": "mujhe bataiye iske baare mein"}'

# 5. End the call
curl -X POST http://localhost:8000/api/agent/end-call \
  -H "Content-Type: application/json" \
  -d '{"conversation_id": "CONV_ID"}'

Hackathon Evaluation Coverage

Criterion Implementation
Problem Understanding Structural failures analysis in agent prompts
Technical Innovation LLM + state machine + multilingual scoring
Real-World Deployability FastAPI + React, Docker-ready, API-first
Demo Quality Live interactive chat, voice input, real scores
Scalability Stateless API, JSON-to-MongoDB swap, horizontal scale

Production Roadmap

Phase Timeline Milestones
Hackathon MVP Week 1 Browser demo, simulated calls
Beta Month 1 Twilio integration, real calls
v1.0 Month 3 ElevenLabs TTS, 8 languages live
Scale Month 6 10K leads/day, CRM integrations

Team

Built for AI for Bharat Hackathon 2026 -- Theme 7: AI Voice Agent for Partner Lead Conversion


License

MIT -- Open source for hackathon evaluation.

About

Rupeezy AI Voice RM is a multilingual AI voice agent designed to solve the structural failure in Rupeezy's partner program, where only 18% of leads currently convert to Authorized Persons (APs).

Topics

Resources

License

Stars

7 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors