AI Chatbot With Knowledge Base: How to Build One

Upload your docs. The AI answers questions grounded in your content, with citations. Skip Intercom Fin's $0.99 per resolution.

100 free credits on signup. No credit card needed.

$940
Saved per 1,000 chats vs Intercom Fin
2h
Chat, document search and uploads set up
100%
Citations on every answer
0
Vendor model lock-in (swap providers)

Guide

How an AI chatbot with a knowledge base works, and how to build one.

A knowledge-base chatbot is a chat interface whose answers come from your documents, not from whatever the model remembers from training. This is what it is, how the parts fit together, how to build one in five steps, and where the real costs and common problems are.

What an AI chatbot with a knowledge base is

Three things get called "chatbot" and they behave very differently:

  • Scripted bots follow a decision tree. If the user's question isn't on the tree, they fail.
  • Plain AI chat (ChatGPT dropped onto a page) answers anything, but from what it learned in training. It doesn't know your refund policy, your product details, or last week's release notes, and it will guess.
  • A knowledge-base chatbot sits in between: an AI model writes the answer, but only after the system finds the relevant passages from your content and puts them in front of the model. When the passages don't exist, a well-built bot says so instead of inventing one.

The technique is called retrieval-augmented generation (RAG). In plain terms: look up the right passages, then have the AI answer from them. It is the standard approach behind Intercom Fin, Zendesk AI agents, Chatbase, and most "train a bot on your docs" products. None of them retrain a model on your data; they look up passages and hand them to the AI.

How it works, step by step

There are two parts: one that runs when your documents change, one that runs on every question.

Preparing your documents (runs when docs change)

  1. Collect sources. Help-center articles, PDFs, product docs, a crawled marketing site, Notion pages, policy documents.
  2. Split. Each document is split into passages of a few paragraphs (roughly 300–800 tokens) with some overlap, so what a single answer needs fits in one passage. Splitting on headings works better than splitting at a fixed length.
  3. Index. Each passage is turned into a list of numbers that captures its meaning, called an embedding. Passages that mean similar things end up with similar numbers.
  4. Store. Those numbers, the original text and details like the source link, title and last-updated date go into a search index: one inside your own database, or a hosted search service like Pinecone.

Answering (runs per question)

  1. Index the question the same way.
  2. Find the 3–8 passages closest in meaning. Many systems also run a plain keyword search and combine the results, which helps with product names and error codes.
  3. Brief the AI: instructions ("answer only from these passages; if they don't cover it, say you don't know"), the passages found, the conversation so far, the question.
  4. Write the answer, showing it as it is written, and attach citations back to the passages used.
  5. Log the question, the passages found, and the answer. This log is how you find gaps in your docs later.

How to build one in five steps

  1. Pick the sources and decide the boundary. Start with the content that already answers most support questions, usually a help center and product docs. Leave out anything you wouldn't want quoted verbatim to a customer.
  2. Choose the three pieces. An AI model to write answers (Claude, GPT, or an open model you run yourself), an indexing model (OpenAI, Cohere, or one you run yourself), and a search index (one inside your own database is enough for well under a million passages). Keep them swappable; prices and quality shift every few months.
  3. Build the document upload. An admin page to upload files and paste links, a background job that reads, splits and indexes them, and an update step that only re-indexes documents whose content actually changed.
  4. Build the chat screen. Replies that appear as they are written, clean formatting, a "Sources" block under every answer, per-user conversation history, and a short snippet to paste so the same bot can live on your site or inside your app.
  5. Add guardrails and measurement. A refusal path when retrieval returns nothing relevant, an escalation button that creates a ticket with the transcript attached, cost tracking per conversation, and a fixed test set of 30–50 real questions you re-run whenever you change how documents are split, the instructions, or the models.

Steps 3–5 are where the time goes. The prompt at the top of this page generates that shape as a real app, with document upload, the search index, live chat replies and citations already set up, so the work left is your content and your instructions to the AI.

Build vs. buy

There are three realistic routes. Which one is right depends on how you pay and what you need to own.

RouteTime to liveHow you payModel choiceOwn the data and UI
Off-the-shelf (Intercom Fin, Zendesk AI, Tidio, Chatbase)HoursPer resolution, per seat, or per message tier on top of the platform subscriptionVendor'sNo: conversations, index, and widget live on their side
Custom build (a developer using AI toolkits or code written from scratch)WeeksAI usage costs plus engineering timeYoursYes
Generated app (WebTwizz)Hours to a dayAI usage costs; hosting is yoursYours, swappableYes: your code, your database, your domain

Buy if your support team already lives in Intercom or Zendesk, volume is low enough that per-resolution pricing doesn't hurt, and you don't need the bot anywhere except the help widget.

Build or generate if per-resolution pricing scales badly for you, the bot needs to sit inside your own product with your logins and your design, your data has to stay in your database, or you want to change the model when a better or cheaper one ships.

What it costs to run

The recurring cost is model usage, and it's small compared to per-resolution pricing.

  • Indexing is a one-time cost per document, on the order of a hundredth of a cent per passage. A 100-page documentation set costs cents to index, and re-indexing only what changed keeps it that way.
  • Answers cost roughly $0.01–$0.05 per conversation on a small model such as Claude Haiku or GPT-4o-mini for typical support-length exchanges. A thousand conversations a month is $10–$50 in AI usage.
  • Hosting is a database with a search index, plus the app itself. On Supabase and Vercel that starts free and stays under typical SaaS seat pricing for a long time.

Compare that with $0.99 per resolved conversation on Intercom Fin: 1,000 resolutions is $990 a month before the platform subscription. Cost is rarely the reason to buy; speed and not having to own anything is.

