The model gets all the attention, but the single biggest lever on a support chatbot’s answer quality is the thing sitting behind it: the knowledge base for your chatbot. Two teams can deploy the exact same GPT-class model and get wildly different results — one bot cites the right refund policy in a sentence, the other confidently invents a policy that was never real. The difference is never the model. It is what you fed it and how you structured it. AI Chat Agent is a self-hosted chatbot built around retrieval-augmented generation (RAG), and after watching a lot of deployments succeed and fail, the pattern is consistent: the knowledge base makes or breaks the bot.

This guide is the content side of the problem — what to put in the knowledge base, how to structure it so retrieval works, and how the chatbot actually consumes it. If you want the infrastructure walk-through instead (pgvector, Docker, embeddings setup), the RAG knowledge base setup guide covers standing up the system; this piece assumes that exists and focuses on filling it well. There are also adjacent deep dives across the blog index on multi-LLM routing and deployment, plus a script library for what to say when the bot doesn’t know and a look at where self-service portals break down when the same content is buried behind a login. Get the knowledge base right and everything downstream — deflection, CSAT, trust — follows.

What a Chatbot Knowledge Base Actually Is

A chatbot knowledge base is not a folder of PDFs the bot “reads.” It is a searchable index of your content, split into small pieces and stored as vectors so the bot can find the handful of passages relevant to each question and answer from them. The technique is retrieval-augmented generation: retrieve first, then generate an answer grounded in what was retrieved. Without it, the model answers from its training data — which knows nothing about your pricing, your policies, or your product.

That distinction matters because it changes what “good content” means. You are not writing for a human reader who scrolls top to bottom. You are writing for a retrieval system that will pull one 500-character chunk out of context and hand it to a model as the entire basis for an answer. A paragraph that only makes sense after three pages of build-up is useless to that system. A self-contained paragraph that states its point directly is gold. Keep that reader — the retriever — in mind for every decision below.

From Documents to Grounded AnswerYour docsmarkdown · URLsChunkheading-awareEmbedvectorsStorepgvectorVisitor question”what’s your refund window?”Retrieve chunkshybrid + rerankGrounded answercites your source
Ingestion happens once; retrieval happens on every message. Both depend on how the content is written.

Step 1: Decide What Belongs (and What Doesn’t)

The instinct is to feed the bot everything — the whole website, every PDF, all the docs. Resist it. A bloated knowledge base is worse than a focused one, because retrieval has to discriminate between many near-identical chunks and will sometimes surface the wrong one. Start from the questions, not the documents. Pull your last few hundred support tickets or live-chat logs and cluster them: onboarding, billing, refunds, integrations, troubleshooting. Those clusters are your knowledge base’s table of contents.

Include the content that answers those questions directly: setup and how-to guides, pricing and plan rules, refund/shipping/warranty policies, troubleshooting steps, and factual product specifications. Deliberately leave out marketing landing pages (they answer nothing and dilute retrieval), duplicated or superseded versions of the same doc, internal-only notes, and anything time-sensitive you can’t commit to maintaining. If a page exists to persuade rather than to inform, it does not belong in a knowledge base. A tight, curated set of 30–60 clean documents almost always beats an indiscriminate dump of 500.

Curated Beats ComprehensiveINCLUDE✓ Setup & onboarding guides✓ Pricing, billing, plan rules✓ Refund / shipping / warranty✓ Troubleshooting steps✓ Product specs & limits✓ Real FAQ answersFewer, cleaner chunks → sharper retrievalLEAVE OUT✗ Marketing landing pages✗ Duplicate / superseded docs✗ Stale, unmaintained content✗ Internal-only notes✗ Legal boilerplate walls✗ “Everything, just in case”More near-duplicates → confused retrieval
Every irrelevant document you add is a chunk that can be retrieved instead of the right one.

Step 2: Structure Content So Retrieval Can Find It

Once you know what goes in, write it for the retriever. The highest-leverage format is markdown with a disciplined heading hierarchy: one topic per section, descriptive H2 and H3 titles, and short paragraphs that each make a single self-contained point. This is not a style preference — it maps directly to how the content gets chunked. AI Chat Agent uses markdown-aware chunking that splits on headings and merges sections that are too small, so a document with clear headings produces clean, topically coherent chunks. A wall of text with no structure gets sliced at arbitrary character boundaries, and you get chunks that start mid-thought.

