AI integration

RAG chatbot: how it works and when to build one.

A chatbot that answers from your own policies, manuals, and product documents sounds like an easy win. Sometimes it is. Sometimes a packaged tool or a better search page would do the job, and sometimes the documents are not ready for any of them. This guide explains how a RAG chatbot works, where it goes wrong, and how to scope one before anything is built.

By SETITUP ยท Updated

The short answer

RAG stands for retrieval-augmented generation. A RAG chatbot does not answer from what a language model happens to remember. When someone asks a question, the system first searches your documents for the passages most likely to hold the answer, then gives those passages to the model and asks it to write an answer from them.

The OWASP Top 10 for LLM Applications, a security guide published by the OWASP Foundation, describes RAG as combining pre-trained language models with external knowledge sources. In plain terms, the model supplies the language and your documents supply the facts.

That split is why RAG suits questions such as what our returns policy says about opened items, which torque setting a manual gives for a part, or what a contract says about notice periods. It also explains most of the ways it fails: if search finds the wrong passage, or the right passage is out of date, the answer will be wrong however fluent it sounds.

The parts of a RAG chatbot.

  • Sources

    The documents and records the chatbot may answer from, such as PDFs, help articles, shared drives, or data in your own software. Each source needs an owner who keeps it current.

  • Ingestion

    The step that reads each source, pulls out the text, and splits it into passages, often called chunks. Scanned files, tables, and images need extra work here, because a passage that loses its heading or table structure can lose its meaning.

  • Search index

    Where the passages are stored so they can be found. Meaning-based search, often called vector search, finds passages that say the same thing in different words. Keyword search is still useful for exact matches such as part numbers, policy codes, and names, and many systems use both.

  • Permission filter

    The rule that limits search to passages the person asking is allowed to see. This has to happen before the model sees anything, not by asking the model to keep secrets.

  • Answer step

    The instructions that tell the model to answer only from the passages found, to show where each answer came from, and to say plainly when the documents do not contain an answer.

  • Logging and review

    A record of questions, the passages found, and the answers given, so someone can spot wrong answers, missing documents, and questions the chatbot should hand to a person.

Where it goes wrong

Confident wrong answers. Anthropic's documentation for its Claude models recommends letting the model say it does not know, asking it to quote the source text it relied on, and telling it to use only the documents provided. The same page says these techniques reduce made-up answers but do not eliminate them, and advises validating critical information. The OWASP guide lists misinformation as one of its ten risks and gives the example of an airline whose chatbot gave travellers wrong information, after which the airline was successfully sued.

Old or conflicting documents. If last year's price list and this year's both sit in the index, search may find either. The OWASP guide notes that errors can occur when data from several sources contradicts itself. A RAG chatbot reflects the state of your documents, so tidying them is part of the work, not a separate project.

Answers drawn from documents the person should not see. The OWASP guide describes data leaking between groups of users who share the same store of documents, and recommends permission-aware stores with strict separation between groups. If HR policies, board papers, and customer contracts are all indexed together, the permission filter is what stops a sales assistant from asking about salaries.

Instructions hidden inside documents. The OWASP guide calls this indirect prompt injection: text inside a file or web page that the model reads as an instruction. One of its examples is a document in a repository being changed so that answers drawn from it become misleading. Any chatbot that reads documents from outside your control, such as supplier files or customer uploads, needs to treat that text as content, not as commands, and should not be able to take actions on the strength of it alone.

Packaged assistant or custom-built chatbot.

Some office suites and workplace tools include an AI assistant that can answer from files you already store with them. Go through each row and note which column describes your situation. If most of your answers fall in the first column, start with the packaged tool.

FactorA packaged assistant is likely enough whenA custom build earns its place when
Who asksYour own team asks questions about files they can already openCustomers, partners, or field staff ask, often inside your website, portal, or app
Where the answers liveDocuments already sit in the suite the assistant belongs toAnswers depend on several systems, or on records in your own software
Who may see whatThe tool's existing file sharing settings match who should see whatAccess depends on rules such as customer account, branch, role, or contract
How answers are shownA general chat window is fineAnswers must show the source, follow a set format, or hand over to a person
Checking and recordsOccasional spot checks are enoughYou need a log of questions and answers, a test set, and a review process
What happens nextThe answer is the end of the taskThe answer should start a next step, such as a ticket, a form, or a task for someone
Volume and wordingA small group asks varied questionsMany people ask similar questions, and wording and tone need to match your business