Mistakes that make these bots bad

  • No refusal path. If the instructions don't tell the AI to decline when the passages found are empty or off-topic, it will answer anyway, and it will be confidently wrong.
  • No citations. Users trust an answer that links to the doc it came from and distrust one that doesn't. Citations also make bad answers easy to trace.
  • Passages that are too big or too small. Too big and the relevant sentence is buried in noise; too small and the answer is split across passages that don't all get found. Split on document structure, and test.
  • A stale index. Docs change; the search index doesn't know unless something re-indexes them. Re-index when a document changes, not on a fixed schedule.
  • Mixing customers' documents. If the bot serves multiple customers or workspaces, every search has to stay within that customer's documents. Forgetting this leaks one customer's documents into another's answers.
  • No test set. Without 30–50 fixed real questions and expected answers, every change to how documents are split or to the instructions is a guess. Run the set on every change.

Which knowledge sources work best

The bot is only as good as what it can retrieve, and some sources retrieve much better than others.

  • Works well: help-center articles, product documentation, policy pages, FAQs, release notes, anything already written to answer a question.
  • Needs preparation: long PDFs (split by section and keep headings), spreadsheets (add a row-per-record description), and marketing pages (strip menus and repeated page text before splitting).
  • Usually not worth it: scanned PDFs without text recognition, Slack or email threads where the answer is spread across twenty messages, and internal wikis nobody has updated in a year. The bot will cite them, and the citation will be wrong.

A useful starting rule: if a human support agent would paste a link to it, add it. If they'd say "let me check with someone," it isn't ready to be a source.

01 / What you get

AI Chatbot with Knowledge Base, generated.

Click Generate from the box above. Real code, a real database, real integrations, not a sandbox. Each piece below ships in the first prompt.

01

Chat replies that appear as they are written, with clean formatting and highlighted code examples

02

Knowledge base upload: add PDFs, paste text or pull in web pages, all split up and indexed for search

03

Answers from your own documents: every answer cites the source documents it pulled from

04

OpenAI or Anthropic as the AI, swap models without changing the chat screen

05

Conversation history per user, searchable, exportable

06

AI usage tracking per conversation so you can check cost per user

02 / Variants

4 variants you can ship.

01
Customer support bot
Docs-grounded, ticket creation if it can't answer, multi-language, escalation rules.
02
Sales assistant
Catalog and pricing-aware, lead capture mid-conversation, demo-booking handoff.
03
Internal HR / IT bot
Employee Q&A on policies, IT troubleshooting, works with company sign-in so it's on the right account.
04
In-product docs assistant
Embedded in your app, context-aware of which page the user is on.

From data to design

The AI builds a real app. Then you shape every pixel.

Data

Wire up real data

Databases and CMS that power your live app, no backend to set up.

Wire up real data
Type

Tune every letter

Font, size, weight, leading and spacing, all by hand.

Tune every letter
Color

Pick any color

Pick any color
Components

Reuse your own blocks

Save any section and drop it in anywhere.

Reuse your own blocks
Images

Drop in photos

Pull in free imagery without leaving the canvas.

Drop in photos
Pages

Structure your site

Structure your site

03 / Who it's for

Who this is for.

→Support teams replacing tier-1 with a bot trained on their docs
→SaaS companies building "ask the docs" search inside their product
→Agencies offering chatbot setups to clients as a service
→Founders who need a docs assistant before they have a support team

Works with the tools you already use.

Payments, data, email, analytics, booking, messaging and AI. Connect an account once and every project can use it.

See all connectors
Stripe
Supabase
GitHub
OpenAI
Anthropic
Google Analytics
Notion
Resend
HubSpot
WhatsApp
PostHog
Sentry

04 / Why generate it

Why generate it instead of buying it.

Intercom Fin charges $0.99 per resolution. At 1,000 questions a month that's $12,000 a year and you don't own the conversations or the model choice.

You pick the AI model (Claude, GPT, or an open model you run yourself later), the indexing model (OpenAI, Cohere, or your own), and where the search index lives (your own database or Pinecone). When prices drop or a better model ships, you change one line.

Head-to-heads: vs Lovable · vs Bolt · vs v0 · vs Replit

FAQ

Questions about AI Chatbot with Knowledge Base.

Everything you need to know before you generate it. Anything else, our team is one email away.

Upload PDFs or paste URLs into an admin page (WebTwizz builds the form). The AI builds the step that reads the content, splits it into small overlapping pieces (about 500 tokens each), and indexes them for AI search in your Supabase database. Updates are incremental: only changed docs are re-indexed.

Searching is right for almost everyone. Training a model on your docs (fine-tuning) is expensive, slow, and brittle when your docs update. Searching pulls fresh passages for every question, which is why the answer can include "this changed last week" without retraining. Keep the instructions tight: tell the AI to say it does not know when the search finds nothing.

Yes. The AI adds citations inline, each answer ends with a "Sources:" block listing the doc titles and URLs the model pulled from. Clicking a citation opens the source. Trust signal users actually look at.

Roughly $0.01-$0.05 per conversation on Claude Haiku or GPT-4o-mini for typical Q&A length. Indexing is about $0.0001 per passage, once, when a document is added. So a 100-page doc set costs cents to index; 1,000 user conversations a month costs $10-$50 in AI usage. Compare to $990 per 1,000 resolutions on Intercom Fin.

Yes. WebTwizz builds a short embed snippet you paste into any website to show the chat. Logging in is optional: anonymous visitors get a temporary session, and logged-in users get history saved to their account.

It searches them. Nothing is trained on your data; the AI reads the passages it found when it answers. That is why updating a document changes the next answer immediately, and why deleting one removes it from every future answer.

Your idea, live in minutes.

Describe what you want. WebTwizz builds the real thing, then you click to change anything.

All templates

100 free credits on signup. No credit card needed.