
Project Overview
In modern business automation, the biggest failure point is an AI that gets stuck in a loop. For this project, I developed a modular middleware that monitors WhatsApp conversations in real-time. The system utilizes a "Confidence Scoring" algorithm to determine exactly when an AI agent should step back and notify a human administrator.
The Challenge
Businesses using automated WhatsApp flows often lose leads because:
- AI Hallucination: The bot provides incorrect data for complex queries.
- Emotional Friction: The customer becomes frustrated and needs empathy, not logic.
- Dead Ends: The bot reaches the end of its programmed logic with no exit strategy.
The Engineering Solution
1. The "Observer" Architecture
Instead of a simple linear bot, I built an Observer Module in Python. This module sits between the Meta Business API and the LLM (Large Language Model). It parses every incoming message for "Urgency Flags" and "Negative Sentiment."
2. Confidence Score Thresholds
I implemented a logic gate where every AI response is assigned a score:
- High Confidence (>0.85): The AI responds instantly.
- Low Confidence (<0.60): The AI pauses, sends a "One moment while I fetch a specialist" message, and triggers the Handover.
3. The Multi-Channel Alert System
Once a handover is triggered, the system doesn't just wait. It executes a Modular Alert Sequence:
- Push Notification: Sent via a dedicated administrative dashboard.
- System Log Entry: Records the exact state of the conversation for the human agent.
- WhatsApp Priority Hook: Re-routes the customer's next message directly to a human-monitored "Live Chat" state, bypassing the bot entirely.
Technical Highlights
- Stack: Python (Processing), FastAPI (Webhooks), Meta Business API, MongoDB (Conversation State).
- Modularity: The handover logic is a standalone module. It can be "plugged into" any existing WhatsApp bot without rewriting the core business logic.
- Safety Net: Implemented a "Global Kill-Switch" pop-up on the admin dashboard, allowing a human to force-takeover any active thread with one click.
The Result
- 0% Lead Drop: Customers are never left without an answer; they are either helped by the bot or greeted by a human within 60 seconds.
- Reduced Overhead: Human agents only intervene in 15% of total conversations—the most high-value ones.
- Scalability: The system was built to handle 1,000+ concurrent threads, managed by a small team of 2 agents.
"Automation is not about replacing the human; it’s about making sure the human only works on what matters."