How a RAG chatbot answers from your company’s knowledge

A RAG chatbot answers questions from your own documents instead of the model’s memory. How it works, why it still gets things wrong, what it costs per question, and when you should buy instead of build.

Wojciech Filipek
·
·
26 Nov 2026
Share

Photo: Valeria Nikitina / Unsplash+

In this article

Key takeaways

  • A RAG chatbot looks up relevant passages in your documents and asks a language model to answer from them. The model’s own memory plays a smaller part, which makes answers more current and easier to check.
  • Most of the quality comes from the retrieval step: how documents are split, indexed and searched. Anthropic reported that better retrieval cut failed retrievals by 49%, and by 67% with reranking.
  • Running costs are low. In our example, 3,000 questions a month cost about $42 in model fees, and indexing 10,000 pages of documents costs well under a dollar.
  • The risks are wrong answers stated with confidence, and prompt injection from documents or users. A Canadian tribunal held an airline responsible for what its chatbot told a customer.
  • For a team asking questions about shared files, a ready-made tool is often enough. Build when the assistant must respect permissions, connect to your systems or answer customers.

A RAG chatbot is an AI assistant that answers questions using your company’s own documents. RAG stands for retrieval-augmented generation: before the language model writes an answer, the system retrieves the most relevant passages from your knowledge base and puts them in front of the model. The answer is generated from those passages, ideally with links to where they came from.

The idea comes from a 2020 research paper by Lewis and colleagues, which combined a model’s built-in “parametric” memory with an explicit, searchable store of documents. The authors noted that models alone struggle to update their knowledge or show where an answer came from. Retrieval addresses both.

We build integrations and custom systems, and an AI assistant on company data is, underneath, an integration project: documents from several systems, permissions, search, and a model behind an API. This guide explains how it works, where it fails, what it costs, and when a ready-made tool is the better choice.

What a RAG chatbot does, step by step

There are two phases: preparing the knowledge and answering a question.

Preparation happens ahead of time. Documents are collected from wherever they live: a shared drive, a wiki, a help centre, PDFs of contracts, product data. Each document is split into chunks of a few hundred words. Each chunk is turned into an embedding, a list of numbers that captures its meaning, and stored in a vector index. Many teams keep this index in a database they already run; the open-source pgvector extension adds vector similarity search to PostgreSQL. Scanned PDFs need OCR first, which our guide to AI document processing explains.

Answering happens when someone asks something. The question is turned into an embedding too, and the index returns the chunks closest in meaning, often combined with a classic keyword search. The system then sends the model a prompt that contains the question, the retrieved chunks and instructions such as “answer only from these sources and cite them”. The model writes the answer, and the interface shows it with links to the source documents.

A plain chatbot answers from what the model learned in training, which is general, possibly outdated, and knows nothing about your price list or your returns policy. A RAG chatbot answers from what you gave it, and you can update that knowledge by updating the documents.

Retrieval decides the quality

When a RAG system gives a bad answer, the model is often not the problem. The right passage simply never reached it. Good retrieval is most of the work.

Anthropic’s write-up on contextual retrieval shows how much this matters. Adding a short context to each chunk before indexing, and combining embeddings with keyword search (BM25), reduced the top-20 retrieval failure rate from 5.7% to 2.9%, a 49% improvement. Adding a reranking step brought the reduction to 67%.

Practical decisions that affect retrieval:

  • How documents are split. A chunk that cuts a table in half or separates a rule from its exception will mislead the model. Splitting along headings and sections usually works better than fixed lengths.
  • Metadata. Store the document title, section, date, product and audience with each chunk, so the system can filter by them and the answer can say which version it used.
  • Hybrid search. Embeddings find meaning; keyword search finds exact terms like product codes, contract numbers and names. Most production systems need both.
  • Freshness. When a document changes, its chunks must be re-indexed, and old versions removed. An assistant that quotes last year’s price list is worse than none.
  • Duplicates and contradictions. If three versions of the same policy exist on the drive, the assistant will find all three. Cleaning the source is part of the project.

None of this is exotic. It’s the same discipline as any data integration: know where data comes from, keep it current, and decide which version wins.

Where RAG chatbots go wrong

Language models are fluent even when they’re wrong, and that’s the central risk.

Confident wrong answers

Retrieval reduces made-up answers but doesn’t remove them. If the passages are incomplete, the model may fill gaps with something plausible. The consequences can be real. In 2024, British Columbia’s Civil Resolution Tribunal ordered Air Canada to pay a customer after its website chatbot gave wrong information about bereavement fares. The airline argued the chatbot was responsible for its own actions; the tribunal member called that “a remarkable submission” and found the airline responsible for all the information on its website, whether it came from a static page or a chatbot. The award was $812.

