Discord bots for your DocsGPT agents. One small binary runs any number of bots, each connected to one or more agents.
- Streaming: answers are written into the message as they are generated, with a Stop button.
- Threads: in servers, each question gets its own thread.
- Sources and feedback: sources are linked under each answer, and 👍/👎 buttons record feedback in DocsGPT.
- Files: attachments go to the agent, and files that its tools produce come back.
Version 2 is a rewrite in Rust on docsgpt-rs, the crates shared with the Slack and Telegram bots. The Python bot lives on the legacy-python branch and the :1 image tag. See Upgrading from version 1.
- Streaming answers. The answer is edited in as it's written, about once a second. Long answers continue in new messages, splitting between blocks so code blocks stay intact. Tool steps ("Running code") show as a small grey line, and Stop cuts the answer short.
- A thread per question. In a server, mention the bot and it opens a thread on your message and answers there. Keep talking in the thread without mentioning it again. If threads aren't allowed in that channel, it replies inline.
- DMs. Every message in a DM continues one conversation until
/new. - Sources and feedback. Sources are linked under the answer. The 👍/👎 buttons record feedback in DocsGPT for that exact answer; click again to take it back.
- Files in. Documents and images you attach are sent to the agent. Voice messages are transcribed and asked as questions.
- Files out. When the agent runs tools (code execution, document or image generation), the files are uploaded to the conversation.
- Several agents.
#sales questionasks one agent once, and a message that is just#salesswitches the channel to it./agentswitches,/agentslists, and/askasks. - Formatting. Markdown renders natively, and tables become aligned code blocks. Answers never ping anyone.
- Operations. SQLite by default (or in memory), structured logs, graceful shutdown that lets answers finish, and a small distroless image for amd64 and arm64.
- In the Discord Developer Portal, create an application and open Bot.
- Copy the token (Reset Token).
- Turn on Message Content Intent under Privileged Gateway Intents. The bot needs it to read follow-ups in its threads that don't mention it. If you'd rather not, set
FOLLOW_THREADS=false; follow-ups then need a mention or/ask. - Run
docsgpt-discord --check(below). It prints an invite link with the right scopes and permissions: send messages, send messages in threads, create public threads, read message history, embed links, attach files. Open it to add the bot to your server.
git clone https://github.com/arc53/discord-docsgpt-extension.git
cd discord-docsgpt-extension
cp .env.example .env # fill in DISCORD_TOKEN and API_KEY
docker compose up -dOr without compose:
docker run -d --name docsgpt-discord --env-file .env -v botdata:/app/data arc53/discord-docsgpt-extension:latestTo get the invite link and check the token: docker run --rm --env-file .env arc53/discord-docsgpt-extension:latest --check.
cargo build --release
./target/release/docsgpt-discord --check
./target/release/docsgpt-discordRust 1.89 or newer is required.
You need an agent API key from DocsGPT: Agents → your agent → API key.
| Variable | Purpose |
|---|---|
DISCORD_TOKEN |
Bot token. Required. |
API_KEY |
DocsGPT agent API key for the default agent. |
API_KEY_<NAME> |
Extra agents, addressed as #name or with /agent. |
API_BASE |
DocsGPT server URL (default https://gptcloud.arc53.com). |
SQLITE_PATH / STORAGE_TYPE |
SQLite file (default data/docsgpt-discord.db; /app/data/… in Docker), or STORAGE_TYPE=memory. |
THREADS |
false to answer mentions inline instead of opening threads. |
FOLLOW_THREADS |
false to need a mention in threads too (no privileged intent needed). |
STREAMING, FILES, SLASH_COMMANDS |
false turns that feature off. |
MAX_FILE_MB, ALLOWED_GUILDS |
File size limit (default 20); comma-separated server ids to answer in (DMs are always allowed). |
RUST_LOG, LOG_FORMAT=json |
Logging. |
Create docsgpt-discord.toml in the working directory, or set DOCSGPT_DISCORD_CONFIG=/path/to/file.
${VAR}and${VAR:-default}are filled in from the environment, so secrets can stay in.env.docsgpt-discord.example.tomlshows every option.- In Docker, mount the file:
-v ./docsgpt-discord.toml:/app/docsgpt-discord.toml:ro.
DocsGPT keeps the conversation transcript. The bot only stores:
- which DocsGPT conversation each DM, thread or channel is in
- the chosen agent for each channel
- which threads it opened
- which message holds which answer (for 👍/👎)
Backends:
sqlite(default): one file, kept in the/app/datavolume in Docker.memory: lost on restart.
- In a server: mention it (
@DocsGPT how do I deploy?) or use/ask. The answer goes in a new thread; keep asking there. - In a DM: just ask.
/newstarts over. - Press Stop while it's writing to cut the answer short.
- 👍 / 👎 under an answer rate it.
- Agents:
/agentslists them,/agent salesswitches the channel, and#sales questionasks one agent once. - Files: attach them to your message. A voice message is transcribed first.
- Images and branches:
:1and thelegacy-pythonbranch keep the Python bot.:latestand:2are version 2. - Your
.envworks as is (DISCORD_TOKEN,API_KEY,API_BASE), except for MongoDB:STORAGE_TYPE=mongodbis no longer supported; remove it and theMONGODB_*variables, and keep/app/dataon a volume.- Version 1 kept its own copy of every chat. DocsGPT keeps them now, so existing chats start fresh conversations.
- Conversations are per DM and per thread, no longer one per user across every server.
- New:
- streaming, threads, buttons and slash commands
- several agents
- files
- Re-invite the bot with the link from
--checkso it gets theapplications.commandsscope and the thread permissions. Turn on the Message Content intent, or setFOLLOW_THREADS=false. !startis gone. Mention the bot, DM it, or use/ask.
cargo test # unit + end-to-end tests against a mock Discord API and a mock DocsGPT
cargo clippy --all-targets -- -D warningsThe end-to-end tests feed gateway events (JSON) to the real dispatcher. They run against an in-process mock of Discord's REST API and the docsgpt crate's mock server.
Layout:
src/config.rs: TOML and environment config.src/gateway.rs: the gateway connection.src/events.rs: what each message, command and button does.src/surface.rs: how an answer is streamed and finished.src/render.rs: Markdown and buttons.src/files.rs: attachments.src/commands.rs: slash commands.
MIT