Skip to main content

Slack: how it works

Slack is a messaging platform; Taji uses one app that you make in your own workspace to carry a direct message (DM) both ways. Alerts, agent answers and permission cards go out as messages from the app, and what you type to the app, or a button you press, comes back in. The plugin is one channel crate, taji-slack, built from plugins/slack/src/lib.rs. It implements taji_plugin::channel::Channel, calls Slack's Web API at https://slack.com/api, and holds one Socket Mode websocket open while linked. It serves no market data, places no orders and feeds no hub product.

The vendor​

All facts here come from Slack's developer docs, fetched 2026-12-02.

Hosts. You get one environment, with no sandbox. Web API methods are POST https://slack.com/api/<method>. Socket Mode is a wss:// URL that apps.connections.open returns on each call. A file upload goes to a one-off upload_url that files.getUploadURLExternal returns. A button press carries a one-off response_url.

Apps and tokens. An app is installed to a workspace, and the app is the unit of permission. Taji uses two of its tokens (Tokens):

TokenPrefixRepresentsLifetimeTaji uses it for
Bot tokenxoxb-"a bot associated with an app installed in a workspace", not tied to a user's identityThe page states no expiry. Rotation is opt-in, and once on it cannot be turned off.Every Web API call but one
App-level tokenxapp-the app across organizations"do not expire by default"; with rotation opted in, access tokens expire after 12 hoursapps.connections.open alone

Slack sends each token as Authorization: Bearer. apps.connections.open refuses an app-level token passed as a POST parameter (apps.connections.open). Taji supports neither rotation nor OAuth: you paste two long-lived tokens.

Making the app. A manifest is a JSON or YAML description of an app. Slack documents the URL https://api.slack.com/apps?new_app=1&manifest_json=<manifest_here>, which "will direct users right into the app creation flow" (App manifests). Taji's manifest asks for:

  • the bot scopes chat:write, im:write, im:history and files:write;
  • the bot event message.im;
  • Interactivity on;
  • Socket Mode on;
  • the App Home messages tab enabled and writable.

plugins/slack/src/tests.rs (manifest_app_step_url_decodes_to_the_expected_json) decodes the URL and checks every one of these.

API families Taji calls.

FamilyMethodScopeStated limitDoc
Authauth.testnone"hundreds of requests per minute"auth.test
Socket Modeapps.connections.openconnections:write on the app-level token; the method page lists none, as no bot or user scope appliesTier 3, 50+ per minuteapps.connections.open, connections:write
Conversationsconversations.openim:writeTier 3conversations.open
Messagingchat.postMessagechat:writeabout 1 per second per channel, several hundred per minute per workspacechat.postMessage
Filesfiles.getUploadURLExternal, then files.completeUploadExternalfiles:writeTier 4, 100+ per minutegetUploadURLExternal, completeUploadExternal
Eventsmessage.im over Socket Modeim:history30,000 deliveries per workspace per app per 60 minutesmessage.im, Rate limits
Interactivityblock_actions payloads, response_urlnoneresponse_url: up to 5 uses within 30 minutesblock_actions, Handling user interaction

Socket Mode (Using Socket Mode) replaces a public Request URL. You cannot set both.

  • On connect, Slack sends hello, then wraps each event or interaction in an envelope with envelope_id, type and payload.
  • The app must acknowledge each envelope with {"envelope_id": …}, "so that Slack knows whether to retry". The page states no deadline for the acknowledgement.
  • Slack ends a connection with disconnect:
    • refresh_requested asks for a new connection;
    • warning comes about 10 seconds before a disconnect;
    • link_disabled means Socket Mode was turned off.
  • Connections are refreshed "once every few hours", and an app may hold up to 10 at once.
  • Apps using Socket Mode are not allowed in the public Slack Marketplace.

Messages.

  • chat.postMessage takes JSON.
  • Its markdown_text is capped at 12,000 characters and "should not be used in conjunction with blocks or text".
  • The markdown block has the same 12,000-character cap, counted across all its blocks in one payload. Slack translates its Markdown and may split it into several blocks.
  • A button's value holds at most 2,000 characters and its label at most 75. Its style is primary, danger or unset (button).
  • conversations.open with one user returns that DM's existing channel id when it is already open.
  • The files.getUploadURLExternal page lists only form encoding. Bytes go to upload_url raw or multipart, and any answer but 200 is a failure. Until files.completeUploadExternal is called, the file is discarded. That call's reply lists files and no message ts.

