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

# Multiple Slack Bot Instances

> Deploy multiple agents as separate Slack bots in one workspace.

Deploy multiple agents as separate Slack bots in one workspace. Each bot has its own identity, token, and signing secret.

```python multiple_instances.py theme={null}
"""
Multiple Slack Bot Instances
============================

Deploy multiple agents as separate Slack bots in one workspace.
Each bot has its own identity, token, and signing secret.

Setup:
  1. Create two Slack apps at https://api.slack.com/apps
  2. Install both apps to the same workspace
  3. Set each app's Event Subscription URL to its prefix:
       - @ResearchBot  ->  https://myapp.com/research/events
       - @AnalystBot   ->  https://myapp.com/analyst/events
  4. Set environment variables (or pass tokens directly):
       RESEARCH_SLACK_TOKEN, RESEARCH_SLACK_SIGNING_SECRET
       ANALYST_SLACK_TOKEN,  ANALYST_SLACK_SIGNING_SECRET

Slack scopes (per app): app_mentions:read, assistant:write, chat:write, im:history
"""

from os import getenv

from agno.agent import Agent
from agno.db.sqlite.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os.app import AgentOS
from agno.os.interfaces.slack import Slack
from agno.tools.websearch import WebSearchTools

# ---------------------------------------------------------------------------
# Agents
# ---------------------------------------------------------------------------

agent_db = SqliteDb(session_table="agent_sessions", db_file="tmp/persistent_memory.db")

research_agent = Agent(
    name="Research Agent",
    model=OpenAIChat(id="gpt-5-mini"),
    tools=[WebSearchTools()],
    db=agent_db,
    add_history_to_context=True,
    num_history_runs=3,
    add_datetime_to_context=True,
)

analyst_agent = Agent(
    name="Analyst Agent",
    model=OpenAIChat(id="gpt-5-mini"),
    instructions=[
        "You are a data analyst. Help users interpret data and create insights."
    ],
    db=agent_db,
    add_history_to_context=True,
    num_history_runs=3,
    add_datetime_to_context=True,
)

# ---------------------------------------------------------------------------
# AgentOS — each Slack interface gets its own credentials
# ---------------------------------------------------------------------------

agent_os = AgentOS(
    agents=[research_agent, analyst_agent],
    interfaces=[
        Slack(
            agent=research_agent,
            prefix="/research",
            token=getenv("RESEARCH_SLACK_TOKEN"),
            signing_secret=getenv("RESEARCH_SLACK_SIGNING_SECRET"),
        ),
        Slack(
            agent=analyst_agent,
            prefix="/analyst",
            token=getenv("ANALYST_SLACK_TOKEN"),
            signing_secret=getenv("ANALYST_SLACK_SIGNING_SECRET"),
        ),
    ],
)
app = agent_os.get_app()


# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------

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

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[os,slack]" ddgs openai
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export ANALYST_SLACK_SIGNING_SECRET="your_analyst_slack_signing_secret_here"
      export ANALYST_SLACK_TOKEN="your_analyst_slack_token_here"
      export OPENAI_API_KEY="your_openai_api_key_here"
      export RESEARCH_SLACK_SIGNING_SECRET="your_research_slack_signing_secret_here"
      export RESEARCH_SLACK_TOKEN="your_research_slack_token_here"
      ```

      ```bash Windows theme={null}
      $Env:ANALYST_SLACK_SIGNING_SECRET="your_analyst_slack_signing_secret_here"
      $Env:ANALYST_SLACK_TOKEN="your_analyst_slack_token_here"
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      $Env:RESEARCH_SLACK_SIGNING_SECRET="your_research_slack_signing_secret_here"
      $Env:RESEARCH_SLACK_TOKEN="your_research_slack_token_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Configure Slack">
    Complete [Slack setup](/agent-os/interfaces/slack/setup): create and install the app, expose the server through public HTTPS, and add the scopes listed in the example. The default event request URL is `<public-url>/slack/events`; HITL examples also use `<public-url>/slack/interactions` for interactivity. Use any custom prefix shown in the example instead of `/slack`.
  </Step>

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

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

Full source: [cookbook/05\_agent\_os/interfaces/slack/multiple\_instances.py](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/interfaces/slack/multiple_instances.py)
