Prerequisites
Example
The following agent sends a message to a Slack channel, lists channels, and retrieves message history.cookbook/14_tools/slack_tools.py
Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
token | Optional[str] | None | Slack API token. Falls back to SLACK_TOKEN env var. |
markdown | bool | True | Enable Slack mrkdwn formatting in messages. |
output_directory | Optional[str] | None | Directory to save downloaded/uploaded files locally. |
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. Only works through the Slack interface (needs action_token). |
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 all tools. Overrides individual flags. |
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. |
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() | List all channels in the workspace. |
get_channel_history(channel, limit=100) | Get message history from a channel. |
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. Only works through the Slack interface. |
get_thread(channel, thread_ts, limit=20) | Get all messages in a thread by parent timestamp. Capped by thread_message_limit. |
list_users(limit=100) | List all users in the workspace. |
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. |
Developer Resources
Slack Interface
Streaming, sessions, file handling, and behavior details.
Source Code
View the SlackTools implementation on GitHub.