The defences are design choices. Tell the model to answer only from the provided sources and to say when it doesn’t know. Show sources with every answer so people can check. For customer-facing assistants, keep high-stakes topics such as prices, refunds, legal terms and medical advice either out of scope or answered with links to the authoritative page.

Prompt injection

OWASP lists prompt injection as the first risk in its Top 10 for LLM applications. Users can type instructions that try to override the system’s rules. More subtle are indirect injections, where the instructions hide in content the system retrieves, such as a web page, an email or an uploaded file. A RAG chatbot reads documents by design, so it is exposed to this.

The mitigations: treat retrieved content as data, not instructions; don’t give the assistant tools that can change data or send messages unless a person confirms; limit what each user’s assistant can retrieve; and log questions and answers so problems can be found.

Permissions

An internal assistant that can read everything will happily answer a junior employee’s question with a passage from the board minutes. If documents have different audiences, the index must store who may see each chunk, and retrieval must filter by the person asking. This is where many quick prototypes fail when they meet a real organisation.

Data protection

Sending company documents to a model provider is a data processing question. Check the provider’s terms. OpenAI, for example, states that it does not train its models on business data by default for its business products and API. Personal data in the knowledge base also falls under the GDPR, so the usual rules apply: purpose, minimisation, a data processing agreement and a decision on where data is stored.

What it costs to run

Model prices fall quickly, so here are list prices checked in November 2026, with assumptions in the open.

Take a company with 10,000 pages of documents, around 8 million tokens at roughly 800 tokens per page. Assume 3,000 questions a month. Each question sends about 5,000 tokens to the model, the question plus eight retrieved chunks and instructions, and gets about 400 tokens back.

ItemPrice usedMonthly cost
Indexing 8 million tokens onceOpenAI text-embedding-3-small, about 62,500 pages per dollarabout $0.16 one-off
Answers with a mid-range modelClaude Sonnet 5.5 at $2 per million input and $10 per million output tokens3,000 × (5,000 × $2 + 400 × $10) / 1M = $42
Answers with a small modelClaude Haiku 5.5 at $0.10 input and $0.50 outputabout $2
Vector indexpgvector in an existing PostgreSQL databaseno separate fee

Embedding prices come from OpenAI’s embeddings guide, and model prices from Anthropic’s pricing page. OpenAI’s current pricing lists GPT-6.2 Sol at the same $2 and $10 per million tokens. If you use a hosted retrieval tool instead of your own index, OpenAI’s file search, for example, adds $0.10 per GB of storage per day after the first free gigabyte and $2.50 per thousand tool calls.

The model is the cheap part. The cost of a RAG chatbot is in building it properly: connecting the sources, cleaning and splitting documents, permissions, the interface, logging and testing, and keeping it running. That’s a software project, and our custom software cost guide explains how such projects are priced.

Buy or build

Several products now let a team upload documents or connect a drive and ask questions about them. For many internal uses that’s the right start, and it’s cheaper than any custom build.

A ready-made tool is usually enough when:

  • the users are your own team, asking questions about shared documents;
  • everyone may see everything in the connected sources;
  • answers don’t need to trigger actions in other systems;
  • the tool connects to where your documents already are.

Build your own when:

  • the assistant answers customers on your website or in your product, under your brand and responsibility;
  • documents have different audiences and permissions must be enforced;
  • answers need live data from your systems, such as order status, stock or contract terms, through APIs;
  • you need control over which model is used, where data is processed and how answers are logged;
  • the assistant is part of a workflow, for example drafting a reply that a person approves before sending.

Our post on build vs buy covers that decision in general.

A sensible first project

Start small and measurable. Pick one group of users and one body of knowledge: support agents and the help centre, sales and the product documentation, new employees and the internal handbook.

Before building anything, collect fifty real questions those people asked recently, with the correct answers. They become your test set. Every change to chunking, search or prompts should be checked against it, and the share of correct answers with correct sources is the number to watch.

Then build the simplest version that answers those questions with sources, put it in front of a few users, and read the logs every week. Questions it can’t answer show missing documents. Wrong answers show retrieval problems. Questions nobody asks show what to drop.

From there, add sources, permissions and integrations one at a time. If the assistant needs to read order data or create tickets, that’s an integration like any other, and the same rules apply as in our guide to API integration services: one owner per data field, logs for every call, and a person in the loop for anything that changes data.

