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

# Slack

> Host agents as Slack Applications.

Use the Slack interface to serve Agents, Teams, or Workflows on Slack. It mounts Slack event routes on a FastAPI app and sends responses back to Slack threads.

## Setup Steps

Follow the Slack setup guide in the [cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/interfaces/slack/README.md).

Required configuration:

* `SLACK_TOKEN` (Bot User OAuth Token)
* `SLACK_SIGNING_SECRET` (App Signing Secret)
* An ngrok tunnel (for local development) and event subscriptions pointing to `/slack/events`

## Example Usage

Create an agent, expose it with the `Slack` interface, and serve via `AgentOS`:

```python basic.py theme={null}
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.slack import Slack

basic_agent = Agent(
    name="Basic Agent",
    model=OpenAIResponses(id="gpt-5.2"), # Ensure OPENAI_API_KEY is set
    add_history_to_context=True,
    num_history_runs=3,
    add_datetime_to_context=True,
)

agent_os = AgentOS(
    agents=[basic_agent],
    interfaces=[Slack(agent=basic_agent)],
)
app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="basic:app", port=8000, reload=True)
```

A complete example is available at `cookbook/05_agent_os/interfaces/slack/basic.py`.

## Core Components

* `Slack` (interface): Wraps an Agno `Agent`, `Team`, or `Workflow` for Slack integration via FastAPI.
* `AgentOS.serve`: Serves the FastAPI app using Uvicorn.

## `Slack` Interface

Main entry point for Agno Slack applications.

### Initialization Parameters

| Parameter                | Type                             | Default         | Description                                                                                                               |
| ------------------------ | -------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `agent`                  | `Optional[Agent]`                | `None`          | Agno `Agent` instance.                                                                                                    |
| `team`                   | `Optional[Team]`                 | `None`          | Agno `Team` instance.                                                                                                     |
| `workflow`               | `Optional[Workflow]`             | `None`          | Agno `Workflow` instance.                                                                                                 |
| `prefix`                 | `str`                            | `"/slack"`      | Custom FastAPI route prefix for the Slack interface.                                                                      |
| `tags`                   | `Optional[List[str]]`            | `None`          | FastAPI route tags for API documentation. Defaults to `["Slack"]` if not provided.                                        |
| `reply_to_mentions_only` | `bool`                           | `True`          | When `True`, respond to @mentions in channels and all direct messages. When `False`, respond to all channel messages too. |
| `token`                  | `Optional[str]`                  | `None`          | Slack Bot User OAuth Token (`xoxb-...`). If omitted, the interface reads from environment configuration.                  |
| `signing_secret`         | `Optional[str]`                  | `None`          | Slack signing secret used to verify request signatures.                                                                   |
| `streaming`              | `bool`                           | `True`          | Enable Slack `chat_stream` responses and event-driven streaming updates.                                                  |
| `loading_messages`       | `Optional[List[str]]`            | `None`          | Optional rotating loading messages shown while processing streamed runs.                                                  |
| `task_display_mode`      | `str`                            | `"plan"`        | Task card display mode used by Slack streaming UI.                                                                        |
| `loading_text`           | `str`                            | `"Thinking..."` | Thread status text shown before streamed output starts.                                                                   |
| `suggested_prompts`      | `Optional[List[Dict[str, str]]]` | `None`          | Suggested prompts sent when Slack starts an assistant thread.                                                             |
| `ssl`                    | `Optional[SSLContext]`           | `None`          | Custom SSL context for Slack SDK HTTP requests.                                                                           |
| `buffer_size`            | `int`                            | `100`           | Stream buffer size for Slack `chat_stream`.                                                                               |
| `max_file_size`          | `int`                            | `1073741824`    | Maximum uploaded/downloaded file size in bytes (default 1 GB).                                                            |

Provide `agent`, `team`, or `workflow`.

Use different `prefix`, `token`, and `signing_secret` values when mounting multiple Slack interface instances on one FastAPI app.

### Key Method

| Method       | Parameters | Return Type | Description                                        |
| ------------ | ---------- | ----------- | -------------------------------------------------- |
| `get_router` | None       | `APIRouter` | Returns the FastAPI router and attaches endpoints. |

## Endpoints

Mounted under the `/slack` prefix:

### `POST /slack/events`

* Handles all Slack events (URL verification, messages, app mentions)
* Verifies Slack signature on each request
* Uses thread timestamps as session IDs for per-thread context
* Streams responses back into the originating thread (splits long messages)

## Testing the Integration

1. Run the app locally: `python <my-app>.py` (ensure ngrok is running)
2. Invite the bot to a channel: `/invite @YourAppName`
3. Mention the bot in a channel: `@YourAppName hello`
4. Open a DM with the bot and send a message

## Troubleshooting

* Verify `SLACK_TOKEN` and `SLACK_SIGNING_SECRET` are set
* Confirm the bot is installed and invited to the channel
* Check ngrok URL and event subscription path (`/slack/events`)
* Review application logs for signature failures or permission errors
