Slack
SlackTools enables an Agent to message, search, and manage Slack channels, threads, files, and users through 12 configurable methods.
SlackTools enable an Agent to interact with the Slack API. 12 methods cover messaging, channels, file management, search, threads, and user lookup.
Prerequisites
uv pip install -U "agno[slack]" openaiexport SLACK_TOKEN=***Set OpenAI Key
Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
export OPENAI_API_KEY=sk-***Install your Slack app into the workspace. For the example, grant the bot chat:write, channels:read, and channels:history, and invite it to the target channel. Use real channel names and IDs. Private-channel access needs the corresponding groups:read/groups:history scopes and membership; file operations need files:read/files:write, and user lookup needs users:read. Add scopes and reinstall the app when enabling those operations.
Example
The following agent sends a message to a Slack channel, lists channels, and retrieves message history. The messaging, channel, and file tools are enabled by default, with SlackTools(); credentials, scopes, and channel access still need the setup above.
from agno.agent import Agent
from agno.tools.slack import SlackTools
agent = Agent(tools=[SlackTools()])
# Example 1: Send a message to a Slack channel
agent.print_response("Send a message 'Hello from Agno!' to the channel #general", markdown=True)
# Example 2: List channels visible to this token
agent.print_response("List accessible nonarchived channels in our Slack workspace", markdown=True)
# Example 3: Get the message history of a specific channel by channel ID
agent.print_response("Get the last 10 messages from the channel 1231241", markdown=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
token | Optional[str] | None | Slack API token. Falls back to SLACK_TOKEN env var. |
user_token | Optional[str] | None | User token (xoxp-) used by search_messages. Falls back to SLACK_USER_TOKEN env var, or to token when it is a user token. |
markdown | bool | True | Enable Slack mrkdwn formatting in messages. |
output_directory | Optional[str] | None | Directory to save downloaded files locally. Setting this implies save_downloads=True. |
save_downloads | bool | False | When True, save downloaded files to disk (in output_directory or current directory). When False, return file content as base64. |
enable_send_message | bool | True | Enable send_message tool. |
enable_send_message_thread | bool | True | Enable send_message_thread tool. |
enable_list_channels | bool | True | Enable list_channels tool. |
enable_get_channel_history | bool | True | Enable get_channel_history tool. |
enable_upload_file | bool | True | Enable upload_file tool. |
enable_download_file | bool | True | Enable download_file tool. |
enable_search_messages | bool | False | Enable search_messages tool. Requires a user token and the search:read OAuth scope. |
enable_search_workspace | bool | False | Enable search_workspace tool. Uses Slack's assistant.search.context API. Requires search:read.public, search:read.files, and search:read.users bot scopes. Requires run_context.metadata["action_token"], supplied by compatible Slack event handling or the caller; see the integration limits below. |
enable_get_thread | bool | False | Enable get_thread tool. |
enable_list_users | bool | False | Enable list_users tool. |
enable_get_user_info | bool | False | Enable get_user_info tool. |
enable_get_channel_info | bool | False | Enable get_channel_info tool. |
all | bool | False | Enable tools regardless of flags; search_messages still requires a user client. |
ssl | Optional[SSLContext] | None | SSL context for the Slack WebClient. |
max_file_size | int | 1073741824 | Maximum file size in bytes for uploads and downloads (default 1 GB). |
thread_message_limit | int | 20 | Maximum number of messages to fetch in get_thread. |
When you do not pass instructions, SlackTools builds usage guidance from the enabled tools (when to reply in a thread, which search to use) and adds it to the agent's system prompt automatically.
Workspace search integration
The current Slack interface copies event.assistant_thread.action_token into run metadata. It does not read the top-level event.action_token used in Slack's current agent example. Events carrying only that top-level token reach search_workspace without the required credential and return a no-token error.
Slack's Real-time Search guide prohibits retaining data retrieved by that API. Agno's ordinary session persistence can retain raw tool results; the Slack Team interface also enables member-response storage. Configure and verify event-token handling and the complete storage path before enabling this search. The workspace-tools example keeps it disabled pending those integration changes.
Toolkit Functions
| Function | Description |
|---|---|
send_message(channel, text) | Send a message to a Slack channel. |
send_message_thread(channel, text, thread_ts) | Reply to a message thread in a channel. |
list_channels(include_private=False) | Paginate accessible, nonarchived public channels. Set include_private=True to include accessible private channels (requires groups:read scope). |
get_channel_history(channel, limit=100) | Get message history from a channel. Returns top-level messages only; use get_thread() to expand threads. |
upload_file(channel, content, filename, title?, initial_comment?, thread_ts?) | Upload a file to a channel with optional caption. |
download_file(file_id, dest_path?) | Download a file by file ID. Returns path or base64 content. |
search_messages(query, limit=20) | Search messages across the workspace. Requires a user token (bot tokens return not_allowed_token_type). |
search_workspace(query, content_types?, channel_types?, limit=10, include_context_messages=True) | Search messages, files, channels, and users across the workspace using Slack's Real-Time Search API. Requires an action_token in run-context metadata, supplied by compatible Slack event handling or the caller; see the integration limits above. |
get_thread(channel, thread_ts, limit=20) | Fetch one page of messages in a thread by parent timestamp. Capped by thread_message_limit. |
list_users(limit=100) | Fetch one page of workspace users. |
get_user_info(user_id) | Get detailed info about a user by user ID. |
get_channel_info(channel) | Get channel metadata: name, topic, purpose, member count, and visibility. |
search_messages supports Slack search modifiers: from:@user, in:#channel, has:link, before:2024-01-01, after:2024-01-01. Combine them to narrow results.
History, thread, user-list, and message-search tools return bounded results from one request. They do not automatically exhaust provider pagination.
SlackTools also exposes download_file_bytes(file_id) for programmatic use. It returns raw bytes and is not registered as an agent tool.