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):
| Token | Prefix | Represents | Lifetime | Taji uses it for |
|---|---|---|---|---|
| Bot token | xoxb- | "a bot associated with an app installed in a workspace", not tied to a user's identity | The page states no expiry. Rotation is opt-in, and once on it cannot be turned off. | Every Web API call but one |
| App-level token | xapp- | the app across organizations | "do not expire by default"; with rotation opted in, access tokens expire after 12 hours | apps.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:historyandfiles: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.
| Family | Method | Scope | Stated limit | Doc |
|---|---|---|---|---|
| Auth | auth.test | none | "hundreds of requests per minute" | auth.test |
| Socket Mode | apps.connections.open | connections:write on the app-level token; the method page lists none, as no bot or user scope applies | Tier 3, 50+ per minute | apps.connections.open, connections:write |
| Conversations | conversations.open | im:write | Tier 3 | conversations.open |
| Messaging | chat.postMessage | chat:write | about 1 per second per channel, several hundred per minute per workspace | chat.postMessage |
| Files | files.getUploadURLExternal, then files.completeUploadExternal | files:write | Tier 4, 100+ per minute | getUploadURLExternal, completeUploadExternal |
| Events | message.im over Socket Mode | im:history | 30,000 deliveries per workspace per app per 60 minutes | message.im, Rate limits |
| Interactivity | block_actions payloads, response_url | none | response_url: up to 5 uses within 30 minutes | block_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 withenvelope_id,typeandpayload. - 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_requestedasks for a new connection;warningcomes about 10 seconds before a disconnect;link_disabledmeans 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.postMessagetakes JSON.- Its
markdown_textis capped at 12,000 characters and "should not be used in conjunction withblocksortext". - The
markdownblock 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
valueholds at most 2,000 characters and its label at most 75. Itsstyleisprimary,dangeror unset (button). conversations.openwith one user returns that DM's existing channel id when it is already open.- The
files.getUploadURLExternalpage lists only form encoding. Bytes go toupload_urlraw or multipart, and any answer but 200 is a failure. Untilfiles.completeUploadExternalis called, the file is discarded. That call's reply listsfilesand no messagets.
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 intaji-plugin.tomlpromises 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 withassistant: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. Readimpl Channel for Slackfirst, thensession.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'sHold(taji_plugin::channel::Hold, every channel's 429 hold) answersFailed::Unreachedat once while a 429 holds, naming the seconds left. A 429 isFailed::Unreached, never resent, and itsRetry-Aftersets that hold. It answersOkon"ok": true; on"ok": falseit answersFailed::Refusedwith Slack's error word; it answersFailed::Unreachedfor transport and decode errors.dm:conversations.openfor the owner's DM channel id.post:chat.postMessage, answering the message'sts.session: one Socket Mode connection. It acknowledges every envelope, then routesevents_apitodm_fromandinteractivetopressed. It answersOkondisconnect, sorunopens a new connection, except onlink_disabled, which it answersFailed::Refused.dm_from: amessage.imevent as anInbound, or nothing.pressed: ablock_actionspress as anInbound, plus theresponse_urlbody that strips theactionsblock.clear_buttons: that one POST. A failure is printed to stderr and never retried.field,refused_asandtext: 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 awiremockWeb API and a local websocket that plays Slack.plugins/slack/taji-plugin.toml: identity, theslacklink form, its steps, fields and refusal words, and the vendor sources.plugins/slack/Cargo.toml: depends ontaji-plugin,reqwest,tokio-tungsteniteandserde_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:
| Method | Slack's answer |
|---|---|
id, name | slack, Slack |
fields | app_token, bot_token |
caps | inbound: true, images: true, text_limit: 12_000 |
markup | the default, Markup::Markdown |
link | auth.test on the bot token, then apps.connections.open on the app-level token. It answers owner: None, so the kernel pairs by code. |
send | Text 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_framed | A markdown block holding **title**\nbody, an actions block with a button per reply, and the fallback in text |
typing | the default, which does nothing |
run | session 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
tajicommands, and asks the desk's Agent chat; - it reruns
run5 s after aFailed::Unreached. Arunthat ended any other way is run again only by the next link or the next kernel start:Channels::unlockstarts arunonly while the slot holds no task, and the ended task stays held; - it writes
erroron 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 surface | Slack call | Made in |
|---|---|---|
POST /verb/channels/link (channel: "slack") | auth.test, apps.connections.open | Channel::link |
GET /read/channels, Slack's row | none: the row is the kernel's slot | wire/channels.rs |
| The pairing code's DM, any owner DM, a button press | Socket Mode events_api and interactive envelopes | session, dm_from, pressed |
The reply to a DM, an alert's desk note, taji command answers | conversations.open, chat.postMessage | send, send_framed |
| A permission card | chat.postMessage with blocks; on press, response_url | send_framed, clear_buttons |
POST /verb/channels/send with pane (MCP call) | conversations.open, chat.postMessage, files.getUploadURLExternal, the upload, files.completeUploadExternal | send |
POST /verb/channels/unlink | none: the kernel drops the run task and the sealed tokens | wire/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.
- You DM the app. Slack pushes an
events_apienvelope on the socket, whichsessionopened withapps.connections.open. sessionacknowledges the envelope first.dm_fromkeeps it only if it is amessagewithchannel_type: "im", nobot_idand nosubtype. It becomes anInboundwith:id<channel>:<ts>;senderevent.user;at_utcthe whole seconds ofts;text.
inbox.heardhands it toChannels::heardinwire/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 aJob::Ask.Channels::askasks the desk's Agent chat with anOriginnaming Slack andimages: true. EachSaid::Answergoes throughsend_to, which renders the Markdown (a pass-through for Slack), cuts it at 12,000 characters and callsSlack::sendonce per piece.sendcallsconversations.openwith{"users": <owner>}for the DM's channel id, thenchat.postMessagewith{"channel", "markdown_text"}. Slack'stsreturns as the sent id. The kernel stamps the row'slast_sent_utcand clears itserror.
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.
linkproves 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'sseenset drops. dm_fromdropsbot_idand everysubtype. The arm's own sends come back asmessage.imwith abot_id. Forwarding them would loop, andChannel::run's contract says the arm's own sends never reachinbox. Edits and file shares carry asubtype.- Markdown passes through. The kernel's text is Markdown, and Slack's
markdown_textandmarkdownblock translate Markdown themselves.text_limitis 12,000 because that is the cap of both. - A card is blocks, and a press is text.
send_frameddraws Slack blocks. Each button'svalueis the reply text the kernel minted, such asyes abcde, so a press reachesheardas 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
textandblocksminusactions, and posts them to the press'sresponse_url, so it needs no messagets. Whyresponse_urlrather thanchat.updateis not on record. - An image is its own message. The text goes first as a separate
chat.postMessage, andsendanswers itsts:Channel::sendanswers the platform's id of what was sent, andChannelSentcalls each a message's id, which on Slack is ats.files.completeUploadExternalreturns nots, so an image with no text answers the file id. - A plugin on the SDK alone. The crate depends on
taji-pluginand 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:
Where What fails Result calla transport or decode error Failed::Unreached:runis rerun after 5 s; a send sets the row'serrorcallHTTP 429, or any call while its Retry-AfterholdsFailed::Unreached, sent nothing during the hold:runis rerun after 5 s; a send sets the row'serrorcall"ok": falseFailed::Refusedwith Slack's word, such asSlack apps.connections.open: invalid_auth:runends and is not rerun until you link again or Taji restartssessiondisconnectwithlink_disabledFailed::Refused: Socket Mode is off for the app, sorunends until you turn it on and link againlinka refused auth.testthe word invalid_keylinka refused apps.connections.openthe word invalid_app_tokenfielda missing field Failed::Refused("Slack needs <name>")sendan upload answered with anything but 2xx Failed::RefusedThe kernel turns each word into the manifest sentence under
[link.refusals]. -
Rate limits. A 429's
Retry-Afterholds every Web API call of the arm, whatever the method, through theHoldevery channel shares (docs/plugins/channel.md): each isUnreachedunsent 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 anUnreachedrunmeets 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, thenchat.postMessage), and an image costs five. Nothing caches the DM's channel id. -
One connection.
runholds one socket. Adisconnectopens a new one at once with a freshapps.connections.open, exceptlink_disabled: Socket Mode was turned off for the app (Using Socket Mode), a new connection cannot help, andrunendsRefused. A socket that closes withoutdisconnectisUnreached, 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
tsis 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. Aresponse_urltakes 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:
/conversations.open;/chat.postMessagewith{"channel": "p2", "markdown_text": "SPY"};/files.getUploadURLExternal, formfilename=taji.png&length=7, answeringupload_urlandfile_idp3;- the raw bytes to
upload_url; /files.completeUploadExternalwith{"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:wiremockplays the Web API and a localTcpListenerplays 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_disabledendingrun; - a 429 refusing every call unsent until its
Retry-Afterpasses; - 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::channelschecks thatGET /read/channelsservesslackunlinked, andcargo test -p taji-open --test routeschecks that the plugin is composed. - Live. There is no
tests/live.rsand 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 throughchannels/link, DM the pairing code, then DM a question.
References
Slack's docs, each fetched 2026-12-02:
- Using Socket Mode
- Tokens
- Rate limits
- App manifests
- message.im
- auth.test
- apps.connections.open
- connections:write
- conversations.open
- chat.postMessage
- files.getUploadURLExternal
- files.completeUploadExternal
- The markdown block
- The button element
- The block_actions payload
- Handling user interaction
In Taji: