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
- Go to api.slack.com/apps
- Click Create New App โ From scratch
- Name it (e.g.,
OpenClaw) and select your workspace - Click Create App
Step 2: Enable Socket Mode
- In the left sidebar, click Socket Mode
- Toggle Enable Socket Mode to On
- Enter a token name:
openclaw-app-token - Click Generate
- Copy the App-Level Token (starts with
xapp-)
Step 3: Configure Bot Permissions
-
Go to OAuth & Permissions
-
Under Bot Token Scopes, add:
app_mentions:readโ respond when mentionedchat:writeโ send messageschannels:historyโ read messages in public channelsim:historyโ read direct messagesim:readโ receive direct message eventsim:writeโ send direct messageschannels:readโ list channels
-
Click Install to Workspace
-
Copy the Bot User OAuth Token (starts with
xoxb-)
Step 4: Enable Event Subscriptions
- Go to Event Subscriptions
- Toggle Enable Events to On
- Under Subscribe to bot events, add:
app_mentionโ when someone @mentions the botmessage.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
- Go to discord.com/developers/applications
- Click New Application
- Name it
OpenClawand click Create
Step 2: Create a Bot User
- In the left sidebar, click Bot
- Click Add Bot โ Yes, do it!
- Under Token, click Reset Token and copy the bot token
- 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
- Go to OAuth2 โ URL Generator
- Under Scopes, check:
bot - Under Bot Permissions, check:
Read Messages/View ChannelsSend MessagesRead Message HistoryUse Slash Commands
- 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
| Option | Type | Description |
|---|---|---|
respondToMentions | boolean | Respond when @mentioned |
respondToDMs | boolean | Respond to direct messages |
prefix | string | Text prefix to trigger bot (e.g., !ai) |
allowedChannelIds | array | Limit to specific channel IDs (empty = all channels) |
ignoreBots | boolean | Ignore 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
| Problem | Solution |
|---|---|
| Bot not responding to DMs | Ensure im:history and im:read scopes are granted |
| Bot not responding to mentions | Ensure app_mention event is subscribed and bot is in channel |
| Socket mode disconnects | Check App Token is valid; regenerate if expired |
invalid_auth error | Regenerate Bot Token; re-install app to workspace |
Discord
| Problem | Solution |
|---|---|
| Bot online but not responding | Check Message Content Intent is enabled |
| Slash commands not showing | Run openclaw discord register-commands again |
| Bot cannot see messages | Missing Read Messages permission in server channel |
| Token invalid | Regenerate token in Discord Developer Portal |
Side-by-Side Comparison
| Feature | Slack | Discord |
|---|---|---|
| Setup difficulty | Medium | Easy |
| Business account needed | Free tier available | No |
| Socket Mode (no public URL) | Yes | Yes (WebSocket) |
| Thread support | Yes | No (channels only) |
| Slash commands | Yes | Yes (native) |
| DM support | Yes | Yes |
| File sharing | Yes | Yes |
| Best for | Work teams | Communities, gaming, OSS |
Next: Chapter 10 โ Microsoft Teams & Google Chat โ Enterprise messaging platform integration.