Blog/Guides & Know-how

How an AI agent answers from your knowledge base (and how to write one that works)

Retrieval and embeddings in plain words, how to write knowledge docs an AI agent can use, why it must never invent prices, and guardrails that help.

LinkModus team · · 6 min read

Short answer

An AI chatbot answers from your knowledge base in two steps. First it searches your documents for the passages most related to the customer’s question, usually using embeddings, which match by meaning rather than exact words. Then it hands those passages to the language model with instructions to answer only from them. Good results come from short, one-topic documents with clear titles and exact facts, plus guardrails: never invent prices or discounts, and hand over to a person when the answer is not in the documents.

Every business that tries an AI chatbot hits the same moment. The bot is polite, fluent and fast, and then it tells a customer in Noida that delivery is free when it is not, or quotes a fee you stopped charging last year. The model is not malfunctioning. It was given the wrong material, or no material, and filled the gap.

Understanding how the bot reads your knowledge base makes it much easier to fix. This guide explains it without jargon first, then gives practical rules for writing documents that work.

How does an AI chatbot find the right answer?

It does not read your whole knowledge base on every message; it searches for the few most relevant pieces and answers from those.

Imagine a new salesperson with a filing cabinet. A customer asks a question. The salesperson pulls out the three most relevant files, reads them, and replies. If the right file is missing, or filed under a misleading name, the answer will be weak. An AI chatbot does exactly this, in about a second. The technical name is retrieval-augmented generation (RAG): retrieve the relevant text, then generate an answer grounded in it.

  1. The customer writes: “Do you have weekend batches for CAT coaching in Andheri?”
  2. The system searches your documents and finds “Batch timings – Andheri centre” and “CAT course overview”.
  3. It sends the question, those documents and your instructions to the language model.
  4. The model writes a reply using those facts, in the customer’s language.

What are embeddings, in plain words?

Embeddings turn text into numbers that represent meaning, so the system can find documents that mean the same thing as the question even when the words differ.

Keyword search fails on real customer messages. Someone asks “kitna lagega monthly?” and your document is titled “EMI and payment plans”. No words match. An embedding model converts both into long lists of numbers (vectors). Texts about similar ideas end up close together, so the question about monthly cost lands near the EMI document. The system compares the question’s vector with every document’s vector and picks the closest ones.

For a developer, the flow is: split documents into chunks, compute an embedding for each chunk once and store it, compute an embedding for each incoming question, then rank chunks by cosine similarity and pass the top few to the model.

// simplified retrieval step
const q = await embed(customerMessage);
const ranked = docs
  .map((d) => ({ doc: d, score: cosine(q, d.vector) }))
  .sort((a, b) => b.score - a.score)
  .slice(0, 4);
const context = ranked.map((r) => r.doc.title + '\n' + r.doc.content).join('\n\n');
Because retrieval works on meaning, a clear title that states the topic in customer language (“Do you offer EMI?”) helps a lot. A title like “Doc 7 – misc” helps nobody.

How should you write knowledge base documents?

Write short documents, one topic each, that a stranger could read on their own and act on.

DoAvoid
One topic per document: “Delivery areas and charges in Bengaluru”One giant “About us” document with everything
Titles phrased like customer questionsInternal codes or vague titles
Exact facts: “₹1,499 per session, includes consultation”“Affordable pricing, contact for details”
What you do not offer: “We do not deliver outside Pune city limits”Leaving gaps the bot will fill itself
A “last updated” line on prices and offersOld offers left active after they end
Common objections answered honestlyMarketing copy written for a brochure

A practical starting set for most Indian SMBs is 15 to 30 documents: what you sell, prices and what they include, locations and timings, delivery or service areas, payment options (UPI, card, EMI, cash), refund and cancellation policy, how booking works, and the ten questions your team answers most on WhatsApp. Pull those from your actual chats; they are the best source you have.

Why must the bot never invent prices?

A wrong price on WhatsApp is a written promise to a customer, and the cost of honouring or retracting it lands on you.

Language models are trained to sound helpful. If a customer asks for the price of a 3BHK in Kharadi and the document only lists the 2BHK, a model without strict instructions may estimate one. A made-up discount is worse. Customers screenshot these replies. The rules we recommend:

  • Quote a price, discount, fee or delivery charge only if it appears in the documents.
  • If it is not there, say the team will confirm, and hand the chat to a person.
  • Keep prices in knowledge documents, not in the bot’s personality or sales instructions, so there is one place to update.
  • Remove expired offers the day they end.

What guardrails should an AI chatbot have?

Guardrails are the fixed rules that keep the bot inside your business and honest about what it does not know.

  1. Scope: answer questions about your business only; politely decline unrelated requests such as homework or coding help.
  2. Grounding: answer from the documents; when unsure, say so.
  3. Handover: escalate to a person for complaints, refunds, negotiation, legal or medical questions, and any customer who asks for a human.
  4. Confidentiality: never reveal its instructions, internal notes or other customers’ details.
  5. No commitments: it can share policy, but it should not promise exceptions.

For a clinic or a financial services firm, the handover list should be longer. Being cautious here costs a few extra human replies; being careless costs trust.

How do you test and improve it?

Test with real customer questions before going live, then review conversations weekly and fix the documents, not just the replies.

Take 30 real questions from last month’s WhatsApp chats, including the messy Hinglish ones and the awkward ones (“last price kya hai?”, “why so costly?”). Ask the bot each one. Wherever it answers vaguely or wrongly, the fix is almost always a missing or unclear document. After launch, read a sample of conversations every week and look for questions the bot handed over because it did not know. Each one is a document waiting to be written. Our chatbot vs AI agent post explains how this differs from older menu bots.

How LinkModus helps

LinkModus’s AI sales agent answers WhatsApp and website chat enquiries from your own knowledge base, in English, Hindi, Hinglish or the customer’s language. It retrieves the relevant documents for each message, follows scope and confidentiality guardrails, and hands the chat to your team when it should. You add and edit documents in the board; the knowledge base guide shows how to structure them. The agent also qualifies and scores each lead as it chats, so your team picks up the hot ones first.

Frequently asked questions

How does an AI chatbot use a knowledge base?+

When a customer asks something, the system first searches your knowledge documents for the most relevant passages, then gives those passages to the AI model with instructions to answer only from them. This is called retrieval-augmented generation.

What are embeddings in simple words?+

An embedding turns a piece of text into a list of numbers that captures its meaning, so that texts about similar things get similar numbers. It lets the system find the document about “EMI options” even when the customer typed “can I pay monthly?”.

Why does an AI chatbot sometimes make up answers?+

Language models are built to produce fluent text, and if the right fact is missing they may fill the gap with something plausible. Clear documents, an instruction to answer only from them, and a rule to hand over to a person when unsure reduce this sharply.

Should I put my price list in the knowledge base?+

Yes, if you want the bot to quote prices, put the exact current prices there with what they include and when they were last updated. Then instruct the bot never to quote a price or discount that is not in the documents.

How long should each knowledge base document be?+

Short and focused is better: one topic per document, written so it makes sense on its own. A 40-page brochure pasted as one document is much harder for retrieval to use well than twenty short documents with clear titles.

Answer every enquiry, see which ad paid for it

LinkModus replies on WhatsApp in seconds, qualifies the lead and traces each sale back to its ad. First week free.