> ## 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 Search & Media Tools

> Run SlackContextProvider with Gemini sub-agents, enabling search_messages and opt-in media tools for file download and upload.

This example uses Gemini as the sub-agent model for Slack operations, while the outer agent uses a different model. This pattern is useful when you want faster/cheaper tool calls but stronger reasoning on top.

```python slack_search_media.py theme={null}
"""
Slack Search & Media Tools
==========================

Demonstrates SlackContextProvider with:

- **search_messages** — Search using the legacy API (works with user
  tokens `xoxp-`). Both bot and assisted read agents now have this
  enabled alongside `search_workspace`.
- **enable_media_tools** — Opt-in file handling:
  - `download_file` on read agents (fetch images/files for multimodal)
  - `upload_file` on write agent (post generated content)

This example uses Gemini as the sub-agent model for Slack operations,
while the outer agent uses a different model. This pattern is useful
when you want faster/cheaper tool calls but stronger reasoning on top.

Requires:
    GOOGLE_API_KEY
    SLACK_BOT_TOKEN  (xoxb-) — uses channel history, no search

Optional:
    SLACK_USER_TOKEN (xoxp-) — enables search_messages API

With a bot token, search_messages returns `not_allowed_token_type` and
the agent falls back to get_channel_history. With a user token, both
search methods are available.

Usage:
    python cookbook/12_context/06_slack_search_media.py
"""

from __future__ import annotations

import asyncio

from agno.agent import Agent
from agno.context.slack import SlackContextProvider
from agno.models.google import Gemini

slack = SlackContextProvider(
    model=Gemini(id="gemini-3.5-flash"),
    enable_media_tools=True,
)

agent = Agent(
    model=Gemini(id="gemini-3.5-flash"),
    tools=slack.get_tools(),
    instructions=slack.instructions(),
    markdown=True,
)


async def main() -> None:
    print(f"slack.status() = {slack.status()}\n")

    search_prompt = "Search Slack for recent discussions about 'deployment'. Summarize the top 3 results."
    print(f"> {search_prompt}\n")
    await agent.aprint_response(search_prompt)


if __name__ == "__main__":
    asyncio.run(main())
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U "agno[slack]" google-genai
```

**2. Export environment variables**

```bash Mac/Linux theme={null}
export GOOGLE_API_KEY="your_google_api_key_here"
export SLACK_BOT_TOKEN="your_slack_bot_token_here"
```

```bash Windows theme={null}
$Env:GOOGLE_API_KEY="your_google_api_key_here"
$Env:SLACK_BOT_TOKEN="your_slack_bot_token_here"
```

**3. Run the example**

Save the code above as `slack_search_media.py`, then run:

```bash theme={null}
python slack_search_media.py
```

Full source: [cookbook/12\_context/06\_slack\_search\_media.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/12_context/06_slack_search_media.py)


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