# Running Multiple AI Agents as Slack Teammates via OpenClaw

> Source: <https://gist.github.com/rafaelquintanilha/9ca5ae6173cd0682026754cfefe26d3f>
> Published: 2026-02-24 19:05:06+00:00

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.
Use one Slack app/bot per agent identity. For example, if you have four agents:
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.
- Slack workspace admin rights (or the ability to create and install apps).
- OpenClaw gateway running on a machine that stays online.
- Existing agent IDs configured in OpenClaw (e.g.
main
,agent-2
,agent-3
…). - For each Slack app:
- Bot token:
xoxb-...
- App-level token:
xapp-...
(Socket Mode +connections:write
scope)
- Bot token:
Repeat this for every agent you want on Slack.
- Go to https://api.slack.com/apps.
- Click Create New App → From scratch.
- Give it a name (e.g.
Alice
) and select your workspace.
- In the left menu, click Socket Mode.
- Enable Socket Mode.
- Click Generate Token and Scopes.
- Add scope:
connections:write
. - Save the generated App-Level Token (
xapp-...
).
- Left menu: OAuth & Permissions.
- Under Bot Token Scopes, add:
chat:write
app_mentions:read
channels:read
,channels:history
groups:history
im:history
,mpim:history
users:read
assistant:write
- Click Install to Workspace (or Reinstall after scope changes).
- 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.
- Left menu: Event Subscriptions → enable events.
- Subscribe to bot events:
app_mention
message.channels
message.groups
message.im
message.mpim
- 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
In Slack, in each channel where the bot should participate:
/invite @Alice
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
.
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 causemissing_scope
warnings and can break routing.
{
"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" } }
]
}
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
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.
DM any bot directly in Slack. Context is isolated per agent/session.
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
You don't need to copy-paste between agents. Keep everything in the same Slack thread:
- Tag one agent with the first ask:
@Carla analyze these metrics and summarize the key signal.
- Wait for the reply.
- 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.
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.
Note: the very first message after setup can occasionally produce a duplicate reply. This is a known edge case and typically doesn't recur.
After full setup:
openclaw channels status --probe
openclaw doctor
- DM each bot individually and confirm it replies.
- In the team channel, mention each bot once and confirm routing.
- Test thread handoff: ask one bot, then tag another in the same thread.
- Test orchestration: ask the primary agent to delegate a task to a specialist.
