Slack bot
The Zentri Slack bot lets people who never open a terminal work with Zentri from Slack. They can ask for work, answer an agent’s question, and approve or reject a decision. The bot lives in integrations/slack-bot. It is built on Slack Bolt with TypeScript and needs Node 22.19 or later. ADR-0010 records the design.
How it works
Section titled “How it works”The bot decides nothing. It translates between Slack and the coordinator’s REST API.
- Requests from Slack. For each verified Slack request, the bot calls the coordinator with its integration token and the header
Zentri-Slack-User: <team_id>:<user_id>. The coordinator looks up the linked Zentri user and runs the same authorization check as for the CLI, with that user’s role. A refusal comes back to the person as a private message. - A rate limit for each Slack user. The coordinator allows each Slack user 1 request a second, with bursts of 10, inside the bot token’s own limit.
/zentri linkattempts count too. Past it, the person sees “Too many requests. Try again in N s.” with the wait the coordinator sent. - Messages to Slack. The coordinator writes each notice for a linked user to an outbox: questions, decisions, someone watching your work instead of starting a duplicate, a duplicate escalated to you as a lead, and queued work whose blocker ended. The bot leases rows, posts them as direct messages from the app, and acknowledges each one. The coordinator deletes a delivery’s row 30 days after it was queued.
- The coordinator never calls Slack and holds no Slack credential. Only the bot holds the Slack tokens.
A linked user acting through Slack can only read projects, check and register work, read and answer questions, read and review decisions, and unlink. Everything else is denied through Slack: tokens, users, invites, sessions, claims, the merge check, and MCP. Work asked for from Slack never starts an agent. It waits in the queue.
What people can do
Section titled “What people can do”| In Slack | What happens |
|---|---|
/zentri link <code> |
Links your Slack account to your Zentri user. |
/zentri request <project> <what you need> |
Checks the request against work in progress. New work is registered and waits in the queue. Matching work shows the matches and a button for each choice the coordinator allows. |
| Answer on a question | Opens a form. Your answer goes to the agent that asked. |
| Approve or Reject on a decision | Records your review. The message shows the outcome in place of the buttons. |
/zentri unlink |
Removes the link. |
/zentri help |
Lists the commands. |
Queued work starts from the CLI. A lead can start any queued intent. An engineer can start only their own.
zt start --queued <intent-id>See Asking for work from Slack for the full flow.
Link your Slack account
Section titled “Link your Slack account”The link code proves your Zentri side. The signed Slack request proves your Slack side. Nobody types a Slack ID by hand.
$ zt slack linkLink code: ZL-XXXX-XXXX-XXXXExpires: <time> (in <minutes>)
In Slack, type: /zentri link ZL-XXXX-XXXX-XXXX
The code works once and is not shown again. Linking replaces any link you have.- The code expires after 10 minutes and works once.
- A bad, expired, or used code gets one generic error.
- An admin can mint a code for someone with no CLI with
zt slack link --user <handle>, and hand it over privately. zt slack statusshows your link.zt slack unlinkremoves it, and an admin can remove anyone’s with--user.
Set up the app
Section titled “Set up the app”Never paste a token into chat or commit it. Put each value in its own file with mode 0600.
-
Give the bot a public HTTPS origin, such as
https://zentri-bot.example.com, that reaches itsPORT. Athttps://api.slack.com/apps, choose Create New App, then From a manifest. Pasteintegrations/slack-bot/manifest.yamlwithhttps://bot.example.comreplaced by that origin in both URLs. The manifest is for HTTP mode. For Socket Mode, change instead the three lines its comments name. The bot scopes arecommandsandchat:write. -
Install the app to the workspace. Save the bot token (
xoxb-) to a file such as~/.zentri/slack/bot-token. -
For HTTP mode, the default, save the Signing Secret from Basic Information to
~/.zentri/slack/signing-secret. -
For Socket Mode, generate an app-level token with the scope
connections:writeunder Basic Information, then App-Level Tokens. Save it (xapp-) to~/.zentri/slack/app-token, and setSLACK_MODE=socket. -
Read the team ID, bot user ID, and bot ID with
auth.test. The header file keeps the token out of your shell history and the process list.Terminal window umask 077printf 'Authorization: Bearer %s\n' "$(cat ~/.zentri/slack/bot-token)" >slack.headerscurl -sS -H @slack.headers https://slack.com/api/auth.test | jq '{team_id, user_id, bot_id}'rm slack.headers -
Have a Zentri admin issue an integration token with the single scope
slack:act-as-verified-user.Terminal window umask 077printf 'Authorization: Bearer %s\n' "$(cat ~/zentri-admin-token)" >admin.headerscurl -sS -H @admin.headers -H 'Content-Type: application/json' \-d '{"label":"slack-bot","scope":"slack:act-as-verified-user"}' \https://zentri.example.com/v1/integration-tokens | jq -r .token >~/.zentri/slack/zentri-tokenrm admin.headers
Run the bot
Section titled “Run the bot”From a checkout of the Zentri repository:
pnpm --dir integrations/slack-bot install --frozen-lockfilepnpm --dir integrations/slack-bot buildSLACK_TEAM_ID=T0123ABCD SLACK_BOT_ID=B0123ABCD SLACK_BOT_USER_ID=U0123ABCD \ SLACK_BOT_TOKEN_FILE=~/.zentri/slack/bot-token \ SLACK_SIGNING_SECRET_FILE=~/.zentri/slack/signing-secret PORT=3000 \ ZENTRI_URL=https://zentri.example.com ZENTRI_TOKEN_FILE=~/.zentri/slack/zentri-token \ node integrations/slack-bot/dist/main.jsThe bot exits with code 2 and the event config_invalid when a setting is missing or malformed. The message names the variable, never its value. SIGTERM and SIGINT stop it cleanly.
It logs JSON lines on stdout with request IDs, action names, outcomes, delivery IDs, and error types. The logs carry no message text and no token.
Configuration
Section titled “Configuration”Each secret can be set directly or read from the file that <NAME>_FILE names, such as SLACK_BOT_TOKEN_FILE. Setting both is an error.
| Variable | Required | Default | Meaning |
|---|---|---|---|
SLACK_MODE |
No | http |
http or socket. |
SLACK_BOT_TOKEN |
Yes | The bot token, xoxb-. |
|
SLACK_APP_TOKEN |
In Socket Mode | The app-level token, xapp-. |
|
SLACK_SIGNING_SECRET |
In HTTP mode | Verifies each request from Slack. | |
PORT |
No | 3000 |
The HTTP mode port. The bot serves POST /slack/events. |
SLACK_TEAM_ID |
Yes | The only workspace the bot answers. Starts with T. |
|
SLACK_BOT_ID |
Yes | The bot ID. Starts with B. |
|
SLACK_BOT_USER_ID |
Yes | The bot’s user ID. Starts with U or W. |
|
SLACK_API_URL |
No | Slack’s API | Another Slack Web API base URL, such as a fake for local tests. |
ZENTRI_URL |
Yes | The coordinator’s URL. | |
ZENTRI_TOKEN |
Yes | The slack:act-as-verified-user integration token. |
|
POLL_INTERVAL_MS |
No | 2000 |
How long the outbox waits after a short batch, from 100 to 60000. It backs off up to 60 seconds while the coordinator is down. |
On the coordinator, ZENTRI_SLACK_RETRY_BASE sets the first retry delay of a failed delivery. It defaults to 10 seconds and doubles up to 15 minutes. A delivery is marked dead after 8 attempts. The metric zentri_slack_deliveries_total counts deliveries by outcome, and zentri_slack_deliveries_pruned_total counts the rows the 30-day retention deleted. See Environment variables and Metrics.
Socket Mode and HTTP mode
Section titled “Socket Mode and HTTP mode”| HTTP mode (default) | Socket Mode | |
|---|---|---|
| Needs a public URL | Yes, HTTPS, ending in /slack/events. |
No. The bot opens a WebSocket to Slack. |
| Secret | SLACK_SIGNING_SECRET |
SLACK_APP_TOKEN |
| Request check | The bot checks the HMAC-SHA256 signature, rejects a timestamp more than 5 minutes off, and rejects a replayed signature. Each answers 401. | Slack delivers over the bot’s own connection, so there is no signature. |
| Team check | A request from another team gets 401. | A request from another team is dropped. |
| Tested | Run end to end against the fake Slack. | Never run. |
Limitations
Section titled “Limitations”- No real Slack. No real workspace has run the bot, and Socket Mode has not run. The manifest has not been installed.
- At least once. A bot crash can post a message twice.
- 30-day retention. A delivery is deleted 30 days after it was queued, delivered or not. A bot that is down that long loses the Slack copy of what was queued before then. The notice stays in
zt status. The prune is not audited. A metric and a log line record it. - A row leased before you unlink may still post once.
- The per-user limit trusts the bot. It is keyed by the Slack user the bot names. A bot host in an attacker’s hands can name a new user for each call, so there the bot token’s limit, 10 a second with bursts of 30, is the only cap on link-code guesses.
- A rare link race. Two codes for one Zentri user, redeemed at the same instant from two Slack accounts, can refuse the second with
slack_user_linkedalthough that account is free. A new code links it. - Pending work requests live in the bot’s memory for 15 minutes. A button clicked after that, or after a bot restart, is refused. Ask again.
Related pages
Section titled “Related pages”- Asking for work from Slack
- Questions and decisions and Approving decisions
- Integrations for how integration tokens work
- CLI reference for
zt slack - The HTTP API reference, for the Slack routes and
POST /v1/integration-tokens - Webhooks for the inbound request URL in HTTP mode
- Vendor terms for the Slack API terms