Three concrete rules pay off immediately. First, front-load the answer: put the conclusion in the first sentence of a section, then elaborate — retrieval favors passages that state their point. Second, keep code blocks and tables intact by using proper markdown fences and pipe tables; the chunker treats fenced code and tables as atomic and never cuts them mid-fence or mid-row, so a correctly formatted config snippet survives as one retrievable unit. Third, add a title and canonical URL in each document’s YAML frontmatter — the ingester extracts it and prefixes every chunk with that source metadata, which is what lets the bot attribute an answer to a specific page. Descriptive headings do double duty here: the chunker prepends a heading breadcrumb like [# Billing > ## Refunds > ### Timeline] to each chunk, giving the model semantic context even when it only sees one fragment.

Step 3: Understand Chunking and Embeddings

Chunking is the step that turns your documents into retrievable units, and it is where most “why is my bot dumb?” problems originate. If chunks are too large, a single chunk covers several topics and dilutes the vector so it matches nothing well. If they are too small, an answer gets split across chunks and the model only sees half of it. Heading-aware chunking sidesteps both by cutting on natural topic boundaries instead of a fixed character count. Your job is to give it good boundaries — which is exactly what disciplined headings do.

Each chunk is then converted to an embedding — a vector that captures its meaning — by the same provider you use for chat, so OpenAI, Anthropic, Google Gemini, OpenRouter, or any OpenAI-compatible endpoint all work without a separate service. This is where multi-provider flexibility matters: your knowledge base is not welded to one vendor’s embeddings, and the multi-LLM chatbot approach means you can switch models later without re-architecting. One nuance worth knowing: language affects chunk sizing. The ingester detects when text is heavily Cyrillic or CJK and shrinks the chunk size accordingly (those scripts pack more meaning per character), so a Russian or Japanese knowledge base gets precise chunks instead of oversized ones — one of several things that separate a working multilingual chatbot from a translated widget. You don’t configure any of this — but knowing it explains why clean, well-delimited source text produces better retrieval.

Heading-Aware Chunking# Billing## Refund policyRefunds within 30 days…## Billing cycleCharged monthly on…yaml (atomic)| Plan | Price |table kept wholeOne markdown doc[# Billing > ## Refund policy]Refunds within 30 days of purchase…[# Billing > ## Billing cycle]Charged monthly on the signup date…[meta: url=“/billing”] · atomic table| Plan | Price | … kept as one unitClean, source-attributed chunks
Good headings in, coherent chunks out. The structure you write is the structure retrieval gets.

Step 4: How Retrieval Finds the Right Answer

When a visitor asks a question, a modern RAG chatbot does more than a single vector lookup. AI Chat Agent runs a pipeline: it first rewrites the message into a standalone search query using the conversation history (so “and what about mine?” becomes “what is the refund window for the Pro plan?”), then runs hybrid retrieval — a dense vector search for meaning and a lexical full-text search for exact terms, fused together with Reciprocal Rank Fusion. Hybrid matters because vector search alone misses exact strings: SKUs, error codes, plan names, proper nouns. The lexical arm catches those; the dense arm catches paraphrases. Together they cover far more question shapes than either alone.

The wide candidate pool is then reranked by the bot’s own LLM, which keeps only the genuinely relevant chunks, and each survivor is expanded with its immediate neighbors — the chunk before and after it from the same source — so the model sees coherent context instead of an isolated fragment. This is why your document order and section boundaries matter: neighbor expansion assumes adjacent chunks belong together. If you understand this pipeline, you understand why structure is worth the effort. For the full engineering detail on how these stages fit together, the advanced chatbot features guide breaks down hybrid RAG, reranking, and query rewriting stage by stage.

Hybrid Retrieval: Meaning + Exact TermsRewrittenqueryDense searchvectors · meaningLexical searchkeywords · SKUsRRF fusionone ranked listLLM rerankfinal chunks
The dense arm catches paraphrases; the lexical arm catches exact strings. Fusing them covers question shapes neither handles alone.

Step 5: Ingest — Upload or Crawl, and Handle Failures

With content structured, ingestion is the easy part. AI Chat Agent gives you two paths: upload markdown and text files directly, or point the crawler at your existing help-center or docs URLs and let it pull the pages. The crawler is SSRF-hardened — it refuses localhost, private-network, and cloud-metadata addresses — because “just paste a URL” ingestion is one of the most common security holes in chatbot builders. When you crawl a site, each page is chunked independently and tagged with its own source URL, so a retrieved answer can point back to the exact page it came from rather than a vague blob of “the website.”

Ingestion at scale is where naive tools fall over, so a couple of production details are worth knowing. Bulk uploads run sequentially with automatic retry and backoff, so a rate-limit blip partway through a 200-file batch doesn’t silently drop the tail. Embedding calls that fail transiently — a provider returning a malformed body, a network hiccup — are retried rather than left in a broken state, and any source that still ends in an error gets a per-row Retry button in the admin so you re-queue it without re-uploading everything. The sources list shows a chunk count per document, which is your first sanity check: a 40-page manual that produced three chunks means the upload or parsing went wrong. Because it is self-hosted with Docker, all of this — your documents, the embeddings, the vectors — stays on infrastructure you control.

Step 6: Grounding — Teach the Bot to Say “I Don’t Know”

A knowledge base is only trustworthy if the bot refuses to answer when the base doesn’t cover the question. This is the difference between a helpful assistant and a liability. Older RAG setups used a fixed cosine-similarity threshold — if the best match scored below 0.25, discard it — but a static number is brittle: it rejects good matches in one corpus and admits garbage in another. AI Chat Agent replaced that threshold with an LLM relevance gate. The reranker can return a “none relevant” verdict, and when it does, the bot routes to a no-match response: it declines to answer from general knowledge and offers a human handoff instead of confabulating.

The grounding prompt does the other half of the job. It frames the retrieved passages as “excerpts relevant to this question, not the complete knowledge base,” which stops a specific and embarrassing failure mode — the bot speculating about its own contents (“the knowledge base only has three articles” or “lesson two isn’t loaded”). It also formats context as clearly labeled source blocks so the model attributes claims correctly. The practical takeaway for you as the knowledge base author: if the bot is refusing questions it should answer, the fix is almost always a content gap, not a settings problem. Add the missing document and the gate opens.

The Relevance GateQuestionrewrite + retrieveLLM rerankrelevant chunks?Answer from your KBgrounded · cites sourceDecline + offer handoffno guessingyesnone relevant
A bot that declines gracefully is worth more than one that answers confidently and wrong.

Multilingual and Non-English Knowledge Bases

If you serve customers in more than one language, you do not need a separate bot per language. A single knowledge base can hold content in several languages, because retrieval matches on meaning rather than exact wording, and embeddings are multilingual by nature. The ingester adapts chunk sizing to the script — smaller chunks for dense Cyrillic or CJK text — and the query-rewrite step preserves the visitor’s language, so a question in German retrieves the German passages and the model replies in German. The widget chrome itself ships English and Russian and auto-detects the page’s language, with a manual override for hosts that need it.

The practical advice is to keep each document in one language and label it clearly rather than interleaving translations in the same file. That keeps chunks linguistically clean and avoids a chunk that is half English, half French — which embeds into a muddle that matches neither well. If a market is important, write native content for it instead of relying on machine translation of your English docs; retrieval quality tracks the quality of the source text.

Measure and Maintain Knowledge Base Quality

A knowledge base is not a one-time upload; it is a living asset that decays as your product changes. Build a simple maintenance loop. Start by reading transcripts: the questions where the bot declined or gave a weak answer are a direct, prioritized list of content gaps — each one is a document you haven’t written yet. Watching the no-match responses is the single most useful signal you have, because it tells you exactly what your customers ask that your knowledge base doesn’t cover.

On a cadence — monthly is reasonable for most teams — reconcile the knowledge base against product reality: retire docs for removed features, update pricing and policy pages the moment they change, and re-crawl help-center URLs so edits propagate. Treat the knowledge base like code: when a policy changes, updating the source document is part of shipping the change, not an afterthought. The teams whose bots stay accurate a year in are the ones who made knowledge base upkeep somebody’s explicit responsibility. If you want a wider tour of what a mature deployment looks like beyond content, the chatbot ideas guide has adjacent build patterns worth borrowing.

Common Knowledge Base Mistakes (and Fixes)

Most failing knowledge bases fail the same handful of ways. Dumping unstructured PDFs is the top offender: exported PDFs lose heading structure and chunk into noise — convert the content to clean markdown first. Including marketing pages pads the index with chunks that answer nothing and outrank real answers on fuzzy queries. Contradictory duplicates — two docs stating different refund windows because one is stale — make the bot cite whichever the retriever happened to rank first; keep exactly one source of truth per fact. Burying the answer under three paragraphs of preamble means the retrieved chunk starts with preamble and the model never reaches the point.

The meta-fix behind all of these is to treat the knowledge base as a product you curate, not a bucket you fill. Compared with SaaS chatbot builders like Chatbase or Intercom, a self-hosted stack gives you full control over the ingestion pipeline and keeps your entire corpus — and your customers’ questions — on infrastructure you own, which for regulated or privacy-sensitive teams is the whole ballgame. But the discipline is the same on any platform: fewer, cleaner, better-structured documents beat a bigger pile every time.

Build Your Knowledge Base the Right Way

A great chatbot is a well-curated knowledge base with a competent model attached — in that order. Start from real questions, keep the content tight and current, write it in structured markdown so chunking produces coherent pieces, and let a grounded retrieval pipeline with a relevance gate handle the rest. Do that and you get a bot that answers correctly, cites its sources, and admits what it doesn’t know — the three things that actually earn a customer’s trust.

You can see the whole pipeline running on the live demo — upload a few markdown docs and watch how structure changes the answers. When you’re ready to run it on your own infrastructure, AI Chat Agent is a €79 one-time license: full source code, all five LLM providers, the complete RAG ingestion and retrieval pipeline described here, and no monthly bill. If you’re still weighing hosting models, the self-hosted vs SaaS breakdown covers the trade-offs — but either way, the knowledge base discipline above is what makes the bot worth deploying.

Frequently Asked Questions

How do I create a knowledge base for a chatbot?

Gather the content that answers real customer questions — help-center articles, product docs, policies, FAQs — clean it up, structure it with clear markdown headings, then ingest it into a retrieval-augmented (RAG) chatbot by uploading the files or crawling the URLs. The chatbot splits each document into chunks, embeds them as vectors, and retrieves the most relevant pieces at answer time. The quality of the answers is decided almost entirely by the quality and structure of what you put in, not by the model.

What should I put in a chatbot knowledge base?

Content that answers questions a visitor would actually ask: setup and onboarding guides, pricing and billing rules, refund and shipping policies, troubleshooting steps, and product specifications. Leave out marketing fluff, duplicated pages, outdated versions, and internal notes. A focused 40-page knowledge base of clean answers outperforms a 400-page dump of everything, because retrieval has fewer near-duplicate chunks to confuse it.

How should I format documents for a chatbot knowledge base?

Use markdown with a clear heading hierarchy — one topic per section, descriptive H2/H3 titles, and short self-contained paragraphs. Markdown-aware chunking splits on headings and keeps code blocks and tables intact, so well-structured docs produce clean, coherent chunks. Add a title and URL in the frontmatter so each chunk carries a source attribution the bot can cite.

How does a chatbot use its knowledge base to answer a question?

At answer time the chatbot rewrites the question into a standalone search query, runs hybrid retrieval (a dense vector search plus a lexical keyword search fused together), reranks the candidates with an LLM to keep only the relevant ones, expands each with its neighboring chunks for context, and passes that grounded context to the model. If nothing relevant is found, it declines to answer instead of guessing.

Can a chatbot knowledge base work in multiple languages?

Yes. Modern RAG chatbots detect the language of each document and adjust chunk sizing so non-Latin scripts like Cyrillic or CJK are chunked precisely, and the query-rewrite step preserves the visitor’s language. You can store content in several languages in one knowledge base; retrieval matches on meaning, and the model answers in the language the visitor used.

How do I stop my chatbot from making things up?

Ground it in a knowledge base and add a relevance gate. AI Chat Agent reranks retrieved chunks with the bot’s own model and, when none are relevant, routes to a no-match response that declines to answer from general knowledge and offers a human handoff. The grounding prompt also tells the model the retrieved excerpts are not the complete library, which stops it from inventing claims about what the knowledge base does or doesn’t contain.