Rate limits. Slack answers an excess with HTTP 429 and a Retry-After header, in seconds. The method pages also list ratelimited among their error words (Rate limits).

What Taji does not use:

  • A public Request URL for events. Socket Mode needs no public URL.
  • OAuth distribution, Marketplace listing and token rotation. The app is your own, made from a manifest. Socket Mode apps are barred from the Marketplace anyway.
  • Channels, group DMs and threads. The app hears only message.im, and the brief in taji-plugin.toml promises never to read a channel.
  • Slash commands, modals and shortcuts. Taji acknowledges their envelopes and drops them. Not yet built.
  • A typing signal. A bot has only assistant.threads.setStatus, for an Agents & AI app in threads with assistant:write. Not yet built.
  • Images sent from the phone and message edits. Inbound files and edits are dropped. Images from the phone are not yet built.

Code map​

  • plugins/slack/src/lib.rs: the whole arm. Read impl Channel for Slack first, then session.
    • Slack::at: the Web API root, which a test swaps for a fake.
    • call: one POST with a bearer token, JSON or form body. Before it sends, the arm's Hold (taji_plugin::channel::Hold, every channel's 429 hold) answers Failed::Unreached at once while a 429 holds, naming the seconds left. A 429 is Failed::Unreached, never resent, and its Retry-After sets that hold. It answers Ok on "ok": true; on "ok": false it answers Failed::Refused with Slack's error word; it answers Failed::Unreached for transport and decode errors.
    • dm: conversations.open for the owner's DM channel id.
    • post: chat.postMessage, answering the message's ts.
    • session: one Socket Mode connection. It acknowledges every envelope, then routes events_api to dm_from and interactive to pressed. It answers Ok on disconnect, so run opens a new connection, except on link_disabled, which it answers Failed::Refused.
    • dm_from: a message.im event as an Inbound, or nothing.
    • pressed: a block_actions press as an Inbound, plus the response_url body that strips the actions block.
    • clear_buttons: that one POST. A failure is printed to stderr and never retried.
    • field, refused_as and text: reading a sealed field, mapping a refusal to a manifest word, and reading a string out of a reply.
  • plugins/slack/src/tests.rs: offline tests against a wiremock Web API and a local websocket that plays Slack.
  • plugins/slack/taji-plugin.toml: identity, the slack link form, its steps, fields and refusal words, and the vendor sources.
  • plugins/slack/Cargo.toml: depends on taji-plugin, reqwest, tokio-tungstenite and serde_json, and on no other Taji crate.
  • plugins/slack/ui/mark.svg: the mark the Connections page draws.
  • plugins/slack/README.md: the page for the person linking.

How it plugs into Taji​

The trait. Slack implements Plugin, whose build calls b.channel(Self::default()), and Channel (engine/crates/taji-plugin/src/channel.rs). The Channel methods it implements:

MethodSlack's answer
id, nameslack, Slack
fieldsapp_token, bot_token
capsinbound: true, images: true, text_limit: 12_000
markupthe default, Markup::Markdown
linkauth.test on the bot token, then apps.connections.open on the app-level token. It answers owner: None, so the kernel pairs by code.
sendText goes as markdown_text, answering its ts. With a PNG, the text goes first if non-empty, then the three-call upload into the same DM; it answers the text's ts, or the file id when there is no text.
send_framedA markdown block holding **title**\nbody, an actions block with a button per reply, and the fallback in text
typingthe default, which does nothing
runsession in a loop until it fails

The plugin has no FACTS, VenueFacts or OFFER statics, because a channel is no data source or venue. engine/crates/taji-open/src/lib.rs composes it into the shipped kernel with .add(taji_slack::Slack::default).

The link form. The manifest's one [[link]] is the form slack. It has pairs = true and its steps are app, token and install; the step text is the manifest's, and the kernel adds a typing step and the pair step. The form posts channels/link with {"channel": "slack"} and the two fields. The two refusal words are invalid_key and invalid_app_token.

The kernel side. engine/crates/taji/src/wire/channels.rs owns everything that is not Slack:

  • it seals the two fields in your vault;
  • it mints the pairing code and binds the owner;
  • it drops every inbound not the owner's, and dedups by Inbound.id;
  • it answers "Not run: Taji heard this late." to an inbound more than 120 s old;
  • it parses card replies and taji commands, and asks the desk's Agent chat;
  • it reruns run 5 s after a Failed::Unreached. A run that ended any other way is run again only by the next link or the next kernel start: Channels::unlock starts a run only while the slot holds no task, and the ended task stays held;
  • it writes error on the channel's row.

Markup::Markdown means engine/crates/taji/src/wire/markup.rs passes the kernel's Markdown through unchanged, and Slack does the rendering.

Surfaces.

Taji surfaceSlack callMade in
POST /verb/channels/link (channel: "slack")auth.test, apps.connections.openChannel::link
GET /read/channels, Slack's rownone: the row is the kernel's slotwire/channels.rs
The pairing code's DM, any owner DM, a button pressSocket Mode events_api and interactive envelopessession, dm_from, pressed
The reply to a DM, an alert's desk note, taji command answersconversations.open, chat.postMessagesend, send_framed
A permission cardchat.postMessage with blocks; on press, response_urlsend_framed, clear_buttons
POST /verb/channels/send with pane (MCP call)conversations.open, chat.postMessage, files.getUploadURLExternal, the upload, files.completeUploadExternalsend
POST /verb/channels/unlinknone: the kernel drops the run task and the sealed tokenswire/channels.rs

The routes' full contracts are the channels rows of the //! header of engine/crates/taji/src/wire/mod.rs.

One message in and one out.

  1. You DM the app. Slack pushes an events_api envelope on the socket, which session opened with apps.connections.open.
  2. session acknowledges the envelope first. dm_from keeps it only if it is a message with channel_type: "im", no bot_id and no subtype. It becomes an Inbound with:
    • id <channel>:<ts>;
    • sender event.user;
    • at_utc the whole seconds of ts;
    • text.
  3. inbox.heard hands it to Channels::heard in wire/channels.rs. The owner rule passes only the paired user; on an unpaired channel, only the live code binds the sender. Then come the dedupe and the 120 s check. Text that is neither a card reply nor a command becomes a Job::Ask.
  4. Channels::ask asks the desk's Agent chat with an Origin naming Slack and images: true. Each Said::Answer goes through send_to, which renders the Markdown (a pass-through for Slack), cuts it at 12,000 characters and calls Slack::send once per piece.
  5. send calls conversations.open with {"users": <owner>} for the DM's channel id, then chat.postMessage with {"channel", "markdown_text"}. Slack's ts returns as the sent id. The kernel stamps the row's last_sent_utc and clears its error.

Why it is built this way​

  • Socket Mode, not a Request URL. Taji runs on your machine with no public address. Every channel's inbound arrives with no public URL.
  • Your own app, two pasted tokens. The arm has no OAuth server to host, and Socket Mode apps cannot be listed in the Marketplace, so each user makes their own app from a manifest. The manifest URL makes that one click, for agent and user alike.
  • link proves both tokens but names no owner. A bot token proves the app, not which person in the workspace is you. The kernel therefore pairs by an eight-letter code that you DM within ten minutes, and binds the sender Slack authenticated. This owner rule is the security boundary, because a card answered from a channel can run a shell.
  • Every envelope is acknowledged before it is read. Slack retries an unacknowledged envelope, so even the envelopes Taji drops are acknowledged. A retry that does arrive is the same Inbound.id, which the kernel's seen set drops.
  • dm_from drops bot_id and every subtype. The arm's own sends come back as message.im with a bot_id. Forwarding them would loop, and Channel::run's contract says the arm's own sends never reach inbox. Edits and file shares carry a subtype.
  • Markdown passes through. The kernel's text is Markdown, and Slack's markdown_text and markdown block translate Markdown themselves. text_limit is 12,000 because that is the cap of both.
  • A card is blocks, and a press is text. send_framed draws Slack blocks. Each button's value is the reply text the kernel minted, such as yes abcde, so a press reaches heard as that text from the presser and passes the same owner rule as typed text.
  • The arm takes the buttons off a pressed card. The arm reuses the pressed message's own text and blocks minus actions, and posts them to the press's response_url, so it needs no message ts. Why response_url rather than chat.update is not on record.
  • An image is its own message. The text goes first as a separate chat.postMessage, and send answers its ts: Channel::send answers the platform's id of what was sent, and ChannelSent calls each a message's id, which on Slack is a ts. files.completeUploadExternal returns no ts, so an image with no text answers the file id.
  • A plugin on the SDK alone. The crate depends on taji-plugin and on no kernel crate (0003). The tokens reach it only by value from the sealed record, and never reach a client (0005).