When not to build one

If people ask the same few questions, a clear help page or a well-organised FAQ may serve them better than a chatbot, and it is easier to keep accurate. If the answer is a simple lookup, such as an order status, a search box or a status page is more reliable than generating text.

If the documents are out of date, contradictory, or held in people's heads, fix that first. A chatbot will repeat whatever the documents say, and it will be blamed for answers that are really document problems.

If a wrong answer could cause real harm, such as legal, medical, safety, or financial advice given directly to customers, think carefully before letting a chatbot answer without a person checking. A draft answer for a member of staff to review can be a safer first step.

A scoping checklist before you build.

Work through these steps with the people who will use the chatbot and the people who own the documents. The answers make a usable brief, whoever builds it, and they will also tell you whether a packaged tool is enough.

  1. 1

    Collect real questions

    Gather questions people already ask, from emails, chat logs, support tickets, and the colleagues who answer them. Note who asked and what a good answer looked like.

  2. 2

    List the sources and owners

    For each question, note which document or system holds the answer, its format, how often it changes, and who keeps it current. Mark any question with no written answer.

  3. 3

    Map who may see what

    Write down which groups may see which sources, and whether the rules depend on role, branch, customer account, or contract. This becomes the permission filter.

  4. 4

    Decide what it must not answer

    List topics the chatbot should refuse or pass to a person, and agree what it says when the documents do not hold an answer.

  5. 5

    Agree how answers are shown

    Decide whether each answer links to its source, quotes the passage, or names the document and section, so people can check it.

  6. 6

    Build a test set

    Turn a sample of the real questions into a test set with the correct answer and source for each, including questions that should be refused. Agree what result is good enough to launch.

  7. 7

    Decide where it lives

    Choose whether it sits in a packaged tool, an internal web app, a customer portal, or a mobile app, and what happens when it hands over to a person.

  8. 8

    Plan the upkeep

    Agree who reviews the logs, who updates documents when answers are wrong, and how new or changed documents reach the index.

How we would approach it

We would start with the questions and the documents, not the technology. Working through the checklist above tells us whether a custom build is needed at all. If a packaged assistant or a simple rule would do the job more reliably, we would say so.

If a custom build makes sense, we would begin with one group of users and one set of sources, build the test set first, and design the answer step so the chatbot shows where each answer came from and says plainly when it cannot find one. We would agree which data the chatbot may use and who can see it before building, and apply those rules at the search step. We build with large language model APIs, retrieval from your own content, and vector search, and we would test answers against the test set before widening access.

On cost and duration, the honest answer is that it depends on scope. The main drivers are the number and format of sources, how much cleaning the documents need, how complex the permission rules are, how many languages it must handle, where it lives, such as an internal tool, a portal, or an app, how much logging and review you need, and how many people will use it, since model usage is an ongoing running cost.

Common questions

Is a RAG chatbot the same as training a model on our data?

No. With RAG, the model is not retrained on your documents. The system searches your documents each time someone asks a question and gives the model the passages it found. When a document changes and is re-indexed, answers can change with it.

Can a RAG chatbot stop making things up?

It can reduce made-up answers, but not remove them. Anthropic's documentation for its Claude models says techniques such as allowing the model to say it does not know and asking it to cite its sources reduce made-up answers without eliminating them. Showing sources and testing against real questions help people catch the rest.

Can different staff see different answers?

Yes, if access rules are applied when the system searches, so each person only gets passages from sources they are allowed to see. The OWASP Top 10 for LLM Applications recommends permission-aware stores for this reason. Asking the model to keep information private is not a substitute.

Should we use a packaged assistant instead?

Often, yes, if your own team is asking about files already stored in the tool the assistant belongs to, and its sharing settings match who should see what. Use the decision table above. A custom build earns its place when customers ask, answers span several systems, or access rules are more detailed.

Let's talk about what you want to build.

Walk us through your idea or what is not working today. You leave the call with a recommended first step.