> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Slack

## Prerequisites

The following example requires the `slack-sdk` library.

```shell theme={null}
pip install openai slack-sdk
```

Get a Slack token from [here](https://api.slack.com/tutorials/tracks/getting-a-token).

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

## Example

The following agent will use Slack to send a message to a channel, list all channels, and get the message history of a specific channel.

```python cookbook/tools/slack_tools.py theme={null}
import os

from phi.agent import Agent
from phi.tools.slack import SlackTools


slack_tools = SlackTools()

agent = Agent(tools=[slack_tools], show_tool_calls=True)

# Example 1: Send a message to a Slack channel
agent.print_response("Send a message 'Hello from Phi!' 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`               | `str`  | -       | Slack API token for authentication                                  |
| `send_message`        | `bool` | `True`  | Enables the functionality to send messages to Slack channels        |
| `list_channels`       | `bool` | `True`  | Enables the functionality to list available Slack channels          |
| `get_channel_history` | `bool` | `True`  | Enables the functionality to retrieve message history from channels |

## Toolkit Functions

| Function              | Description                                         |
| --------------------- | --------------------------------------------------- |
| `send_message`        | Sends a message to a specified Slack channel        |
| `list_channels`       | Lists all available channels in the Slack workspace |
| `get_channel_history` | Retrieves message history from a specified channel  |

## Information

* View on [Github](https://github.com/agno-agi/phidata/blob/main/phi/tools/slack.py)
