Setup
1. Create a Slack App
- Go to api.slack.com/apps and click Create New App
- Choose From scratch, name your app, and select a workspace
2. Enable Socket Mode
- Go to Settings → Socket Mode and enable it
- Generate an App-Level Token with the
connections:writescope (starts withxapp-)
3. Add Bot Token Scopes
Go to OAuth & Permissions → Scopes → Bot Token Scopes and add:4. Subscribe to Events
Go to Event Subscriptions → Subscribe to bot events and add:message.im— Direct messagesapp_mention— @mentions in channelsmessage.channels— Channel messages (if you want thread replies)
5. Install and Run
Install the app to your workspace, then copy the Bot User OAuth Token (starts withxoxb-).
Installation
slack-bolt and aiohttp as dependencies.
SlackInterface Parameters
Authentication
str
required
Slack Bot User OAuth Token (
xoxb-...).str
Slack App-Level Token (
xapp-...). Required when mode="socket".str
Signing secret for request verification. Required when
mode="http".Receiver Mode
str
default:"socket"
How the bot receives events.
"socket" for development (WebSocket, no public URL needed), "http" for production (Events API, requires public URL).HTTP Events API Settings
str
default:"/slack/events"
URL path for the Events API endpoint (HTTP mode only).
str
default:"/slack/interactions"
URL path for interactive components (HTTP mode only).
Channel Behavior
bool
default:true
Respond when @mentioned in channels.
bool
default:true
Respond to direct messages.
bool
default:true
Respond when a user replies in a thread the bot started.
bool
default:true
Always reply in a thread when in channels (keeps channels tidy).
bool
default:false
Reply in threads in DMs. When
false, replies appear as top-level DM messages.Typing Indicators
str
default:"hourglass_flowing_sand"
Emoji reaction added while the agent processes. Set to
"" to disable.str
default:""
Emoji reaction added when the agent finishes. Set to
"" to disable.Text Formatting
bool
default:true
Automatically convert standard Markdown to Slack mrkdwn format (
**bold** → *bold*, [text](url) → <url|text>, etc.).int
default:40000
Maximum message length. Messages exceeding this are split at paragraph/sentence boundaries.
Access Control
List[str]
Only accept messages from these Slack user IDs. All users allowed if not set.
List[str]
Only accept messages from these channel IDs. All channels allowed if not set.
Rate Limiting & Timeouts
int
default:3
Maximum retries for Slack API calls on rate limit (429) responses.
float
HTTP connection timeout in seconds.
float
HTTP request timeout in seconds.
Slash Commands
Dict[str, str]
Slash commands to register. Maps command name to description. Commands are routed through the agent pipeline by default.
bool
default:true
Whether slash commands are sent to the agent. When
false, commands only dispatch to registered callbacks.Socket Mode (Development)
Socket Mode uses a WebSocket connection — no public URL, no HTTPS, no firewall configuration. Ideal for development.HTTP Events API (Production)
For production, use HTTP mode with Slack’s Events API. Events are pushed to your server over HTTPS.- A publicly accessible HTTPS URL
- The signing secret from your app’s Basic Information page
- Event subscriptions configured to point at your URL
Threading
The Slack interface automatically manages thread context:- Channel messages: Replies always go to a thread (when
thread_replies_in_channel=True) - Thread replies: When a user replies in a bot thread, the conversation continues in that thread with full history
- DMs: By default, replies appear as top-level messages (set
thread_replies_in_dm=Truefor threaded DMs)
Media Support
The interface handles Slack file uploads automatically:
Files shared in messages are downloaded from Slack and passed to the agent’s
images, audio, and files parameters.
Block Kit Interactions
Slash Commands
Register slash commands that route through the agent:You must also register slash commands in your Slack app settings at Features → Slash Commands. The
slash_commands parameter tells the interface to listen for them.Custom Command Handlers
Handle commands with custom logic instead of (or alongside) the agent:Buttons and Actions
Register handlers for interactive components:Modals
Open and handle modal dialogs:Shortcuts
Handle global and message shortcuts:Reactions
React to emoji reactions:App Home Tab
Publish a custom App Home tab:Block Kit Builders
Theformatter module provides pure-dict builders for Slack’s Block Kit — no SDK dependency needed:
Additional API Methods
The interface provides methods beyond basic messaging:Access Control
Restrict who can interact with the bot:Agent with Tools and Memory
Error Handling
The Slack interface maps API errors to the standard exception hierarchy:
When an error occurs during message processing, the configured
error_message is sent to the user, and all on_error hooks are invoked.