Slack Setup
Configure Slack bot with Socket Mode for OpenClaw
Slack Bot Setup
Set up a Slack bot using Socket Mode to interact with OpenClaw via Slack.
Slack uses Socket Mode for real-time communication - no public URLs or webhooks needed!
Prerequisites
- A Slack workspace where you can install apps
- Admin permissions to create and install Slack apps
- A Slack account
Create Slack App
-
Go to Slack API Dashboard: https://api.slack.com/apps
-
Create New App:
- Click "Create New App"
- Choose "From scratch"
- App Name:
OpenClaw Bot(or your preferred name) - Pick a workspace: Select your development workspace
- Click "Create App"
Enable Socket Mode
Socket Mode is required! This allows OpenClaw to receive messages without exposing a public URL.
- Go to Settings → Socket Mode (left sidebar)
- Toggle "Enable Socket Mode" → ON
- Generate App-Level Token:
- Token Name:
openclaw-socket - Scopes: Select
connections:write - Click "Generate"
- Copy the App Token (starts with
xapp-) - save it securely!
- Token Name:
Configure Bot Token Scopes
- Go to Features → OAuth & Permissions
- Scroll to "Scopes" → "Bot Token Scopes"
- Click "Add an OAuth Scope" and add these scopes:
app_mentions:read- See @mentions of the botchannels:history- View messages in public channelschannels:read- View basic channel informationchat:write- Send messagesgroups:history- View messages in private channelsgroups:read- View basic private channel infoim:history- View messages in DMsim:read- View basic DM infoim:write- Start direct messagesmpim:history- View messages in group DMsmpim:read- View basic group DM infousers:read- View people in workspace
Install App to Workspace
- Stay on OAuth & Permissions page
- Click "Install to Workspace" (top of page)
- Review permissions → Click "Allow"
- Copy the Bot User OAuth Token (starts with
xoxb-) - save it securely!
Enable Event Subscriptions
- Go to Features → Event Subscriptions
- Toggle "Enable Events" → ON
- Subscribe to bot events:
- Click "Add Bot User Event"
- Add these events:
app_mention- When bot is @mentionedmessage.channels- Messages in public channelsmessage.groups- Messages in private channelsmessage.im- Direct messages to botmessage.mpim- Group direct messages
- Click "Save Changes"
Get Slack IDs
Get Channel ID
- Open Slack workspace in browser or desktop app
- Go to the channel (e.g., #general)
- Click channel name at top → View details
- Scroll down → Channel ID (e.g.,
C04ABC12345)
Or right-click channel → Copy → Copy Link
- Link format:
https://yourworkspace.slack.com/archives/C04ABC12345 - The ID is after
/archives/
Get User ID
- Click on your profile picture → Profile
- Click ••• (More) → Copy member ID
- Format:
U04ABC12345
Get Workspace/Team ID (if needed)
- Go to workspace settings
- Or extract from any Slack URL:
https://app.slack.com/client/T04ABC12345/... - Format:
T04ABC12345
Add Slack Configuration
Set environment variables:
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-YOUR-BOT-TOKEN-HERE
SLACK_APP_TOKEN=xapp-YOUR-APP-TOKEN-HEREUpdate configuration file ~/.openclaw/openclaw.json:
{
"channels": {
"slack": {
"enabled": true,
"socketMode": true,
"dm": {
"enabled": true,
"policy": "allowlist",
"allowFrom": ["U04ABC12345"]
},
"groupPolicy": "allowlist",
"channels": {
"C04ABC12345": {
"allow": true,
"requireMention": false
}
},
"teams": {
"T04ABC12345": {
"users": ["U04ABC12345"]
}
}
}
},
"plugins": {
"entries": {
"slack": {
"enabled": true
}
}
}
}Replace with your IDs:
xoxb-...- Your Slack Bot Tokenxapp-...- Your Slack App TokenU04ABC12345- Your Slack user IDC04ABC12345- Your channel IDT04ABC12345- Your workspace/team ID
Invite Bot to Channels
After configuration, invite the bot to channels:
- Go to the Slack channel (e.g., #general)
- Type:
/invite @OpenClaw Bot - Press Enter
- Bot will join the channel
Or:
- Click channel name → Integrations tab
- Click "Add apps" → Find your bot → Add
Configuration Options
| Field | Description | Default |
|---|---|---|
socketMode | Use Socket Mode (no webhooks needed) | true |
dm.enabled | Enable direct message support | true |
dm.policy | Access control: allowlist, pairing, open, disabled | pairing |
dm.allowFrom | Slack user IDs allowed to DM | [] |
groupPolicy | Channel policy: allowlist, open, disabled | allowlist |
channels.<id>.allow | Allow bot in this channel | false |
channels.<id>.requireMention | Require @mention to respond | true |
teams.<id>.users | User IDs allowed in this workspace | [] |
Mention vs No-Mention Mode
With requireMention: true (Recommended)
Bot only responds when @mentioned:
@OpenClaw Bot hello- Prevents bot from responding to every message
- Better for busy channels
- Recommended for shared channels
With requireMention: false (Testing Only)
Bot responds to every message in configured channels.
- Can be noisy in active channels
- Good for private testing channels
Verify Setup
Start Gateway
cd /path/to/aiq-openclaw
export SLACK_BOT_TOKEN=xoxb-...
export SLACK_APP_TOKEN=xapp-...
node scripts/run-node.mjs gatewayExpected Log Output
[slack] socket mode connected
[slack] connected to workspace: YourWorkspaceCheck Status
pnpm openclaw channels status --probeExpected output:
Slack default: enabled, configured, running, worksTest Slack Bot
Test in DM
- Click Apps in Slack sidebar
- Find your bot → Click to open DM
- Send:
Hello ArmorIQ! - Bot should respond (if your user ID is in allowlist)
Test in Channel
- Go to configured channel where bot was invited
- If
requireMention: false, send:hello - If
requireMention: true, send:@YourBot hello - Bot should respond
Test with @mention
In any channel where bot is a member:
@OpenClaw Bot what's the weather today?Troubleshooting
Bot doesn't respond
Check:
- Both
SLACK_BOT_TOKENandSLACK_APP_TOKENare set correctly - Socket Mode is enabled in Slack app settings
- Bot has all required OAuth scopes
- Bot was invited to the channel:
/invite @YourBot - Check logs for "socket mode connected"
- Your user ID is in
allowFromlist if using allowlist policy - You're using @mention if
requireMention: true
Solution:
# Check logs
tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | grep slack
# Verify environment
echo $SLACK_BOT_TOKEN
echo $SLACK_APP_TOKENSocket mode connection failed
Error: Failed to connect to Socket Mode
Fix:
- Verify App Token (
xapp-...) hasconnections:writescope - Check Socket Mode is enabled in Slack app settings
- Regenerate tokens if they were revoked
Missing permissions
Error: missing_scope: The token used is not granted the specific scope permissions required
Fix:
- Go to Slack API dashboard
- Check all required scopes are added
- Reinstall app after adding scopes
Security Best Practices
Use Allowlist Policy
SAFE - Only specific users in allowed channels:
{
"channels": {
"slack": {
"dm": {
"policy": "allowlist",
"allowFrom": ["U04ABC12345"]
},
"groupPolicy": "allowlist",
"teams": {
"T04ABC12345": {
"users": ["U04ABC12345"]
}
}
}
}
}❌ DANGEROUS - Anyone in workspace can interact:
{
"channels": {
"slack": {
"dm": { "policy": "open" },
"groupPolicy": "open" // NEVER DO THIS!
}
}
}Token Storage
Store tokens securely in environment:
~/.openclaw/.envNever commit tokens to version control!
Next Steps
Slack configured!
Configure additional channels: