Slack Adapter
Expose a Band agent as a Slack-native AI app
The SlackAdapter wraps an existing framework adapter (the “brain”, such as AnthropicAdapter or LangGraphAdapter) and bridges it into Slack. Mention the bot in a channel or DM and it replies in the thread, backed by your agent’s reasoning and the Band platform.
Unlike a gateway, the Slack adapter is a wrapper: one process, one Band agent identity. It decorates the inner adapter with Slack ingress and egress and relays messages between Slack threads and Band rooms in both directions.
Prerequisites
Before starting, complete the Setup tutorial:
- SDK installed
- Agent created on the platform
.envandagent_config.yamlconfigured
Install the Slack extra plus a brain adapter (Anthropic here):
The slack extra installs slack-sdk, starlette, uvicorn, and aiohttp.
Set Up the Slack App
The bridge expects an installed Slack app with the right scopes and events. A maintained manifest ships with the SDK at src/band/integrations/slack/templates/manifest.yaml.
Create the app from the manifest
In Slack, go to Create New App then From a manifest, and paste the bundled manifest.yaml. It declares:
- AI App (
assistant_view+assistant:write) so the assistant pane, status indicators, and Block Kit plan/task blocks render. - Thread-context scopes:
app_mentions:read,im:history,channels:history,groups:history,chat:write,users:read, pluschannels:read/groups:read/im:readto resolve channel names. - Events
app_mention,message.im, andassistant_thread_started. - Socket Mode enabled (no public URL or signing secret needed to start).
Install the app and grab tokens
Install the app to your workspace, then collect:
- Bot Token (
xoxb-...), always required. - App-Level Token (
xapp-...) with theconnections:writescope, required for Socket Mode. Generate it under Basic Information then App-Level Tokens. - Signing Secret, required only for HTTP transport.
Choose a Transport
The adapter supports two transports that share the same downstream pipeline, so status indicators, plan blocks, thread backfill, and session rehydration behave identically:
The constructor default is transport="http". The quickstart below uses Socket Mode because it needs no public URL.
Quickstart: Socket Mode Bot
Create slack_bot.py. This wraps an Anthropic brain and runs it as a Slack AI app over Socket Mode:
Set the required environment variables in .env:
Run it:
Mention the bot in a channel it belongs to, or DM it. It replies in the thread.
The adapter starts its Socket Mode websockets when the agent connects, and slack.close() shuts them down cleanly. Always close it in a finally block.
HTTP Transport
For production, use HTTP transport and mount the adapter’s router into your own ASGI app. Each SlackApp exposes a route at /{slug}/events.
Point your Slack app’s Event Subscriptions request URL at https://<your-public-host>/slack/dev/events. The router verifies Slack’s HMAC signature and handles URL verification and retry idempotency.
slack.router is only available for transport="http". Accessing it in Socket Mode raises RuntimeError.
How It Works
When a Slack user mentions the bot or DMs it:
- Thread binding - The adapter maps the Slack
channel:thread_ts(scoped by app slug) to a Band room, creating one if needed. A per-thread lock collapses concurrent events onto a single room. - Thread backfill - Each turn refetches
conversations.repliesso the brain sees the full thread history, including messages it missed while offline. - Reasoning - The Slack event is synthesized into a
PlatformMessageand passed to the inner adapter with REST-backed tools. - Reply - The brain’s reply is posted back into the originating Slack thread.
Two outbound tools
When a room is bound to a Slack thread, the brain sees two send tools and picks based on intent:
slack_send_messageposts a plain-text reply into the bound Slack thread. Use this for the user-facing answer. It does not post to the Band room.band_send_messagesends a real Band message to peers in the room (still requires at least one@mention). Use this to coordinate with other Band agents.
Status and progress
The adapter shows a thinking status via assistant.threads.setStatus while the brain works, and renders Block Kit plan and task blocks so tool-call progress is visible in Slack (capped at Slack’s 50-block limit with an overflow summary). Disable with show_tool_progress=False.
Session rehydration and context mirroring
The Slack thread binding is stored in the room’s bootstrap task event, so the bridge recovers thread context after a restart. By default each inbound Slack turn is also mirrored into the bound Band room as a context-only event (tagged slack_mirror) so the Band audit timeline reflects the Slack conversation. These mirrored events never loop back into the brain’s history. Disable with mirror_slack_context=False.
Multiple Slack Apps
One adapter can serve several Slack apps, each with its own bot token and route. Room lookup is keyed by app slug, so two apps sharing a channel:thread_ts tuple map to distinct rooms with no cross-workspace reply routing.
Configuration Options
SlackAdapter
SlackApp
The adapter validates token combinations at construction time. Missing a signing_secret for HTTP, or an app_token for Socket Mode, raises ValueError.
Operational Notes
The bot must be a channel member. Run /invite @your-bot in every channel it should read. Without membership, thread backfill fails with not_in_channel and the brain loses context.
Enable “Delayed Events” for production. Under the Slack app’s Event Subscriptions settings, turn on “Delayed Events” so Slack keeps retrying missed events hourly for 24h while the bridge is offline (the default is 2h). This is a GUI toggle with no manifest field, so it must be set manually after the app is created. See the Slack retry events changelog.