Skip to content

Instantly share code, notes, and snippets.

@rafaelquintanilha
Created February 24, 2026 19:05
Show Gist options
  • Select an option

  • Save rafaelquintanilha/9ca5ae6173cd0682026754cfefe26d3f to your computer and use it in GitHub Desktop.

Select an option

Save rafaelquintanilha/9ca5ae6173cd0682026754cfefe26d3f to your computer and use it in GitHub Desktop.
Running Multiple AI Agents as Slack Teammates via OpenClaw

Running Multiple AI Agents as Slack Teammates via OpenClaw

Goal: Run multiple AI agents as real Slack teammates — each with its own identity, able to DM independently or participate in shared channels — while keeping orchestration centralized through one primary agent.

Architecture

Use one Slack app/bot per agent identity. For example, if you have four agents:

Agent role OpenClaw agent ID Slack bot name
Primary orchestrator main Alice
Creative/strategy agent-2 Bob
Analytics/data agent-3 Carla
Engineering agent-4 Dave

Each Slack app maps to one accountId in channels.slack.accounts, and bindings route each account to its OpenClaw agent.

This gives each agent true individual DMs plus group-chat presence in shared channels.

Adapt the number of bots to however many agents you have. The pattern is the same for 2 or 10.


What you need

  1. Slack workspace admin rights (or the ability to create and install apps).
  2. OpenClaw gateway running on a machine that stays online.
  3. Existing agent IDs configured in OpenClaw (e.g. main, agent-2, agent-3…).
  4. For each Slack app:
    • Bot token: xoxb-...
    • App-level token: xapp-... (Socket Mode + connections:write scope)

Step-by-step: creating one Slack app

Repeat this for every agent you want on Slack.

Step 1 — Create the app

  1. Go to https://api.slack.com/apps.
  2. Click Create New App → From scratch.
  3. Give it a name (e.g. Alice) and select your workspace.

Step 2 — Enable Socket Mode and get the App token (xapp-...)

  1. In the left menu, click Socket Mode.
  2. Enable Socket Mode.
  3. Click Generate Token and Scopes.
  4. Add scope: connections:write.
  5. Save the generated App-Level Token (xapp-...).

Step 3 — Add OAuth scopes and get the Bot token (xoxb-...)

  1. Left menu: OAuth & Permissions.
  2. Under Bot Token Scopes, add:
    • chat:write
    • app_mentions:read
    • channels:read, channels:history
    • groups:history
    • im:history, mpim:history
    • users:read
    • assistant:write
  3. Click Install to Workspace (or Reinstall after scope changes).
  4. Copy the Bot User OAuth Token (xoxb-...).

If assistant:write doesn't appear in the scope list, go to App Settings → Agents & AI Apps, enable it, then return to OAuth & Permissions.

Step 4 — Subscribe to events and enable DMs

  1. Left menu: Event Subscriptions → enable events.
  2. Subscribe to bot events:
    • app_mention
    • message.channels
    • message.groups
    • message.im
    • message.mpim
  3. Left menu: App Home → enable Messages Tab (required for DMs to work).

Optional events (enable if your agents need reactions, pins, or file handling):

  • reaction_added, reaction_removed
  • pin_added, pin_removed
  • member_joined_channel, member_left_channel

Optional scopes (same context):

  • reactions:read, reactions:write
  • pins:read, pins:write
  • files:read, files:write
  • commands

Step 5 — Invite the bot to your channel(s)

In Slack, in each channel where the bot should participate:

/invite @Alice

OpenClaw configuration

1) Initial single-bot test (recommended before going multi-bot)

Before configuring all bots, test with one. Patch your config:

{
  "channels": {
    "slack": {
      "enabled": true,
      "mode": "socket",
      "botToken": "xoxb-YOUR-FIRST-BOT-TOKEN",
      "appToken": "xapp-YOUR-FIRST-APP-TOKEN",
      "groupPolicy": "allowlist",
      "streaming": false,
      "replyToMode": "all",
      "channels": {
        "C_YOUR_CHANNEL_ID": {
          "allow": true,
          "requireMention": false
        }
      }
    }
  }
}

Restart and validate:

openclaw gateway restart
openclaw status
openclaw doctor --non-interactive

Expected: Slack ON/OK.


2) Multi-bot: one account per agent

Once one bot is stable, expand to multiple accounts:

{
  "channels": {
    "slack": {
      "enabled": true,
      "mode": "socket",
      "dmPolicy": "pairing",
      "groupPolicy": "allowlist",
      "streaming": false,
      "replyToMode": "all",
      "channels": {
        "C_YOUR_TEAM_CHANNEL_ID": {
          "allow": true,
          "requireMention": true
        }
      },
      "accounts": {
        "alice": { "name": "Alice", "botToken": "xoxb-...", "appToken": "xapp-..." },
        "bob":   { "name": "Bob",   "botToken": "xoxb-...", "appToken": "xapp-..." },
        "carla": { "name": "Carla", "botToken": "xoxb-...", "appToken": "xapp-..." },
        "dave":  { "name": "Dave",  "botToken": "xoxb-...", "appToken": "xapp-..." }
      }
    }
  }
}