Constraints and limits​

The README has no measured section yet: no Slack exchange has been walked on a real workspace.

  • Failures map onto the kernel's three outcomes:

    WhereWhat failsResult
    calla transport or decode errorFailed::Unreached: run is rerun after 5 s; a send sets the row's error
    callHTTP 429, or any call while its Retry-After holdsFailed::Unreached, sent nothing during the hold: run is rerun after 5 s; a send sets the row's error
    call"ok": falseFailed::Refused with Slack's word, such as Slack apps.connections.open: invalid_auth: run ends and is not rerun until you link again or Taji restarts
    sessiondisconnect with link_disabledFailed::Refused: Socket Mode is off for the app, so run ends until you turn it on and link again
    linka refused auth.testthe word invalid_key
    linka refused apps.connections.openthe word invalid_app_token
    fielda missing fieldFailed::Refused("Slack needs <name>")
    sendan upload answered with anything but 2xxFailed::Refused

    The kernel turns each word into the manifest sentence under [link.refusals].

  • Rate limits. A 429's Retry-After holds every Web API call of the arm, whatever the method, through the Hold every channel shares (docs/plugins/channel.md): each is Unreached unsent until it passes, and nothing sleeps, since a wait would hold the kernel's send for as long as Slack asks. Slack limits per method and workspace (Rate limits), so the hold is wider than Slack's. The kernel's 5 s rerun of an Unreached run meets the hold until it passes, which paces the reconnect. A message sent during the hold is not queued. Every send costs two calls (conversations.open, then chat.postMessage), and an image costs five. Nothing caches the DM's channel id.

  • One connection. run holds one socket. A disconnect opens a new one at once with a fresh apps.connections.open, except link_disabled: Socket Mode was turned off for the app (Using Socket Mode), a new connection cannot help, and run ends Refused. A socket that closes without disconnect is Unreached, and the kernel reruns it after 5 s.

  • Late and lost messages. Nothing queues while the kernel is down. A DM delivered more than 120 s after its ts is answered "Not run: Taji heard this late." and not asked.

  • Interactivity. Without Interactivity on the app, no press arrives, and typed yes <t> replies still work. A response_url takes up to 5 uses within 30 minutes of the press (Handling user interaction), and the arm uses it once at once. If Slack does not take that update, the buttons stay and the session stays up. The first press still answers the card, which the kernel then forgets, so a second press is answered "No such request.".

  • Scopes. A hand-made app that lacks a scope fails on first use with Slack's missing_scope. Naming a hand-made app's missing scope is not yet built.

Examples​

Each comes from a test body, its values made up, in plugins/slack/src/tests.rs. Ids are masked: the owner p1, the DM channel p2, a file p3, envelopes p4 and p5, the presser p6.

A send (send_opens_the_owners_dm_and_posts_the_text). The kernel's send_to calls Slack::send(secret, "p1", "hi"):

POST /conversations.open Authorization: Bearer <bot token>
{"users": "p1"}
→ {"ok": true, "channel": {"id": "p2"}}

POST /chat.postMessage
{"channel": "p2", "markdown_text": "hi"}
→ {"ok": true, "ts": "1700000000.000100"}

send answers 1700000000.000100.

An inbound DM (run_acknowledges_every_envelope_forwards_only_the_owners_dms_and_reconnects). Slack pushes:

{"envelope_id": "p4", "type": "events_api",
"payload": {"event": {"type": "message", "channel_type": "im", "channel": "p2",
"user": "p1", "text": "hello", "ts": "1700000000.000100"}}}

