Home Marketplace Chatbot Knowledge-Base Starter

A support bot that
only says true things.

Four Python scripts, an importable app config and a playbook that stand up a grounded support chatbot on Dify in about an hour. Create the knowledge base from the terminal, ingest a folder of docs with heading-aware chunking, crawl your own site politely, and verify indexing before you trust it. The app config answers only from the knowledge base, cites its sources, and hands off to a human instead of guessing. Nothing to install.

4Scripts
0Dependencies
1Importable app config
30Minute test protocol

Instant download · Commercial licence, unlimited client bots · Free updates for life · 7-day refund

Real output

Not pseudocode.
Actual runs.

Captured from running the scripts against a live self-hosted Dify 1.x instance on 15 August 2026 — create, ingest and index verified end to end.

kb_create.py output showing a knowledge base created on a live Dify instance with its dataset ID
kb_create.py against a live instance — one command, and the dataset ID every other script uses comes back.
kb_ingest.py uploading a folder of markdown docs with heading-aware chunking
A folder of docs in one pass. Chunks split on headings rather than at arbitrary character counts, because retrieval quality is set at ingestion.
kb_status.py showing all documents indexed and ready with a clean exit code
kb_status.py confirms every document actually indexed. Exit 0 clean, exit 1 otherwise — so a cron job can watch your bot's knowledge.
kb-support-bot.yml grounding rules: answer only from the knowledge base, cite sources, escalate to a human
The grounding rules from the importable config — answer only from the KB, cite the source, and escalate rather than improvise.

The problem

The demo works.
The customer breaks it.

Most support chatbots fall apart the moment someone asks a question the docs don't cover — and the bot answers anyway. It invents a refund policy, promises a feature, quotes a price that doesn't exist. One confident wrong answer to a paying customer costs more than the bot ever saved.

The fix isn't a smarter model. It's grounding: a knowledge base built so retrieval actually finds the right passage, and an app configured to refuse when it can't. Both of those are set up in about an hour — if you do them in the right order, with a test protocol before going live.

Order — ground, test, then ship
Not — ship, then apologise

What's inside

Four scripts, a config,
and the playbook.

01

kb_create.py — the knowledge base, from the terminal

Creates the Dify knowledge base with the retrieval settings the rest of the kit expects and prints the dataset ID every other script uses. Scriptable from day one — no clicking through the console, and rebuilding a client's KB from scratch is one command.

Works on — self-hosted & Dify Cloud
02

kb_ingest.py — a folder of docs, chunked properly

Points at a folder of .md, .txt, .html and .pdf and uploads the lot with heading-aware chunking — sections stay whole instead of being cut mid-sentence at a character count. This is the step that decides whether retrieval finds the right passage later; the defaults here are the ones that survived live testing.

Chunks on — headings, not char counts
03

kb_crawl.py — your site, politely

Reads your own site's sitemap.xml, fetches pages with a delay between requests, strips navigation and boilerplate, and feeds clean text into the knowledge base. Built for your own properties and docs sites — it identifies itself and rate-limits rather than hammering.

Source — sitemap.xml
Manner — rate-limited
04

kb_status.py — trust, verified

Checks that every document actually finished indexing — because a document that uploaded but never indexed is invisible to the bot, and nothing in the chat window tells you. Exit 0 when everything is ready, exit 1 otherwise, so it drops into cron and alerts you when a re-ingest silently fails.

Exits — 0 ready / 1 not
Drops into — cron or CI
05

kb-support-bot.yml — the app that stays honest

An importable Dify app config with the grounding prompt, citations switched on, retrieval tuned (top-k 4, score threshold, temperature 0.2) and the refusal line: when the knowledge base doesn't cover it, the bot says so and flags a human instead of improvising. Import it, pick your model, connect the KB — done.

Answers — only from the KB
Otherwise — escalates
+

The KB Playbook

What belongs in a knowledge base and what poisons it, the chunking rules that make retrieval work, and a 30-minute test protocol to run before the bot meets a customer — including the adversarial questions that catch a bot that's about to start guessing.

Format — Markdown
Setup — START-HERE.md, ~60 min

Who it's for

People who'd rather escalate
than hallucinate.

SaaS founders adding support chat

You want deflection on the questions the docs already answer — without the bot freelancing on the ones they don't.

Agencies shipping client bots

Commercial licence covers unlimited client bots. The scripts make every new client KB a repeatable one-command setup.

Ops and support leads

You own the help centre and want it answering chat — with citations you can audit when a customer disputes an answer.

Not a fit if you won't open a terminal. You need a Dify instance — self-hosted or Dify Cloud's free tier — and the willingness to run four small Python scripts. If you want a fully hosted, no-code chatbot subscription, this is deliberately not that.

Honestly

What this can't do.

!

The bot is only as good as your docs. Grounding stops the bot inventing answers; it doesn't write your help centre. If the knowledge base is thin or stale, the bot will correctly refuse a lot — the playbook tells you what to write first.

Not a hosted service. You bring the Dify instance and the model key (OpenAI, Claude, Gemini or a local model — anything Dify supports). No usage fees to me, but your model provider bills for the tokens.

Grounding reduces wrong answers; nothing eliminates them. That's why the config cites sources and the playbook makes you run the 30-minute test protocol before launch rather than after the first complaint.

Does — refuse & escalate
Can't — write your docs

Questions

Before you buy.

Q

Why do support chatbots make things up?

Because a language model's default behaviour is to answer, and most bots are wired straight to the model with the docs stuffed loosely into the prompt. When retrieval misses — wrong chunk, unindexed document, question outside the docs — the model fills the gap fluently. The fix is structural: retrieval tuned so the right passage is actually found, a score threshold so weak matches are discarded, and an explicit instruction to refuse and escalate when nothing clears the bar. That is exactly what the included app config does.

Q

Do I need to self-host Dify, or does Dify Cloud work?

Either. The scripts talk to Dify's Knowledge API, which is the same on a self-hosted instance and on Dify Cloud — you set the base URL and API key in one .env file. The kit was live-tested end to end against a self-hosted Dify 1.x instance; Dify Cloud's free tier is enough to evaluate everything before you commit to hosting.

Q

Does this work with Flowise, LangChain or another RAG stack?

The four scripts and the app config are Dify-specific. The KB Playbook is not — what belongs in a knowledge base, the heading-aware chunking rules, the grounding prompt pattern and the 30-minute test protocol apply unchanged to Flowise, LangChain or anything else that retrieves before it answers. If you're on another stack you're buying the playbook with a working reference implementation.

Q

Which AI model does the bot use?

Whichever you connect in Dify — OpenAI, Claude, Gemini, or a local model via Ollama. The app config sets temperature low and grounding strict, which matters more for support accuracy than which frontier model you pick. You pay your model provider directly for usage; there are no fees to me.

Q

Do I need to install anything to run the scripts?

No. All four scripts run on stock Python 3.9 or newer with no packages to install — they use the standard library only. You need network access to your Dify instance and an API key, both of which go in the provided .env.example. Every script exits 0 on success and 1 on failure, so they work in cron jobs and CI without modification.

Q

Can I use this for client projects?

Yes. The licence is single-operator commercial and covers unlimited client bots, including paid work — set up as many knowledge bases and support bots for clients as you like. You may not resell or redistribute the files themselves. If it isn't useful, reply to your receipt within seven days for a full refund.

About an hour. Then it stops guessing.

Instant download. Commercial licence, unlimited client bots. Free updates for life. Seven-day refund, no justification needed.

Live-tested against a real Dify instance before listing

Where this came from

We run a self-hosted Dify instance for our own client chatbots — the chunking defaults, the status checks and the refusal line all come from bots that are answering real customers today. Read how to stop a support chatbot from making things up, or if you'd rather we build and host the whole thing for you, that's the day job.