Use channel IDs (C_...), not channel names (#general). Names cause missing_scope warnings and can break routing.


3) Bind each Slack account to one OpenClaw agent

{
  "bindings": [
    { "agentId": "main",    "match": { "channel": "slack", "accountId": "alice" } },
    { "agentId": "agent-2", "match": { "channel": "slack", "accountId": "bob" } },
    { "agentId": "agent-3", "match": { "channel": "slack", "accountId": "carla" } },
    { "agentId": "agent-4", "match": { "channel": "slack", "accountId": "dave" } }
  ]
}

4) Enable agent-to-agent orchestration

This lets the primary agent delegate to specialists and lets them share session visibility:

{
  "tools": {
    "agentToAgent": {
      "enabled": true,
      "allow": ["main", "agent-2", "agent-3", "agent-4"]
    },
    "sessions": {
      "visibility": "all"
    }
  },
  "agents": {
    "list": [
      {
        "id": "main",
        "subagents": {
          "allowAgents": ["agent-2", "agent-3", "agent-4"]
        }
      }
    ]
  }
}

Restart:

openclaw gateway restart

5) Cross-bot context in threads (optional but recommended)

If you want agents to hand off context within the same Slack thread — e.g. agent-3 analyzes data, then agent-2 continues the conversation referencing that output — add this:

{
  "channels": {
    "slack": {
      "historyLimit": 80,
      "thread": {
        "historyScope": "thread",
        "inheritParent": true,
        "initialHistoryLimit": 50
      },
      "channels": {
        "C_YOUR_TEAM_CHANNEL_ID": {
          "allow": true,
          "requireMention": true,
          "allowBots": true
        }
      }
    }
  }
}
  • allowBots: true — lets each agent consume other bots' messages as context.
  • requireMention: true — prevents bot loops (each bot only responds when explicitly tagged).
  • thread.* + historyLimit — keeps full continuity inside a Slack thread.

How to use it

Individual DMs

DM any bot directly in Slack. Context is isolated per agent/session.

Team channel: mention-driven

Put all bots in one channel with requireMention: true. Call each one explicitly:

@Alice summarize the thread above
@Bob critique this positioning copy
@Carla pull the numbers for last week
@Dave propose implementation steps

Thread handoff between agents

You don't need to copy-paste between agents. Keep everything in the same Slack thread:

  1. Tag one agent with the first ask:

    @Carla analyze these metrics and summarize the key signal.

  2. Wait for the reply.
  3. In the same thread, tag the next agent:

    @Bob use Carla's analysis above and propose the communication angle.

With allowBots and thread history configured, the second agent sees the first agent's output as context automatically.

Orchestrator mode (recommended for complex tasks)

Use your primary agent (main) as a coordinator:

  • Ask it in DM or channel.
  • It delegates to specialists via sessions_spawn(agentId=...).
  • It returns one synthesized answer.

This keeps the channel clean while using specialist depth under the hood.


Known issues and fixes

Symptom Cause Fix
Bot shows "reviewing findings" then goes silent Stream stop error (missing_recipient_team_id) Set streaming: false
Duplicate replies Duplicate channel entries (by name AND by ID) Use only channel ID keys, remove name-based keys
Channel warnings (missing_scope) Channel referenced by name instead of ID Route by channel ID in the allowlist
Bot never responds in channel groupPolicy or channel not in allowlist Check groupPolicy: "allowlist" and that the channel ID is listed

Note: the very first message after setup can occasionally produce a duplicate reply. This is a known edge case and typically doesn't recur.


Verification checklist

After full setup:

  1. openclaw channels status --probe
  2. openclaw doctor
  3. DM each bot individually and confirm it replies.
  4. In the team channel, mention each bot once and confirm routing.
  5. Test thread handoff: ask one bot, then tag another in the same thread.
  6. Test orchestration: ask the primary agent to delegate a task to a specialist.
@gotexis
Copy link

gotexis commented Feb 27, 2026

Being scratching my head why slack always route to the main agent, then I googled your post.

So looks like multiple agents cannot share a single bot / app, right?

Is the following possible:

1 Slack App / 1 Bot / multiple slack channels / multiple openclaw agents

  • Slack Channel #life => add @openclaw => route to life agent
  • Slack Channel #work => add @openclaw => route to work agent

@rafaelquintanilha
Copy link
Author

Being scratching my head why slack always route to the main agent, then I googled your post.

So looks like multiple agents cannot share a single bot / app, right?

Is the following possible:

1 Slack App / 1 Bot / multiple slack channels / multiple openclaw agents

  • Slack Channel #life => add @openclaw => route to life agent
  • Slack Channel #work => add @openclaw => route to work agent

I don't think so, it's one bot for agent and you can ask agents to orchestrate among themselves. You can of course add whatever bot you would like in any channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment