๐Ÿ”
ChannelsChapter 9 of 33ยท 7 min read

Chapter 9: Slack & Discord Setup

Slack and Discord are where most development teams spend their working hours. Connecting OpenClaw to these platforms means your AI agents are already inside the tools your team uses โ€” no context switching, no new apps to open. This chapter covers complete setup for both.


Part 1: Slack

How OpenClaw Connects to Slack

OpenClaw uses Slack's Socket Mode for receiving events, which means:

  • No public HTTPS URL required โ€” works behind NAT/firewalls
  • Real-time event delivery via WebSocket connection
  • Works in both development (local machine) and production (cloud server)

For production with webhooks instead of Socket Mode, you can switch to HTTP mode (covered at the end of this section).


Step 1: Create a Slack App

  1. Go to api.slack.com/apps
  2. Click Create New App โ†’ From scratch
  3. Name it (e.g., OpenClaw) and select your workspace
  4. Click Create App

Step 2: Enable Socket Mode

  1. In the left sidebar, click Socket Mode
  2. Toggle Enable Socket Mode to On
  3. Enter a token name: openclaw-app-token
  4. Click Generate
  5. Copy the App-Level Token (starts with xapp-)

Step 3: Configure Bot Permissions

  1. Go to OAuth & Permissions

  2. Under Bot Token Scopes, add:

    • app_mentions:read โ€” respond when mentioned
    • chat:write โ€” send messages
    • channels:history โ€” read messages in public channels
    • im:history โ€” read direct messages
    • im:read โ€” receive direct message events
    • im:write โ€” send direct messages
    • channels:read โ€” list channels
  3. Click Install to Workspace

  4. Copy the Bot User OAuth Token (starts with xoxb-)


Step 4: Enable Event Subscriptions

  1. Go to Event Subscriptions
  2. Toggle Enable Events to On
  3. Under Subscribe to bot events, add:
    • app_mention โ€” when someone @mentions the bot
    • message.im โ€” direct messages to the bot

Step 5: Configure openclaw.json

{
  "channels": {
    "slack": {
      "enabled": true,
      "botToken": "${SLACK_BOT_TOKEN}",
      "signingSecret": "${SLACK_SIGNING_SECRET}",
      "appToken": "${SLACK_APP_TOKEN}",
      "mode": "socket",
      "respondToMentions": true,
      "respondToDMs": true,
      "respondToThreads": true
    }
  }
}

Set environment variables:

export SLACK_BOT_TOKEN="xoxb-xxxxxxxx-xxxxxxxx-xxxxxxxxxxxxxxxxxx"
export SLACK_SIGNING_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export SLACK_APP_TOKEN="xapp-1-xxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxxxxxxxx"

Find the Signing Secret in: App Settings โ†’ Basic Information โ†’ App Credentials.


Step 6: Invite the Bot to Channels

In any Slack channel where you want OpenClaw active:

/invite @OpenClaw

Step 7: Allowlist Setup

Slack allowlists use Slack user IDs (format: U01ABCDE123). Find a user's ID by clicking their name โ†’ profile โ†’ three dots โ†’ Copy member ID.

{
  "workspaces": [
    {
      "id": "dev-team",
      "channels": ["slack"],
      "agent": "claude-sonnet",
      "allowlist": ["U01ABCDE123", "U02FGHIJ456"]
    }
  ]
}

To allow all workspace members:

{
  "allowlist": ["*"]
}

Slack Usage Patterns

Direct message the bot: Send a DM to @OpenClaw โ€” the bot responds in the DM thread.

Mention the bot in a channel:

@OpenClaw review this PR and summarize the changes

Thread replies: When respondToThreads: true, the bot responds in the same thread โ€” keeps channels clean.


Slack HTTP Mode (Alternative)

For environments where Socket Mode is not preferred:

{
  "channels": {
    "slack": {
      "mode": "http",
      "webhookPath": "/webhooks/slack",
      "port": 3001
    }
  }
}