The arm acknowledges with {"envelope_id": "p4"} and hands the kernel Inbound { id: "p2:1700000000.000100", sender: "p1", at_utc: 1700000000, text: "hello" }. The same event with "bot_id", with "subtype": "message_changed" or with "channel_type": "channel", and any slash_commands envelope, are acknowledged and dropped. {"type": "disconnect", "reason": "refresh_requested"} makes the arm open a second connection.

A card and its press (send_framed_posts_markdown_and_actions_blocks_and_omits_actions_when_empty and a_button_press_is_heard_as_its_value_and_the_buttons_go, trimmed):

POST /chat.postMessage
{"channel": "p2", "text": "Allow Bash? yes abcde",
"blocks": [{"type": "markdown", "text": "**Allow `Bash`?**\n```\nls\n```"},
{"type": "actions", "elements": [
{"type": "button", "text": {"type": "plain_text", "text": "Yes"},
"action_id": "reply_0", "value": "yes abcde", "style": "primary"}, …]}]}
→ {"ok": true, "ts": "1700000000.000200"}

The press arrives as {"envelope_id": "p5", "type": "interactive", "payload": {"type": "block_actions", "user": {"id": "p6"}, "container": {"channel_id": "p2"}, "actions": [{"value": "yes abcde", "action_ts": "1700000010.000400", …}], "response_url": …, "message": …}}. The kernel hears Inbound { id: "p2:1700000010.000400", sender: "p6", text: "yes abcde" }, and the arm POSTs {"replace_original": true, "text": "Allow Bash? yes abcde", "blocks": [<the markdown block alone>]} to the response_url.

An image (an_image_send_answers_the_texts_ts_else_the_file_id). send with text SPY and a 7-byte PNG calls, in order:

  1. /conversations.open;
  2. /chat.postMessage with {"channel": "p2", "markdown_text": "SPY"};
  3. /files.getUploadURLExternal, form filename=taji.png&length=7, answering upload_url and file_id p3;
  4. the raw bytes to upload_url;
  5. /files.completeUploadExternal with {"files": [{"id": "p3", "title": "taji.png"}], "channel_id": "p2"}.

send answers 1700000000.000100, the text's ts. With no text, step 2 is skipped and send answers p3.

The link form (engine/crates/taji/tests/fixtures/wire/link-forms.json, trimmed). GET /read/link/forms serves Slack's form as {"form": "slack", "group": "Channels", "pairs": true, "post": {"route": "channels/link", "body": {"channel": "slack"}}, "fields": [{"name": "app_token", "kind": "secret", …}, {"name": "bot_token", "kind": "secret", …}], "refusals": {"invalid_app_token": …, "invalid_key": …}, …}.

The kernel's answers to a Slack link and send. No capture yet. channels_walk.py walks Discord alone; its Slack steps are not yet built, and a Slack link and ask step there would make one.

Testing​

  • The arm, offline: cargo test -p taji-slack. It needs no key and no network: wiremock plays the Web API and a local TcpListener plays the Socket Mode server. The tests cover:
    • the link: both tokens checked, refusal words mapped, a missing field, an unreachable host;
    • the manifest URL;
    • a text send, the image upload flow and a framed send;
    • envelope acknowledgement, filtering and reconnect, and link_disabled ending run;
    • a 429 refusing every call unsent until its Retry-After passes;
    • a button press, and a failed response_url;
    • a refused app-level token ending run.
  • The kernel's channel logic (owner rule, pairing, cutting, cards, commands) is tested against a fake arm: cargo test -p taji --lib -- channels.
  • The composed kernel lists Slack: cargo test -p taji-open --test headless surface::channels checks that GET /read/channels serves slack unlinked, and cargo test -p taji-open --test routes checks that the plugin is composed.
  • Live. There is no tests/live.rs and no Slack walk. The human checks not yet walked are an app made from the manifest with Interactivity on, a DM round trip and a tap. Run them against a headless kernel, never your own Taji: link with your own workspace's tokens through channels/link, DM the pairing code, then DM a question.

References​

Slack's docs, each fetched 2026-12-02:

In Taji: