The Problem
Most "AI support bot" builds skip the part that actually matters: what happens when the model doesn't know the answer. A bot that improvises past its knowledge base erodes trust faster than no bot at all, especially over WhatsApp, where a wrong answer about a refund or cancellation is a support ticket waiting to happen.
Architecture
WhatsApp Trigger → Config/Extract → Text Message Filter → OpenRouter Agent (Pinecone retrieval, Gemini embeddings, per customer memory) → [answerable: reply on WhatsApp] / [not answerable or sensitive: Gmail escalation → predefined hold message]
What It Does
Retrieval grounded answering: the agent only answers from content actually retrieved out of a Pinecone knowledge base index; it isn't free associating from model weights.
Per customer conversation memory: a windowed memory buffer keyed per phone number, so a multi turn WhatsApp thread stays coherent without replaying the whole history into every prompt.
Explicit escalation triggers: refund, cancellation, and "get me a human" requests are routed to a Gmail alert to the support team rather than handled by the model, with a predefined hold message sent back so the customer isn't left hanging.
Input filtering before the AI runs: nontext WhatsApp events (delivery receipts, reactions) are dropped before they reach the agent, keeping the model call scoped to actual messages.
Engineering Focus
The interesting problem here isn't the WhatsApp webhook: it's the boundary condition: deciding, reliably, when the agent should not answer. That decision lives in the retrieval confidence and category logic, not in prompt wording, which is the part worth scrutinizing before trusting this in front of real customers.
What I'd Harden
Before production I'd want: idempotency on the WhatsApp webhook (duplicate delivery is common), a retry/backoff around the Pinecone and Gemini calls, and audit logging on every escalation so "the bot didn't know" is traceable after the fact, not just implied by an email in someone's inbox.
Gallery


