Article · Interface
Slack as the Interface for Platform AI
Half the engineering work isn’t AI. It’s negotiating with Slack: thread mechanics, retry semantics, double-reply races, formatting quirks. Get those right and the AI gets to focus on being useful.
When I started building our internal platform assistant, I assumed Slack was just the chat layer — a place to receive the question and post the answer. It turned out to be the substrate. Half the engineering work on the system isn’t AI; it’s negotiating with Slack’s behavior: thread mechanics, retry semantics, race conditions, formatting quirks, ephemeral message rules. Anyone building an internal AI tool that lives in chat will run into the same wall.
Here’s what Slack actually does to your architecture, and what we built to deal with it.
Why Slack and not a UI
We considered a web UI. Slack won on three grounds:
- Developers are already there. A platform assistant that lives somewhere they have to go is one they won’t go to. Slack is the lowest possible activation energy.
- Threads are the right unit of conversation. A debugging session has natural continuity — an opening question, follow-ups, a resolution. Slack threads model that without ceremony.
- The audit trail is automatic. Every interaction with the assistant is searchable by the rest of the team. When someone asks a question, the answer is visible to the next person who asks something similar. A web UI you’d have to build that yourself.
The cost is that Slack imposes its own model — Socket Mode, Block Kit, message TTLs, the way @mentions and DMs interleave — and your architecture has to bend around it.
The double-reply problem
The hardest bug I’ve shipped fixes for, by a wide margin, is double-reply. The user @mentions Atlas. Two Slack message handlers fire. Two investigations run in parallel. Two answers post.
The causes are stacked:
- Slack Socket Mode redelivery. If your handler doesn’t ack within 3 seconds, Slack redelivers the event. A real investigation takes longer than 3 seconds. So redelivery is normal.
- Multiple processes. In a multi-pod deployment, more than one pod can receive the event before any has claimed it.
- In-process concurrency. Even within one pod, if the handler isn’t structured carefully, two coroutines can both think they’re the canonical handler.
The fix is layered:
- Event-level dedup. As soon as the event arrives, claim a Redis key (
atlas:event:{event_id}). If the key exists, this is a redelivery — exit silently. The TTL is generous, scaled to the investigation budget — we usemax(600, budget * 2). - Reply-layer lock. Before posting any visible reply, claim a Redis lock keyed
atlas:reply:{channel}:ts:{ts}. Only one handler crosses this gate. - In-memory backstop. A per-pod in-memory map catches the rare case where Redis is unreachable or slow. Belt and suspenders.
- Thread-inflight marker. When a thread already has an investigation running, a rapid re-mention in the same thread gets a brief “still working on your earlier question” instead of a parallel investigation. Backed by a per-thread Redis marker keyed
atlas:thread_inflight:{channel}:{thread_ts}. - Race-resolution settling pause. Between claiming the lock and posting the visible ack, we wait 1 second to let any concurrent handler resolve out. After the pause, a re-check of the in-memory backstop catches anything that snuck through.
Each layer catches a different race. None of them is sufficient alone. The combination has eliminated double-reply in production.
The lesson generalizes: any chat-based AI system that does work taking more than a second needs to think about idempotency at multiple layers. The 3-second redelivery window in Socket Mode is the loudest forcing function, but the underlying issue is that “the message arrived” and “the work completed” are different events, and you have to build the bridge between them.
Progress is the contract
A platform investigation takes 30 seconds to 4 minutes depending on what’s involved. The user is sitting there. If Slack shows nothing, they assume it’s broken.
We built a progress heartbeat that updates a single message in place. Status text rotates: “Understanding your question” → “Checking for prior findings” → “Looking at logs” → “Tracing dependencies” → “Composing the answer.” Phase-level updates fire on real state transitions (sub-agent boundaries, synthesizer kickoff). The heartbeat ticks every 8 seconds, with the first tick at 2 seconds so operations that finish quickly don’t get a misleading “still working.”
Every emit site logs a greppable token: SLACK_ACK_PRIMARY_POSTED, SLACK_ACK_FALLBACK_FIRED, SLACK_PROGRESS_NEW_MESSAGE, HEARTBEAT_TICK, HEARTBEAT_SKIPPED. When something goes wrong with the progress UX, Splunk has the trace within seconds.
The principle: a slow operation is acceptable if the user can see it making progress. A slow operation that looks frozen is a bug. Progress isn’t a nice-to-have — it’s the contract.
Block Kit vs mrkdwn
Slack has two formatting languages: Block Kit (structured JSON, rich layout) and mrkdwn (plain markdown with Slack-specific extensions). For most of Atlas’s lifetime, we used Block Kit. It looked clean. The structured chips for response type, the formatted bullets, the divider blocks — all pretty.
We’ve moved most things to mrkdwn. Reasons:
- Block Kit imposes more roundtripping. Edits are heavier. Some operations that are trivial in mrkdwn (changing a single line) require constructing a fresh block array.
- mrkdwn renders consistently across mobile clients and edge cases that Block Kit sometimes mishandles.
- The reply is a conversation, not a report. Block Kit’s structure subtly pushes toward “report” framing — which is exactly what we don’t want for natural, prose-style answers.
We still use Block Kit for specific cases: cost responses (the table renders well), visualizations (charts need image blocks), feedback buttons. For the main answer body, mrkdwn is now the default. The split keeps the rendering consistent with the underlying response type without forcing every answer into a Block Kit envelope.
The ephemeral problem
Slack has a third message type: ephemeral. Only the user sees it. Useful for one-off prompts (“do you mean orders-prod or orders-staging?”), but with a quirk: ephemeral messages stack. If you post three ephemeral prompts in a row, the user sees three buttons. They click one and get confused about which one applied.
We hit this with a “Connect to Glean” OAuth prompt — a knowledge-agent feature that needs the user to authenticate the first time. If the user @mentioned Atlas rapidly three times before completing the OAuth flow, they got three Connect buttons stacked in the thread. We added a per-(workspace, user, channel, thread) SET-NX claim on the ephemeral with a 30-minute TTL, cleared by the OAuth success path or the cancel handler. One button per thread, period.
The pattern generalizes: any ephemeral that prompts the user for input needs a dedup claim. The default behavior is wrong.
Headers, sections, and the formatter
The synthesizer produces markdown. The Slack formatter takes that markdown and converts it to Slack-compatible blocks. The formatter is more complex than it sounds, because synthesized prose drifts in ways the formatter has to absorb:
- Inline ## headers sometimes appear in synthesizer output. They need to become bold-prefixed paragraphs in mrkdwn, not raw
##characters. - Duplicate body headings — the LLM occasionally repeats the section title at the top of the body. The formatter strips the dup.
- Rich-text bodies need normalization. Some markdown constructs that work in github-flavored markdown render badly in Slack; the formatter rewrites them.
- Ordered list numbering breaks in nested lists; the formatter fixes the numbering.
None of this is glamorous. All of it is what keeps the output looking professional in the actual user-visible surface. A model that produces beautiful markdown that renders badly in Slack is a worse outcome than a model that produces simpler text that renders cleanly.
What I’d do differently
Two regrets, both about premature optimization:
- I shipped Block Kit too early. The structured rendering was visually impressive in early demos and turned into a maintenance tax later. If I were starting over, I’d default to mrkdwn and add Block Kit only for the specific response types that genuinely benefit.
- I didn’t build greppable Splunk tokens from day one. Adding
SLACK_ACK_PRIMARY_POSTEDand friends later was easy. Tracing a double-reply incident before they existed was a nightmare. Wire them in early; you’ll thank yourself the first incident.
What I’d do the same:
- Layered idempotency from day one. Event-level dedup is the floor; everything else builds on it. Don’t ship without it.
- In-place progress updates. Editing the same Slack message is dramatically less noisy than posting status replies. Worth the implementation effort.
- Slack-mrkdwn-first formatting. The output is a Slack message. Optimize for that surface, not for the markdown standard.
Slack isn’t a thin layer over your AI system. It’s the interaction model. The model decisions cascade backward into the architecture: idempotency, progress, formatting, ephemerals, threads. Get those right and the AI gets to focus on being useful. Get them wrong and the AI feels broken even when it isn’t.
More like this in the newsletter.
Practical notes on agentic AI for platform engineering. No hype. No spam.
Leave a Reply