ANKIT YADAV

01 · AI Automation

Live in production

WhatsApp AI Contact Center

WhatsApp support agent for an insurance team. It answers policy, claim, and appointment questions through tool calls, escalates when a person should take over, and serves about 2,000 to 5,000 chats a day.

Role
Sole engineer
Scope
WhatsApp Cloud API, tools, escalation, reporting
Stack
Node.js, Express.js, LangChain

Client details are confidential. No client data is shown.

WhatsApp AI Contact Center01 · SYNTHETIC EXAMPLEChannel: WhatsAppWhat is my claim status?Claim SAMPLE-104 is in review.tool: get_claim_statusHandoff to a human agentOpenAIClaude · fallbackGroq
WhatsApp message path: webhook, dedupe, context, model router, tools, frustration check, handoff or reply, then logging.WhatsAppWebhookDedupeContextLLM routerToolsFrustration checkHandoff or replyLog
WhatsApp message path: webhook, dedupe, context, model router, tools, frustration check, handoff or reply, then logging.

Overview

I built and shipped this contact center on my own. Customers reach it on WhatsApp, and the same service also has a web path. The model is OpenAI GPT-4o-mini, orchestrated with LangChain. It can register a policy, open or check a claim, read status, and book an appointment by calling tools, instead of inventing those answers. When the turn should be a person, the chat is escalated to a live agent.

The desk handles about 2,000 to 5,000 chats a day, in English, Hindi, and Gujarati. It is sized for about 1,000 concurrent chats. A human agent on the same desk holds about two.

The problem

The conversations already live on WhatsApp. Moving the customer to another channel loses the thread. The answers that matter are operational: a policy, a claim, a status, an appointment. A model that only chats cannot see that data, and a timeout cannot be the end of the customer's message. The reporting around containment and agent KPIs was also too slow to use during the day.

What I built

  • The Node.js and Express service, with MongoDB and Socket.IO, in front of the WhatsApp Cloud API.
  • The LangChain agent and the tool schemas for policy registration, claims, status checks, and appointments.
  • Department routing, so a chat lands with the right queue.
  • Human-intent detection, and escalation to a live agent when the model should stop.
  • Memory that loads recent chats from Redis on every message, and older important details from a vector database when the recent window is not enough.
  • Agenda.js jobs with retries for scheduled follow-ups.
  • The FastAPI and Pandas reporting service for containment and agent KPIs.
  • GitHub Actions deployment to AWS EC2, with PM2 and zero-downtime releases.

Architecture

A message arrives from WhatsApp Cloud API. The service loads the recent thread from Redis and, when needed, older context from the vector store. LangChain chooses a tool or a reply. Tools read policy, claim, status, and appointment data through the existing APIs. If the intent classifier says a person should take the chat, the turn is handed to a live agent with the thread still attached. Socket.IO keeps the agent desk current. MongoDB holds the operational records the reports read.

Diagram

Key engineering decisions

The primary model is GPT-4o-mini. Claude and Groq are integrated as additional model endpoints on the same platform, so a provider is not a single point of failure for the wider AI surface. The agent does not answer policy or claim facts from memory. Those facts come from tools.

Recent turns stay in Redis because every message needs them immediately. Older details stay in a vector store so the prompt does not grow with the whole history. That is the cost control: pass both, but only the older slice that the turn actually needs.

Hard problems and how I solved them

Report queries for containment and agent KPIs were taking 20 to 60 seconds and timing out, which blocked the contact-centre team. I added compound MongoDB indexes, batch aggregation, and connection pooling. The same queries dropped to under 100 milliseconds, a reduction of more than 95 percent.

A chat that should leave the model was staying in the bot. The agent now classifies human intent and escalates to a live agent, with the conversation context still available.

Follow-ups and campaigns have to survive a failed send. Agenda.js jobs retry that work instead of losing the schedule on the first error.

Reliability and failure handling

Tool calls are the path for operational facts. Escalation is the path when a person should answer. Background work retries. Deploys go out through GitHub Actions to EC2 under PM2 without taking the process down for the release.

Outcome

The bot is live. Volume is about 2,000 to 5,000 chats a day, at about 1,000 concurrent chats, against about two chats per human agent. The KPI reports that used to time out now return in under 100 milliseconds.

Stack

Node.js, Express.js, MongoDB, Redis, Socket.IO, LangChain, OpenAI GPT-4o-mini, with Claude and Groq available as model endpoints. WhatsApp Cloud API. FastAPI and Pandas for the reports. Agenda.js, GitHub Actions, AWS EC2, PM2.

What I would improve next

A published evaluation set for the intent classifier, and a clearer per-provider error budget, so a fallback is chosen from measured failure rather than from a single timeout story.

Client details are confidential. No client data is shown.