Case study · AI · Self-started

A community docs bot that learns from your moderators

Community mods spend their days answering the same questions, and most of those answers never make it back into the docs. I built a Discord bot that answers from a project's docs, stays current on its own, and learns from what mods answer, so they only have to answer each question once.

Type
Side project, self-started
My part
Idea, product and build
When
2024
Team
Solo build, piloted with a few communities

Self-startedNobody asked for this one. I kept seeing mods answer the same questions, so I built something for it.

What I did

  1. 01

    Spotted the problem

    Watching community channels, the same questions kept coming back. Docs bots could answer what was written down, but the answers that mattered most lived in mods' replies, and those were never captured.

  2. 02

    Designed the loop

    Answer from the docs. Admit when you don't know. Let a mod answer, then learn from it. Keep sources fresh without anyone re-uploading docs.

  3. 03

    Built it end to end

    As a product, not a script. Multi-tenant backend where each community gets its own knowledge base, credits and usage tracking, five ways to feed it knowledge, the Discord bot, and the training loop.

The problem

Before AI, every crypto company kept a moderation budget: four or five mods answering community questions all day. Most of those questions were already answered in the docs or the whitepaper. Nobody wants to read a long whitepaper, so they ask in Discord instead. For a company that’s a fixed cost spent on repeating what’s already written down.

When LLMs arrived, that looked like a gap AI could fill. But a docs bot only knows what’s written down. In a live community, the useful answers are often in a mod’s reply from last week: a workaround, a date, a link that isn’t in the docs yet. So mods keep answering the same thing, and the bot can’t help with exactly the questions people ask most.

How it works

Ingest, answer, learn

1Ingest

Five sources per community
GitHub docs repoHosted docs sitePDF whitepaperMedium feedMod replies
Split on headings, embeddedchunks embedded with OpenAI ada-002
MongoDBone knowledge base per community

2Answer

Someone mentions the bota question in a Discord channel
Seen it before?a near-identical past question, or a strong match on a mod's answer, is returned directly. No model call.
Retrieve, then writemost relevant sections + the question → gpt-4o-mini
Answershort, with source links
"I don't know."please check with admin

3Learn

A mod repliesthe moment the bot couldn't answer
Was it a question?a small classifier checks the original message
Credential filterpasswords, tokens, API keys and vault references are never learned
Training job, every 30–60 minnew mod answers join the knowledge base

The next person who asks gets the mod's answer. Mods answer each question once.

Ingest. Five front doors into one knowledge base: a GitHub docs repo, a hosted docs site like GitBook, a PDF whitepaper, a Medium feed, and mod replies. Each source is split on headings into chunks, embedded with OpenAI’s ada-002, and stored in MongoDB under that community. The demo indexes the Astro Starlight docs. Medium sync pulls the latest articles, so announcements land in the bot’s knowledge without anyone re-uploading.

Answer. Mention the bot in Discord and it embeds the question, pulls the most relevant sections from MongoDB, and passes those sections plus the question to gpt-4o-mini to write a short answer with source links. If the sources don’t cover the question, it says “I don’t know. Please check with admin.” It doesn’t guess.

Learn from mods. When a mod replies in Discord, a small classifier first checks the original message was actually a question. If it was, the reply becomes training data. A job runs every 30–60 minutes and adds new mod answers to what the bot knows. The next person who asks gets the mod’s answer.

Guardrails. Learning from mods can leak internal info, so replies go through a filter before training. Anything that looks like a credential (passwords, tokens, API keys, vault references) is skipped. In the demo, a mod’s reply about where the staging password lives is never learned, and the bot defers to an admin.

Try the loopExample conversation
  1. Member

    Is there a discount code for the workshop?

    Bot

    I don't know. Please check with admin.

  2. Mod

    Use the code from the launch post at checkout.

  3. Member

    What's the staging deploy password?

    Mod

    It is in the team vault under "Docs Staging".

  4. Training job

    1 mod answer learned · 1 skipped by the credential filter

  5. Another member

    Any discount for the workshop?

    Bot

    Use the code from the launch post at checkout.

    source: mod answer
  6. Another member

    What's the staging password?

    Bot

    I don't know. Please check with admin.

    credential filter: never learned
Ingest via API, three answers from the Starlight docs, "I don't know" on a discount code, a mod answers, training runs, the bot answers with the mod's code, and it declines to share an internal password. Recorded on a test server; the asker's handle and avatar are blurred. No sound.

Decisions

Batch training, not real time. A job every 30–60 minutes was enough. A repeat question within the hour is still answered by a mod, and real-time training would have added cost and complexity for no real gain.

“I don’t know” over a guess. A wrong answer in a community channel costs more than no answer. Deferring to an admin also creates the exact moment a mod’s reply can teach the bot. Temperature 0 and a 300-token cap keep answers short and predictable.

Don’t call the LLM when you don’t have to. Communities ask the same thing over and over, so a near-identical past question (similarity above 0.97) reuses its answer. A strong match on a mod’s answer is returned directly. Both skip the model call, which matters when every answer is billed against a community’s credits.

Never cache “I don’t know”. An early version cached them, so a question could keep getting “I don’t know” even after a mod had taught the answer. Dropping them from the cache let the learning loop work.

Stack

Python, FastAPI, MongoDB Atlas, OpenAI text-embedding-ada-002 and gpt-4o-mini, tiktoken, NLTK, PyMuPDF, Discord bot API.

Where it landed

We piloted it with a couple of communities, including Router’s own, with a community manager running it day to day. While it ran, it cut query resolution time by ~35% and saved mods ~10 hours a week.

Over time, tools built entirely around this problem appeared, and we moved to one of them. Soon after, ChatGPT and later Claude could read docs directly, and people started asking them instead.

What I took from it

A team that makes a problem its whole business will usually move faster on it. Seeing others go all-in confirmed the problem was real.

The part with lasting value was learning from moderators, the knowledge that isn’t written down anywhere. That’s where I’d go deeper if I came back to it.