> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 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

```shell theme={null}
uv pip install -U "agno[slack]" openai
```

```shell theme={null}
export SLACK_TOKEN=***
```

## 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, so `SlackTools()` needs no configuration.

```python theme={null}
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 all channels in the Slack workspace
agent.print_response("List all 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. 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`. |

> [!NOTE]
>
> 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.

## 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)` | List all channels in the workspace. Set `include_private=True` to include 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. 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. |

> [!TIP]
>
> `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.

SlackTools also exposes `download_file_bytes(file_id)` for programmatic use. It returns raw bytes and is not registered as an agent tool.

## Developer Resources

> **[Examples](https://agno-v2.mintlify.site/examples/tools/slack-tools.md)**
>
> Tool configurations: all tools, a subset, and read-only.

> **[Slack Interface](https://agno-v2.mintlify.site/agent-os/interfaces/slack/introduction.md)**
>
> Streaming, sessions, file handling, and behavior details.

> **[Source Code](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/slack.py)**
>
> SlackTools implementation: methods, defaults, and instruction building.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.