How to measure answer quality

“It seems to work” is how most assistants are judged, and it’s how most of them disappoint three months later. Measure from the start, with the same test set every time.

For each question in the set, check three things separately:

CheckQuestion to askWhat a failure means
RetrievalWas the passage with the correct answer among the retrieved chunks?Fix splitting, metadata or search, not the prompt.
FaithfulnessDoes the answer say only what the retrieved passages say?The model added something. Tighten instructions or use a stronger model.
CorrectnessIs the answer right and complete for the person asking?Either of the above, or the source document itself is wrong.

Separating them tells you where to work. A team that only measures the final answer tends to rewrite prompts for weeks while the real problem is a PDF that was split badly.

Add questions the assistant should refuse or redirect: topics outside its scope, questions about documents the user may not see, and attempts to make it ignore its rules. A good assistant says “I don’t know” or “please contact us” for those, and the test set proves it does.

Keep measuring after launch. Let users mark answers as helpful or not, read the low-rated ones every week, and add them to the test set with the right answer. Re-run the set whenever you change the model, the prompt or the document sources. Providers update models regularly, and an assistant that was right last month can drift.

Choices that shape the architecture

A few decisions early on save rework later.

Model choice. Use a capable mid-range model for answers and a small, cheap one for routing and simple tasks, such as deciding whether a question is in scope. At the prices above, the difference between them is a few dozen dollars a month for most companies, so quality should decide, not cost. Keep the model behind one function in your code, so you can switch providers without rebuilding.

Where data lives. Your documents, index and logs can stay in your own infrastructure; only the question and retrieved passages need to go to the model. Several providers offer processing in specific regions, including the EU, through their own platforms or through the big cloud providers. Decide this with whoever is responsible for data protection before the first document is indexed.

Hosted or own retrieval. Hosted file search tools are the fastest start and fine for a pilot. Your own index gives you control over splitting, metadata, permissions and hybrid search, which most production systems need eventually. Starting hosted and moving later is a reasonable path if the test set travels with you.

Logging. Store every question, the retrieved chunks, the answer and the user’s rating. That log is how you debug, measure and prove what the assistant said if a customer disputes it. Treat it as personal data where it contains any.

Lessons from integration work that apply here

We haven’t seen a document-based assistant fail for reasons that are new. The failures look like integration failures.

When we connected an online shop to an accounting system, the hardest part wasn’t the API. It was thousands of old orders still marked as “processing” years after they were invoiced, which would have been exported as new. We set a cut-off date and cleaned the history before switching anything on. A knowledge base has the same problem with outdated documents: if old policies sit next to new ones, the assistant will cite them.

On a booking platform we built, prices are shown from a local copy for speed, but the final price is always confirmed with the supplier’s system before payment. A RAG assistant should follow the same rule for anything that matters: answer from the index, but check live data for prices, stock or status before stating them.

When not to build a chatbot

Don’t build an assistant to fix documentation nobody maintains. It will repeat the gaps and contradictions faster. If the answers people need fit on a few well-written pages, a good FAQ and search are cheaper and more reliable. If the questions are really requests, such as changing an order or booking a date, a form or a workflow serves people better than a conversation. And if a wrong answer could cause legal or financial harm, keep a person in the loop or keep that topic out of scope.

If you have a body of knowledge people keep asking about, and the questions and sources are clear, a RAG assistant can save real time. We build them as part of our integration and automation work and custom software, and we’re happy to look at your use case and say whether a ready-made tool would do.

Frequently
asked questions

It’s an AI assistant that retrieves relevant passages from your own documents and asks a language model to answer from them. RAG stands for retrieval-augmented generation. It makes answers more current and lets users see the sources.

A general chatbot answers from what its model learned in training. A RAG chatbot searches your documents first and answers from what it finds, so it can use your policies, products and data, and show where each answer came from.

Model fees are usually small. In our example, 3,000 questions a month cost about $42 with a mid-range model and about $2 with a small one, at November 2026 list prices. Building, integrating and maintaining the system costs far more than running it.

Yes. If retrieval misses the right passage or the sources are outdated, the model can answer wrongly with confidence. Show sources, tell the model to admit when it doesn’t know, test against real questions and keep high-stakes topics with a person.

It can be, with the right setup. Check the provider’s data terms, sign a data processing agreement, limit what each user can retrieve, and treat personal data under the GDPR. Prompt injection is a separate risk that needs design measures.