DEV Community

Hex
Hex

Posted on • Originally published at openclawplaybook.ai

How to Connect Your AI Agent to Slack (Complete Setup Guide)

Your AI agent lives on your machine. Your team lives in Slack. The gap between those two is where most "AI at work" experiments die — an agent nobody can talk to is an agent nobody uses.

OpenClaw's Slack integration bridges that gap. It connects your agent to Slack via either Socket Mode or HTTP Events API, giving your agent the ability to participate in DMs, channels, and threads like any other team member. Not a webhook that dumps text — a real conversational presence with access control, threading, reactions, and file handling.

This guide walks through the complete setup, from creating a Slack app to fine-tuning channel policies. By the end, your agent will be a Slack citizen.

Prerequisites

Before you start, you'll need:

  • OpenClaw installed and running — if you haven't done this yet, check out What is OpenClaw?
  • A Slack workspace where you have admin permissions (or can ask an admin to install apps)
  • 5-10 minutes — the setup is straightforward once you know the steps

Step 1: Create a Slack App

Head to api.slack.com/apps and click "Create New App". Choose "From a manifest" — it's faster than clicking through every permission screen manually.

Here's a manifest that covers everything OpenClaw needs:

{
  "display_information": {
    "name": "OpenClaw",
    "description": "Slack connector for OpenClaw"
  },
  "features": {
    "bot_user": {
      "display_name": "OpenClaw",
      "always_online": false
    },
    "app_home": {
      "messages_tab_enabled": true,
      "messages_tab_read_only_enabled": false
    },
    "slash_commands": [
      {
        "command": "/openclaw",
        "description": "Send a message to OpenClaw",
        "should_escape": false
      }
    ]
  },
  "oauth_config": {
    "scopes": {
      "bot": [
        "chat:write",
        "channels:history",
        "channels:read",
        "groups:history",
        "im:history",
        "im:read",
        "im:write",
        "mpim:history",
        "mpim:read",
        "mpim:write",
        "users:read",
        "app_mentions:read",
        "assistant:write",
        "reactions:read",
        "reactions:write",
        "pins:read",
        "pins:write",
        "emoji:read",
        "commands",
        "files:read",
        "files:write"
      ]
    }
  },
  "settings": {
    "socket_mode_enabled": true,
    "event_subscriptions": {
      "bot_events": [
        "app_mention",
        "message.channels",
        "message.groups",
        "message.im",
        "message.mpim",
        "reaction_added",
        "reaction_removed",
        "member_joined_channel",
        "member_left_channel",
        "channel_rename",
        "pin_added",
        "pin_removed"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

After creating the app, install it to your workspace. Slack will ask you to authorize the scopes — approve them. You'll get a Bot Token (xoxb-...) on the install confirmation page. Save it.

Step 2: Get Your Tokens

You need two tokens for Socket Mode (the recommended approach):

  1. Bot Token (xoxb-...) — found under OAuth & Permissions after installing the app
  2. App Token (xapp-...) — go to Basic Information → App-Level Tokens, click "Generate Token", name it anything, and add the connections:write scope

The Bot Token lets your agent send messages and read channels. The App Token opens the WebSocket connection that Slack uses to push events to your agent in real time.

Step 3: Configure OpenClaw

Add the Slack channel to your openclaw.json:

{
  "channels": {
    "slack": {
      "enabled": true,
      "mode": "socket",
      "appToken": "xapp-1-...",
      "botToken": "xoxb-..."
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Or use environment variables if you prefer keeping tokens out of config files:

SLACK_APP_TOKEN=xapp-1-...
SLACK_BOT_TOKEN=xoxb-...
Enter fullscreen mode Exit fullscreen mode

Config tokens take precedence over env vars. The env fallback only works for the default account.

Why Socket Mode?

Socket Mode is the default for good reason. It uses a persistent WebSocket connection — no public URL needed, no webhook endpoints to expose, no SSL certificates to manage. Your agent connects outbound to Slack, which means it works behind firewalls, on home networks, even on a Raspberry Pi. If you're just getting started, use Socket Mode.

Step 4: Start the Gateway

openclaw gateway
Enter fullscreen mode Exit fullscreen mode

That's it. OpenClaw connects to Slack, establishes the WebSocket, and your agent is online. Send it a DM in Slack — you should see a response within seconds.

Controlling DM Access

By default, Slack DMs use pairing mode. This means when someone DMs your agent for the first time, they get a pairing code. You approve the pairing from the CLI:

openclaw pairing approve slack <code>
Enter fullscreen mode Exit fullscreen mode

This is the most secure default — nobody talks to your agent without explicit approval. But you have other options:

  • pairing (default) — require explicit pairing approval per user
  • allowlist — only specific Slack user IDs can DM the agent
  • open — anyone in the workspace can DM (requires allowFrom: ["*"])
  • disabled — no DMs at all, channels only
{
  "channels": {
    "slack": {
      "enabled": true,
      "mode": "socket",
      "appToken": "xapp-...",
      "botToken": "xoxb-...",
      "dmPolicy": "allowlist",
      "allowFrom": ["U01ABC123", "U02DEF456"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Group DMs (MPIMs) are disabled by default. Enable them with "dm": { "groupEnabled": true } if your team uses group chats.

Adding Channel Access

DMs are one-on-one. Channels are where teams actually work. To let your agent participate in Slack channels, configure the group policy:

{
  "channels": {
    "slack": {
      "groupPolicy": "allowlist",
      "channels": {
        "C0A4G5T2DLM": {
          "requireMention": true
        },
        "C0ACMC7HM18": {
          "requireMention": false,
          "users": ["U01ABC123"]
        }
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Key channel settings:

  • requireMention — when true, the agent only responds when explicitly @mentioned. This is the right default for most channels.
  • users — restrict which users the agent responds to in this channel.
  • allowBots — let the agent respond to other bots. Usually keep this off.
  • systemPrompt — inject a per-channel system prompt. Your agent can behave differently in #engineering vs #marketing.
  • skills — restrict which skills are available per channel for tighter access control.

HTTP Events API Mode (Alternative)

If you need a publicly accessible endpoint — maybe you're running on a VPS with a domain — OpenClaw supports that too:

{
  "channels": {
    "slack": {
      "enabled": true,
      "mode": "http",
      "botToken": "xoxb-...",
      "signingSecret": "your-signing-secret",
      "webhookPath": "/slack/events"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

In HTTP mode, set your webhook URL as the Request URL in three places in your Slack app settings: Event Subscriptions, Interactivity, and Slash Commands.

Threading and Sessions

OpenClaw maps Slack threads to isolated sessions so context stays clean:

  • DMs route as direct sessions — with default settings, DMs share your agent's main session context
  • Channels create per-channel sessions — agent:<agentId>:slack:channel:<channelId>
  • Threads can spawn thread-scoped sub-sessions

Control reply threading behavior with replyToMode:

{
  "channels": {
    "slack": {
      "replyToMode": "all",
      "replyToModeByChatType": {
        "direct": "off",
        "channel": "all"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Options: off, first, all.

Live Streaming Responses

OpenClaw supports Slack native text streaming — your agent's responses appear token-by-token, like watching someone type in real time:

{
  "channels": {
    "slack": {
      "streaming": "partial",
      "nativeStreaming": true
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

This uses Slack's Agents and AI Apps API. Requirements: enable Agents and AI Apps in your Slack app settings, ensure the assistant:write scope is granted, and a reply thread must be available.

Reactions and Acknowledgments

When someone sends a message, your agent can react with an emoji to acknowledge it's processing:

{
  "channels": {
    "slack": {
      "ackReaction": "eyes"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The reaction appears immediately while the agent generates a response. Your agent can also add reactions as part of its workflow — acknowledging bug reports with 🔨, marking tasks complete with ✅, flagging urgent items with 🚨.

Multi-Account Setup

Running your agent across multiple Slack workspaces? OpenClaw supports named accounts:

{
  "channels": {
    "slack": {
      "enabled": true,
      "accounts": {
        "primary": {
          "mode": "socket",
          "appToken": "xapp-primary-...",
          "botToken": "xoxb-primary-...",
          "allowFrom": ["U01ABC123"]
        },
        "client-workspace": {
          "mode": "http",
          "botToken": "xoxb-client-...",
          "signingSecret": "client-secret",
          "webhookPath": "/slack/client-events"
        }
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

Agent not responding in channels: Check groupPolicy → channel allowlist → requireMention setting → per-channel users allowlist. Run openclaw channels status --probe.

DMs being ignored: Verify dm.enabled is true, check dmPolicy, confirm pairing is approved (openclaw pairing list slack).

Socket Mode won't connect: Double-check both tokens. Ensure Socket Mode is enabled in Slack app settings.

General debugging:

openclaw channels status --probe
openclaw logs --follow
openclaw doctor
Enter fullscreen mode Exit fullscreen mode

What's Next

Once Slack is connected, your agent is a team member. Explore further:

OpenClaw also supports Telegram, Discord, WhatsApp, Signal, iMessage, and more. Same agent, multiple surfaces.


Originally published at openclawplaybook.ai. Get The OpenClaw Playbook — $9.99

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.