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

# Slack Search & Media Tools

> This example uses Gemini as the sub-agent model for Slack operations, while the outer agent uses a different model.

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

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno google-genai
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export GOOGLE_API_KEY="your_google_api_key_here"
      export SLACK_BOT_TOKEN="your_slack_bot_token_here"
      export SLACK_TOKEN="your_slack_token_here"
      export SLACK_USER_TOKEN="your_slack_user_token_here"
      ```

      ```bash Windows theme={null}
      $Env:GOOGLE_API_KEY="your_google_api_key_here"
      $Env:SLACK_BOT_TOKEN="your_slack_bot_token_here"
      $Env:SLACK_TOKEN="your_slack_token_here"
      $Env:SLACK_USER_TOKEN="your_slack_user_token_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `slack_search_media.py`, then run:

    ```bash theme={null}
    python slack_search_media.py
    ```
  </Step>
</Steps>

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