Requires your gateway to have a public HTTPS URL. Configure it in Slack under Event Subscriptions โ†’ Request URL.


Part 2: Discord

How OpenClaw Connects to Discord

OpenClaw uses a Discord Bot via the discord.js library. The bot connects via a persistent WebSocket connection (Discord Gateway) โ€” no public URL required.


Step 1: Create a Discord Application

  1. Go to discord.com/developers/applications
  2. Click New Application
  3. Name it OpenClaw and click Create

Step 2: Create a Bot User

  1. In the left sidebar, click Bot
  2. Click Add Bot โ†’ Yes, do it!
  3. Under Token, click Reset Token and copy the bot token
  4. Under Privileged Gateway Intents, enable:
    • Message Content Intent (required to read message text)
    • Server Members Intent (required for allowlist matching by username)

Step 3: Set Bot Permissions

  1. Go to OAuth2 โ†’ URL Generator
  2. Under Scopes, check: bot
  3. Under Bot Permissions, check:
    • Read Messages/View Channels
    • Send Messages
    • Read Message History
    • Use Slash Commands
  4. Copy the generated URL and open it to invite the bot to your server

Step 4: Configure openclaw.json

{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "${DISCORD_BOT_TOKEN}",
      "respondToMentions": true,
      "respondToDMs": true,
      "prefix": "!ai",
      "allowedChannelIds": ["1234567890123456789"]
    }
  }
}

Set environment variable:

export DISCORD_BOT_TOKEN="MTxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxx"

Discord Configuration Options

OptionTypeDescription
respondToMentionsbooleanRespond when @mentioned
respondToDMsbooleanRespond to direct messages
prefixstringText prefix to trigger bot (e.g., !ai)
allowedChannelIdsarrayLimit to specific channel IDs (empty = all channels)
ignoreBotsbooleanIgnore messages from other bots (default: true)

Step 5: Discord Allowlist

Discord allowlists use numeric user IDs. Find a user's ID: right-click their name โ†’ Copy User ID (requires Developer Mode in Discord settings).

{
  "workspaces": [
    {
      "id": "discord-dev",
      "channels": ["discord"],
      "agent": "claude-sonnet",
      "allowlist": ["123456789012345678", "987654321098765432"]
    }
  ]
}

Discord Usage Patterns

Mention the bot:

@OpenClaw write unit tests for the AuthService class

Use a prefix: If prefix: "!ai" is set:

!ai explain the difference between TCP and UDP

DM the bot: Send a direct message โ€” the bot responds without needing a channel mention.


Discord Slash Commands

OpenClaw can register slash commands with Discord for a polished user experience:

openclaw discord register-commands

This registers:

  • /ask [question] โ€” ask the AI a question
  • /reset โ€” reset your conversation session
  • /status โ€” check gateway status

Slash commands show up in Discord's autocomplete menu.


Troubleshooting

Slack

ProblemSolution
Bot not responding to DMsEnsure im:history and im:read scopes are granted
Bot not responding to mentionsEnsure app_mention event is subscribed and bot is in channel
Socket mode disconnectsCheck App Token is valid; regenerate if expired
invalid_auth errorRegenerate Bot Token; re-install app to workspace

Discord

ProblemSolution
Bot online but not respondingCheck Message Content Intent is enabled
Slash commands not showingRun openclaw discord register-commands again
Bot cannot see messagesMissing Read Messages permission in server channel
Token invalidRegenerate token in Discord Developer Portal

Side-by-Side Comparison

FeatureSlackDiscord
Setup difficultyMediumEasy
Business account neededFree tier availableNo
Socket Mode (no public URL)YesYes (WebSocket)
Thread supportYesNo (channels only)
Slash commandsYesYes (native)
DM supportYesYes
File sharingYesYes
Best forWork teamsCommunities, gaming, OSS

Next: Chapter 10 โ€” Microsoft Teams & Google Chat โ€” Enterprise messaging platform integration.