slack_bot.py
Install the dependency:
uv pip install 'agno[slack]'Setup
Create a Slack App
- Go to api.slack.com/apps and click Create New App
- Choose From scratch, give it a name, and select your workspace
- On the Basic Information page, copy the Signing Secret
Enable Agents & AI Apps
This is required for streaming task cards and suggested prompts.
- In the sidebar, click Agents & AI Apps
- Toggle Agent or Assistant to On
- Under Suggested Prompts, select Dynamic
- Click Save
Enabling this automatically adds the
assistant:write scope.Add OAuth Scopes
- In the sidebar, click OAuth & Permissions
- Under Scopes > Bot Token Scopes, add:
| Scope | Purpose |
|---|---|
app_mentions:read | Receive @mention events |
assistant:write | Streaming (task cards, suggested prompts) |
chat:write | Send messages and stream responses |
im:history | Read DM history for thread context |
files:read | Download files users send to the bot |
files:write | Upload response files (images, docs) |
- Click Install to Workspace and authorize the app
- Copy the Bot User OAuth Token (
xoxb-...)
Set Environment Variables
- Bot User OAuth Token: OAuth & Permissions
- Signing Secret: Basic Information > App Credentials
Subscribe to Events
- In the sidebar, click Event Subscriptions
- Toggle Enable Events to On
-
Set Request URL to your tunnel URL:
Your app must be running for Slack to verify the URL.
- Under Subscribe to bot events, add:
| Event | Purpose |
|---|---|
app_mention | Respond to @mentions in channels |
message.im | Respond to direct messages |
assistant_thread_started | Set suggested prompts on new threads |
- Click Save Changes
- Go to Install App and click Reinstall to Workspace
Enable App Home
- In the sidebar, click App Home
- Under Show Tabs, enable Messages Tab
- Check Allow users to send Slash commands and messages from the messages tab
Start a Tunnel
Slack needs a public HTTPS URL to deliver events:Copy the
https:// forwarding URL and paste it into the Event Subscriptions Request URL (Step 5). The free ngrok tier gives you a random subdomain that changes on restart.Scopes Reference
Add scopes based on the features your bot uses.Minimum (streaming bot that responds to mentions and DMs)
| Scope | Required For |
|---|---|
app_mentions:read | Receive @mention events in channels |
assistant:write | Streaming task cards, suggested prompts, thread titles |
channels:read | Resolve channel names (called on every inbound event) |
chat:write | Send messages and stream responses |
im:history | Read DM history for thread context |
File handling
| Scope | Required For |
|---|---|
files:read | Download files users attach to messages |
files:write | Upload images, audio, video, and files generated by agent tools |
SlackTools methods
| Scope | Required For |
|---|---|
channels:read | list_channels(), get_channel_info() |
channels:history | get_channel_history(), get_thread() in public channels |
groups:read | list_channels() for private channels |
groups:history | get_channel_history(), get_thread() in private channels |
search:read | search_messages() (requires user token) |
search:read.public | search_workspace() messages and channels |
search:read.files | search_workspace() files |
search:read.users | search_workspace() users |
users:read | list_users(), get_user_info() |
users:read.email | get_user_info() with email field |
Other features
| Scope | Required For |
|---|---|
users:read | resolve_user_identity=True on the Slack interface |
users:read.email | resolve_user_identity=True with email lookup |
channels:history | reply_to_mentions_only=False in public channels |
groups:history | reply_to_mentions_only=False in private channels |
Event subscriptions
| Event | Required For |
|---|---|
app_mention | Respond to @mentions in channels |
message.im | Respond to direct messages |
assistant_thread_started | Set suggested prompts on new threads |
message.channels | Respond to all public channel messages (reply_to_mentions_only=False) |
message.groups | Respond to all private channel messages (reply_to_mentions_only=False) |
Developer Resources
Slack Interface
Streaming, sessions, file handling, and behavior details.
Interface Reference
All parameters, endpoints, and event handling.
SlackTools
Give agents outbound Slack actions: messaging, search, files.
Deployment Templates
Production deployment guides for AWS, GCP, and Docker.