Files
wekan/docs/Features/Rules/Bots.md
T
Lauri Ojansivu 7e1f9e89eb Docs: every feature topic in one folder under docs/Features, each with README.md as its main page.
- The General/ level is gone: its 109 files moved up into the folders of the
  same name, and its topic table is the "Shared topics" section of
  Features.md.
- Accessibility is one folder, docs/Features/Accessibility/, with the Admin
  Panel's accessibility page in it.
- Every folder's main page is README.md (110 X/X.md pages renamed with git mv,
  five merged with an existing README.md, 26 index pages added for folders
  that had none), so a folder opened on GitHub shows its page.
- The 73 "# Moved" forwarding pages are deleted, with the folders that held
  only them; every link that went to one goes to its final page.
- docs/Features/README.md has the website's "Features in WeKan" overview,
  each feature linking to its page here.

1,129 Markdown links in 262 files and 352 doc paths in code, tests, compose,
snap and release files follow. tests/docsFeaturesLayout.test.cjs fails when
General/ or a "# Moved" page comes back, a folder has no README.md, or a
relative link in the docs or README.md does not resolve.

Thanks to xet7 !
2026-11-24 20:02:06 +02:00

8.3 KiB

Bots

What it is

Board Settings → Bots, below Workflow view, is the Rules page's view for bots: runners on your own server that this board hands cards to. A runner can be an AI coding agent, a CI job or a script. The view looks and works like kanbots, in the board's own theme, Font Awesome icons and drag and drop. Like the rest of the Rules page it is for board admins only. It is not a board view: it is not in the Board View menu and can never be a public view.

Read more

How to use it

  1. Open the board's right sidebar → Board Settings → Bots (below Workflow view). You must be a board admin.
  2. In the rail, click Add bot and fill in Bot name, Runner address and, optionally, Signing token (optional).
  3. Open a card from the columns. In the drawer, pick the bot and click Hand to bot. Or make a Rule with the action Hand the card to bot.
  4. Follow the run in the card's state, in Live runs and in Activity. When the bot asks a question, click one of the answers on the card, or type in Reply to the bot and click Send.
  5. Click Stop to stop a run.
┌ Bots ───────────┬ Dev / Bots              2 running · 1 waiting for you ─┬ Fix login ─────┐
│ ⚙ Coder  host   │ TODO 3      │ IN PROGRESS 2        │ REVIEW 1 │ DONE  │ [Coder ▾][▶ Hand]│
│ [+ Add bot]     │ ┌─────────┐ │ ┌──────────────────┐ │          │       │ ■ Stop           │
│ ⚡ Live runs     │ │bug #12  │ │ │feat #7 RUNNING   │ │          │       │ RUNNING · $0.12  │
│  RUNNING Fix…   │ │Fix login│ │ │Add export        │ │          │       │ 💬 alice: please…│
│ ⟲ Activity      │ └─────────┘ │ │>_ Bash: npm test │ │          │       │ ⚙ Edit: login.js │
│  Coder: Edit…   │             │ │? Which file?     │ │          │       │ [Reply…] [Send]  │
│                 │             │ │[a.js] [b.js]     │ │          │       │                  │
└─────────────────┴─────────────┴──────────────────────┴──────────┴───────┴──────────────────┘
  • The rail: this board's bots (add one with a name, the runner's address and an optional signing token), the live runs with what each is doing, and the bots' recent activity.
  • The columns are the board's lists. Each card shows its first label, its number, its bot run's state (Queued, Running, Waiting for you, Ready to review, Done, Failed, Stopped), the step it is on, and when the bot asked a question, the answers to click. Drag a card to another column to move it, as on the board.
  • The drawer shows a card's thread: its comments and its run's events, in order. Hand to bot gives the card to a bot, Stop stops the run, and the reply box answers the bot.

How the numbers are calculated

  • The header line N running · M waiting for you (bots-summary) counts this board's runs whose status is running, and those whose status is awaiting_input (runningCount, waitingCount in client/components/rules/rulesBots.js).
  • A run keeps its last 50 events (MAX_EVENTS); a text is cut at 4,000 characters (MAX_TEXT), a tool name and an option at 200, a question at 1,000, and at most 8 answer options are kept (MAX_OPTIONS), all in models/lib/botRuns.js.
  • tokens and costUsd must be finite numbers from 0 to 10^12; they are shown as reported (e.g. $0.12), not computed by WeKan.
  • A dispatch carries at most the card's last 20 comments; a reply is cut at 65,536 characters (server/bots.js).
  • The Bots view is sent at most the 300 most recently updated runs of the board (botRuns publication).

How it works in WeKan

A bot has no rights of its own

Bots are like Rules and workflows: they act only through what WeKan already allows, and override no WeKan permission.

  • WeKan only sends to a bot. A bot is an outgoing webhook marked as a bot. Handing it a card queues one dispatch through the ordinary webhook queue: the SSRF guard, the bot's signing token as X-Wekan-Token, retries, and on Sandstorm the Powerbox. A bot is subscribed to no board activity, due reminders included, so nothing else from the board is sent to it.
  • The runner works through the REST API. It changes the board with its own WeKan user's API token, so it has that user's board role and nothing more: comments, moves, labels and archiving are WeKan REST calls that WeKan allows or refuses as for anyone.
  • Who hands over. A board admin, in this view, or a Rule a board admin made with the action Hand the card to bot. For example, "when a card is moved to In progress, hand it to Coder" is kanbots' drag-to-start.
  • Answers and replies are the admin's own card comments, written under their right to comment in that list, and the bot is told.

The runner's side

The dispatch is a JSON POST to the runner's address:

{ "event": "bot.dispatch", "runId": "…", "bot": { "id": "…", "title": "Coder" },
  "board": { "id": "…", "title": "Dev", "key": "DEV" },
  "card": { "id": "…", "number": 7, "title": "…", "description": "…",
            "list": { "id": "…", "title": "In progress" }, "labels": ["bug"], "url": "…" },
  "comments": [{ "id": "…", "text": "…", "at": "…" }],
  "report": "https://<wekan>/api/boards/<board>/cards/<card>/bot-runs/<run>",
  "api": "https://<wekan>/api" }

The runner reports at report with its own API token (Authorization: Bearer <token>); WeKan requires write access to the board:

{ "status": "running", "tool": "Bash", "text": "npm test" }
{ "status": "awaiting_input", "question": "Which file?", "options": ["a.js", "b.js"] }
{ "status": "review", "text": "Ready: see the comment", "tokens": 1200, "costUsd": 0.12 }

status is one of queued, running, awaiting_input, review, done, failed and stopped. A finished run (done, failed, stopped) stays finished, the last 50 events are kept, and texts are bounded. Later the runner receives bot.answer (value, text), bot.reply (text) and bot.stop.

Files

File
client/components/rules/rulesBots.jade, .js, .css The view
server/bots.js Handing over, answers, replies, stopping, the run report route
models/lib/botRuns.js A run's states and what may change them. No Meteor code
models/botRuns.js The runs, written by the server only, published to board admins
tests/botRuns.test.cjs, server/lib/tests/bots.tests.js The tests

A card already with a bot keeps its active run: handing it over again returns the same run (dispatchToBot). Handing over, answering, replying, stopping and the botRuns publication all check that the caller is a board admin (allowIsBoardAdmin); an answer or reply is also checked with canCommentInList.

Commits