Skip to content

//AI · Backend

A WhatsApp support agent that answers from your docs, and knows when to stop

What kills an AI support bot is not a model that is not smart enough. It is one confident, invented answer given to one real customer. So this one answers only from your documents, and below a confidence threshold it hands the conversation to a human with the transcript and detected intent attached.

High-level diagram: a WhatsApp user messages the WhatsApp Business API, which webhooks into a chatbot service that queries a knowledge base and conversation store, calls OpenAI for generation, and escalates low-confidence answers to a human agent.
Scroll to explore the diagram

The problem

The support team was drowning in the same questions. Not hard ones. Where is my order, how do I change my plan, is this covered. But there were thousands of them and they arrived at all hours.

WhatsApp was where the customers already were, so that is where it had to live. Nobody was going to download an app or open a support portal.

The thing that actually mattered

Everyone assumes the risk with an AI support bot is that the model is not smart enough. In our experience that is not what kills these projects.

What kills them is one confident, fluent, completely invented answer given to one real customer. It happens once, someone screenshots it, and the support team never trusts the thing again. Within a month it is quietly switched off.

So the build has two rules that sit above everything else. It only answers from your documents: product docs, FAQs and resolved tickets are embedded and indexed, retrieval happens before generation, and if the answer is not in there, there is nothing to answer with. And it is allowed to say it does not know: below a confidence threshold it stops and hands the conversation to a human, with the transcript and detected intent attached so the agent is not starting cold.

That second rule feels like a downgrade when you are demoing it. It is not. A bot that cleanly resolves 60% of queries is worth far more than one that attempts all of them and gets 15% wrong.

How it is built

Serverless, because support traffic is bursty and there is no sense paying for idle capacity.

WhatsApp webhooks hit API Gateway, then a Lambda that verifies the signature, deduplicates, and drops the message onto an SQS FIFO queue. The queue matters more than it looks. Real people fire three messages in a row, and WhatsApp retries webhooks, so without per-conversation ordering you get replies out of sequence or sent twice.

An orchestrator Lambda picks the message up. LangChain handles routing and the retrieval chain. Source documents live in S3, embedded into an OpenSearch Serverless vector index. Conversation state sits in DynamoDB. Generation and embeddings both go out to the OpenAI API, which is outside the AWS boundary, so it gets its own timeout and fallback path.

CloudWatch tracks latency, token spend and resolution rate. Every answer can be traced back to the exact documents it cited, which turned out to be the feature the support team used most.

One WhatsApp thing worth knowing

The Business Platform has a 24-hour customer service window. Inside it you can reply freely. Outside it you need pre-approved message templates.

This is not a technical detail, it shapes the product. If someone messages at 11pm and the bot escalates, a human has until 11pm the next day to reply freely. After that the conversation changes shape entirely. Anyone who has shipped on WhatsApp has hit this; anyone who has not will find out the hard way.

Where it landed

Average query resolution time came down and satisfaction scores went up, with round-the-clock coverage and no added headcount.

But the number worth watching is the escalation rate. It tells you what the bot does not know, which tells you what documentation to write next.

Detailed view

Detailed AWS diagram: WhatsApp webhooks reach API Gateway, an ingest Lambda verifies and deduplicates before enqueuing to SQS FIFO, an orchestrator Lambda runs LangChain routing against S3 source documents indexed in OpenSearch Serverless with conversation state in DynamoDB, and the OpenAI API sits outside the AWS boundary with its own timeout and fallback.
Scroll to explore the diagram