WhatsApp is where a large share of Indian customers already talk to businesses. So it is no surprise that many companies want an AI assistant there that can answer questions from their own documents: product details, policies, FAQs, service manuals. The standard way to build this is called Retrieval-Augmented Generation, or RAG. This article explains how a WhatsApp RAG chatbot is put together, which decisions matter most, and which mistakes to avoid.

What RAG means in plain words

A language model on its own only knows what it learned during training. It does not know your company's price list or your return policy. RAG fixes that in two steps:

  1. Retrieve: when a customer asks a question, search your own documents for the passages most likely to contain the answer.
  2. Generate: give those passages to the model along with the question, and instruct it to answer using only that material.

The model becomes a writer that works from your notes rather than from memory. Done well, this keeps answers accurate and up to date without retraining any model.

The building blocks

1. The WhatsApp connection

Businesses connect to WhatsApp through the official WhatsApp Business Platform, usually via a Business Solution Provider. The provider gives you a verified business number, a dashboard and a webhook: every incoming customer message is sent to a URL you control, and you send replies back through their API. Your chatbot is simply the service behind that webhook.

Two platform rules shape the design. First, when a customer messages you, you can reply freely within a customer service window; outside it, you can generally only send pre-approved template messages. Second, the platform has policies on what businesses may send. Read your provider's documentation on both before you design flows that send messages on your own initiative.

2. The knowledge base

This is the set of documents the bot will answer from. Quality here matters more than any model choice. Before indexing anything:

  • Remove outdated documents. If two files disagree, the bot will sometimes quote the wrong one.
  • Prefer clear, factual text: FAQs, policy pages, product sheets.
  • Convert scanned PDFs to real text; images of text cannot be searched.
  • Give each document a title and a date so you can trace answers back to sources.

3. Chunking

Documents are split into smaller pieces, called chunks, before they are stored. The model receives a few chunks per question, not whole manuals. Chunking choices directly affect answer quality:

  • Too small, and a chunk loses its context: a sentence about "the fee" without saying which fee.
  • Too large, and the relevant sentence is buried among unrelated text, and fewer chunks fit into the prompt.
  • Split on meaning, not character count, where possible: by heading, by question-answer pair, by paragraph.
  • Add a little overlap between neighbouring chunks so ideas that span a boundary are not cut in half.
  • Prefix each chunk with its document title and section, so a chunk about "cancellation" also says which product it belongs to.

4. Embeddings and the vector database

Each chunk is converted into an embedding: a list of numbers that represents its meaning. Questions are converted the same way. Searching then means finding the chunks whose embeddings are closest to the question's embedding. This finds relevant text even when the customer's words differ from the document's words.

The embeddings are stored in a vector database. You do not need an exotic system to start. PostgreSQL with the pgvector extension, available on managed services such as Supabase, is enough for most business knowledge bases and keeps your data in a familiar database next to everything else.

5. Retrieval

When a message arrives, the bot embeds it, fetches the top few matching chunks and passes them to the model. Some improvements are worth adding early:

  • Hybrid search: combine meaning-based search with plain keyword search. Keyword search is better at exact terms like model numbers and plan names.
  • Use conversation context: "What about the blue one?" means nothing on its own. Rewrite follow-up questions into complete questions using the recent chat history before searching.
  • Filter by metadata: if the customer has told you which product they own, search only that product's documents.

6. Generation and guardrails

The prompt to the model should say, in clear words:

  • Answer only from the provided passages.
  • If the passages do not contain the answer, say so and offer to connect the customer to a person.
  • Keep replies short and readable on a phone screen.
  • Do not make promises about refunds, prices or timelines that are not in the passages.

This "I don't know" behaviour is a feature, not a weakness. A bot that confidently invents a refund policy on WhatsApp creates written evidence of a promise the business never made.

Handing over to humans

Every business bot needs a clean path to a person. Typical triggers:

  • The customer asks for a human.
  • The bot could not find an answer twice in a row.
  • The topic is sensitive: complaints, payments, legal issues.

When the handover happens, pass the conversation so far to the agent so the customer does not have to repeat themselves.

Language

Indian customers often write in Hinglish, in Hindi script, or mix languages within a sentence. Test your retrieval with real customer phrasing, not just clean English. Many modern embedding models handle multiple languages, but quality varies, so measure it on your own examples rather than assuming.

Testing before launch

Collect fifty real questions from your support team's chat history. For each, write down the correct answer and which document contains it. Run them through the bot and check two things separately:

  1. Retrieval: did the right chunk appear in the results?
  2. Answer: was the final reply correct, complete and polite?

If retrieval fails, fix chunking, metadata or search. If retrieval succeeds but the answer is wrong, fix the prompt. Separating the two saves hours of guessing.

Keeping it fresh

The knowledge base must change when the business changes. Set up a simple process: when a policy or price is updated, the document is updated and re-indexed the same day. Review a sample of real conversations weekly and add missing information to the documents rather than patching the prompt. A RAG bot is only ever as good as the knowledge it is given.

Originally published on my blog. More practical AI guides: omkarghate.blogspot.com.