OpenClaw Slack Integration: Deploy Your AI Agent to Slack
Slack is where most teams already spend their working hours. Adding an OpenClaw AI agent directly into Slack means your team can ask questions, trigger workflows, and get reports without leaving the conversation. This guide walks you through every step: creating a Slack app, configuring permissions, writing a SOUL.md for Slack, setting up slash commands, and troubleshooting the issues you will actually hit.
Why Slack for AI Agents
Slack has over 750,000 organizations using it daily. Unlike standalone dashboards or CLI tools, a Slack-based agent meets your team where they already work. There is no context switch. Someone asks a question in a channel, the agent responds in seconds, and the entire team sees the answer.
Practical use cases for OpenClaw agents in Slack include: answering recurring questions from a knowledge base, generating daily reports and posting them to a channel, monitoring external services and alerting when something breaks, triaging incoming support requests by analyzing the message and routing to the right person, and running SQL queries against a database when someone types a slash command.
The Slack integration uses Slack's Socket Mode by default, which means you do not need a public URL or webhook endpoint. Your OpenClaw gateway connects outbound to Slack's servers over a WebSocket, making it work behind firewalls and NATs without any additional networking configuration.
Prerequisites
Before you start, make sure you have the following ready:
OpenClaw installed and running. You should be able to run openclaw agent --agent myagent --message "hello" and get a response. If not, follow the OpenClaw setup guide first.
A Slack workspace where you have admin permissions. You need to be able to install apps. If you are not a workspace admin, ask one to approve your app after you create it.
A SOUL.md file for your agent. This defines the agent's personality, skills, and boundaries. We will customize it for Slack in Step 4.
Step 1: Create a Slack App
Every Slack bot starts as a Slack App. This is the container that holds your bot user, permissions, event subscriptions, and tokens. The setup takes about three minutes.
Create the App
Go to api.slack.com/apps and click "Create New App." Choose "From scratch" (not from a manifest). Give it a descriptive name like "Orion PM Agent" or "Support Bot." Select the workspace where you want to install it.
Enable Socket Mode
In the left sidebar, click "Socket Mode" and toggle it on. Slack will ask you to generate an app-level token. Name it something like "openclaw-socket" and give it the connections:write scope. Copy this token immediately.
Important: Socket Mode tokens start with xapp-. Bot tokens start with xoxb-. You will need both. Do not mix them up in your configuration.
Add a Bot User
Navigate to "App Home" in the sidebar. Under "Your App's Presence in Slack," make sure "Always Show My Bot as Online" is enabled. Set a display name and default username for the bot. This is what your team will see when the agent sends messages.
Step 2: Configure Bot Permissions (OAuth Scopes)
Slack uses OAuth scopes to control what your bot can and cannot do. Go to "OAuth & Permissions" in the sidebar and scroll down to "Bot Token Scopes." Add the following scopes:
| Scope | Required? | Purpose |
|---|---|---|
| chat:write | Yes | Send messages as the bot |
| app_mentions:read | Yes | Detect when someone @mentions the bot |
| channels:history | Yes | Read messages in public channels |
| im:history | Yes | Read direct messages sent to the bot |
| groups:history | Optional | Read messages in private channels |
| users:read | Optional | Look up user display names and profiles |
| files:write | Optional | Upload files (reports, CSVs, images) |
| commands | Optional | Register and handle slash commands |
After adding scopes, scroll up and click "Install to Workspace" (or "Reinstall to Workspace" if you already installed it before adding scopes). Authorize the app. You will see a "Bot User OAuth Token" starting with xoxb-. Copy this token.
Subscribe to Events
Go to "Event Subscriptions" in the sidebar and toggle it on. Under "Subscribe to bot events," add these events:
# Required bot events for OpenClaw Slack integration
app_mention # Triggers when someone @mentions your bot
message.channels # Messages in public channels where bot is present
message.im # Direct messages to the bot
# Optional events
message.groups # Messages in private channels
message.mpim # Messages in multi-person DMsCritical: If you skip event subscriptions, the bot will appear online in Slack but never receive any messages. This is the most common "my bot is not responding" issue with Slack integrations.
Step 3: Configure OpenClaw for Slack
With your Slack app created and tokens in hand, configure OpenClaw to connect to it. You need two tokens: the Bot User OAuth Token (xoxb-) and the App-Level Token (xapp-) for Socket Mode.
# Required: Bot User OAuth Token (starts with xoxb-)
openclaw config set channels.slack.bottoken xoxb-YOUR-BOT-TOKEN
# Required: App-Level Token for Socket Mode (starts with xapp-)
openclaw config set channels.slack.apptoken xapp-YOUR-APP-TOKEN
# Optional: Reply in threads instead of the main channel
openclaw config set channels.slack.replyInThread true
# Optional: Only respond when @mentioned (ignore other messages)
openclaw config set channels.slack.mentionOnly true
# Optional: Restrict to specific channel IDs
openclaw config set channels.slack.allowedChannels '["C01ABC123", "C02DEF456"]'
# Optional: Set a custom status emoji
openclaw config set channels.slack.statusEmoji ":robot_face:"
# Start or restart the gateway
openclaw gateway restartAfter restarting the gateway, check the logs to confirm the connection:
# Verify Slack connection
openclaw gateway logs | grep slack
# Expected output:
# [channel:slack] connected to workspace "YourWorkspace"
# [channel:slack] socket mode active, listening for events
# [channel:slack] bot user: @your-bot-name (U01XXXXXXXX)If you see [channel:slack] connected in the logs, your agent is live. Go to any channel where the bot is present, type @YourBot hello, and you should get a response.
Step 4: Write a SOUL.md Optimized for Slack
Your SOUL.md defines how the agent behaves. When targeting Slack, there are specific considerations: messages should be concise (Slack is not the place for essays), formatting should use Slack's mrkdwn syntax (not standard Markdown), and the agent should understand channel context.
# Support Agent โ SOUL.md
## Identity
You are a technical support agent for the engineering team.
Your name is Atlas. You respond in Slack channels and DMs.
## Communication Rules
- Keep responses under 300 words. Slack messages should be scannable.
- Use Slack mrkdwn formatting: *bold*, _italic_, `code`, ```code blocks```.
- Use bullet points for lists, not numbered lists (they render poorly in Slack).
- When sharing links, use Slack format: <https://example.com|Display Text>.
- Never use Markdown headers (# H1) โ they do not render in Slack.
- For long responses, suggest continuing in a thread.
## Behavior
- If asked about something outside your knowledge, say so. Do not guess.
- When a question is ambiguous, ask one clarifying question before answering.
- Tag relevant team members with <@USER_ID> when escalation is needed.
- React with :eyes: when you start processing a complex request.
## Skills
- Search the internal knowledge base at https://docs.internal.company
- Query the PostgreSQL database for user and order data
- Check service health status via the monitoring API
## Boundaries
- Never share API keys, tokens, or credentials in channel messages.
- Never modify production data. Read-only access to databases.
- Escalate billing and account deletion requests to <@U01ADMIN123>.The key differences from a generic SOUL.md: explicit Slack formatting rules, message length limits appropriate for chat, instructions for using Slack-specific features like user mentions and reactions, and clear escalation paths using Slack user IDs.
Environment Variables
If your agent uses skills that require API keys or database connections, configure them as environment variables in your OpenClaw project:
# Slack tokens (set via openclaw config, but can also be env vars)
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token
# Agent-specific environment variables
DATABASE_URL=postgresql://user:pass@host:5432/mydb
KNOWLEDGE_BASE_API_KEY=kb_xxxxxxxxxxxx
MONITORING_API_URL=https://status.internal.company/api
# OpenAI / Anthropic model key (used by the agent)
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxStep 5: Test Your Slack Agent
Before rolling the agent out to your whole team, test it thoroughly. Here is a testing checklist:
Test 1: Direct Message
Open a DM with your bot and send a simple message like "hello." The agent should respond within a few seconds. If it does not respond, check the gateway logs for errors.
Test 2: Channel Mention
Invite the bot to a test channel with /invite @YourBot. Then send a message mentioning the bot: @YourBot what can you do?. Verify it responds in the channel (or in a thread if replyInThread is enabled).
Test 3: Thread Conversation
Start a thread on a message and mention the bot inside the thread. The agent should reply within the same thread and maintain context from the thread's conversation.
Test 4: Error Handling
Ask the agent something it cannot answer or request an action outside its boundaries. Verify it responds gracefully instead of crashing or returning raw error messages.
# Watch logs in real-time while testing
openclaw gateway logs --follow | grep slack
# Check for errors specifically
openclaw gateway logs --lines 50 | grep -i "error|failed|timeout"
# Verify message flow
# Expected log pattern:
# [channel:slack] received message from U01USER123 in C01CHANNEL
# [agent] processing message: "what can you do?"
# [agent] response generated (247 tokens, 1.3s)
# [channel:slack] sent response to C01CHANNELAdvanced: Slash Commands
Slash commands give your agent a structured interface. Instead of free-form messages, users type /ask how do I reset my password? and get a clean response. This is especially useful for agents that handle specific tasks like database queries, report generation, or ticket creation.
Register the Command
In your Slack app settings, go to "Slash Commands" and click "Create New Command."
# Command: /ask
# Request URL: https://your-host:18789/slack/commands
# (or use Socket Mode โ no URL needed)
# Short Description: Ask the AI agent a question
# Usage Hint: [your question here]
# Command: /report
# Request URL: https://your-host:18789/slack/commands
# Short Description: Generate a report
# Usage Hint: [daily|weekly|monthly] [metric-name]
# Command: /query
# Request URL: https://your-host:18789/slack/commands
# Short Description: Run a database query
# Usage Hint: [SQL query or natural language question]Handle Commands in OpenClaw
Configure OpenClaw to route slash commands to your agent:
# Enable slash command handling
openclaw config set channels.slack.enableCommands true
# Map commands to specific agent behaviors
openclaw config set channels.slack.commands '{
"/ask": {
"agent": "support-bot",
"ephemeral": false
},
"/report": {
"agent": "metrics-bot",
"ephemeral": true
},
"/query": {
"agent": "data-bot",
"ephemeral": true
}
}'
# Restart to apply
openclaw gateway restartThe ephemeral flag controls visibility. When set to true, only the user who ran the command sees the response. This is ideal for sensitive data like database queries or personal reports. When false, the response is visible to everyone in the channel.
Troubleshooting
Here are the most common issues you will encounter and how to fix them.
Bot is online but not responding
This almost always means missing event subscriptions. Go to Event Subscriptions in your Slack app and verify that app_mention and message.im are listed under bot events. After adding them, reinstall the app to your workspace.
# Check if the gateway is receiving events
openclaw gateway logs --follow | grep "slack.*received"
# If no events appear, the issue is on the Slack side:
# 1. Verify event subscriptions are saved
# 2. Reinstall the app to the workspace
# 3. Make sure Socket Mode is enabled
# 4. Check the App-Level Token is correct"not_authed" or "invalid_auth" errors
Your bot token is wrong, expired, or was regenerated without updating OpenClaw. This also happens if you accidentally use the App-Level Token (xapp-) where the Bot Token (xoxb-) is expected.
# Verify your tokens
openclaw config get channels.slack.bottoken
# Should start with xoxb-
openclaw config get channels.slack.apptoken
# Should start with xapp-
# If wrong, update them:
openclaw config set channels.slack.bottoken xoxb-CORRECT-TOKEN
openclaw config set channels.slack.apptoken xapp-CORRECT-TOKEN
openclaw gateway restartBot responds in DMs but not in channels
The bot needs to be explicitly invited to each channel. Slack does not give bots automatic access to all channels. Also check that you have the channels:history scope and the message.channels event subscription.
# Invite the bot to a channel (run in Slack)
/invite @YourBot
# If using allowedChannels, make sure the channel ID is listed
openclaw config get channels.slack.allowedChannels
# Get a channel's ID: right-click channel name > Copy > Copy Link
# The ID is the last segment: https://workspace.slack.com/archives/C01ABC123Rate limiting (429 errors)
Slack enforces rate limits on API calls. If your agent sends too many messages too quickly, Slack returns a 429 and includes a Retry-After header. OpenClaw handles this automatically with backoff, but high-traffic channels can still trigger it.
# Add a response delay to reduce API call frequency
openclaw config set channels.slack.responseDelay 1500
# Limit concurrent message processing
openclaw config set channels.slack.maxConcurrent 2
# Check rate limit hits in the logs
openclaw gateway logs | grep "rate.limit|429"Socket Mode disconnections
Socket Mode connections can drop due to network issues or Slack server maintenance. OpenClaw reconnects automatically, but if disconnections are frequent, check your network stability and consider using pm2 for process management.
# Enable reconnection with backoff
openclaw config set channels.slack.autoReconnect true
openclaw config set channels.slack.reconnectDelay 5000
openclaw config set channels.slack.maxReconnectAttempts 15
# Use pm2 for production uptime
pm2 start "openclaw gateway start" --name openclaw-slack
pm2 save && pm2 startupSkip the Setup with CrewClaw
If you want a Slack-connected AI agent without managing tokens, Socket Mode, event subscriptions, and gateway processes yourself, CrewClaw gives you a pre-configured agent with Slack integration included. Pick a role, customize the SOUL.md in the visual builder, and get a complete deployment package with Slack channel configuration, Docker setup, and environment templates. The entire process takes about 60 seconds.
Related Guides
OpenClaw Discord Integration
Connect your AI agent to Discord servers with bot setup and troubleshooting
OpenClaw Autonomous Agent Setup
Deploy agents that run independently without manual input
OpenClaw Agent Communication
How agents collaborate using mentions and delegation patterns
OpenClaw Setup Guide 2026
Complete installation and first agent walkthrough
Frequently Asked Questions
How do I connect OpenClaw to Slack?
Create a Slack app at api.slack.com/apps, enable Socket Mode, add bot token scopes (chat:write, app_mentions:read, channels:history, im:history), install the app to your workspace, copy the Bot User OAuth Token and App-Level Token, configure them in OpenClaw with 'openclaw config set channels.slack.bottoken' and 'openclaw config set channels.slack.apptoken', then restart the gateway. Your agent will respond to mentions and direct messages.
Why is my OpenClaw Slack bot not responding to messages?
The most common cause is missing event subscriptions. In your Slack app settings, go to Event Subscriptions and make sure you have subscribed to app_mention and message.im events. If the bot is in a channel but not responding, check that channels:history scope is added and the bot has been invited to the channel with /invite @YourBot. Also verify Socket Mode is enabled if you are not using a public Request URL.
Can I use OpenClaw with Slack slash commands?
Yes. You can register slash commands in your Slack app configuration under Slash Commands. Create a command like /ask or /report, point it to your OpenClaw gateway's webhook endpoint (typically http://your-host:18789/slack/commands), and OpenClaw will route the command input to your agent and return the response. Make sure your gateway is publicly accessible or use a tunnel like ngrok for development.
Does OpenClaw support Slack threads?
Yes. When a user mentions the bot in a thread, OpenClaw replies within that thread automatically. The agent maintains conversation context per thread, so each thread is treated as a separate conversation. For top-level channel messages, the agent can be configured to reply in a thread to avoid cluttering the channel by setting 'openclaw config set channels.slack.replyInThread true'.
Can one OpenClaw agent work in multiple Slack channels?
Yes. Once the bot is installed in a workspace, you can invite it to any channel with /invite @YourBot. The agent responds in all channels where it is present. To restrict it to specific channels, use 'openclaw config set channels.slack.allowedChannels' with an array of channel IDs. Conversations in different channels are tracked separately and do not share context.
What Slack API scopes does an OpenClaw bot need?
At minimum, the bot needs chat:write (send messages), app_mentions:read (detect @mentions), channels:history (read channel messages), and im:history (read direct messages). For file uploads add files:write. For reading user profiles add users:read. For slash commands add commands. The full recommended scope set is: chat:write, app_mentions:read, channels:history, groups:history, im:history, mpim:history, users:read, files:write, commands.
Build and Deploy Your Slack Agent
Get a complete, pre-configured OpenClaw agent with SOUL.md, Slack integration, deployment scripts, and monitoring. Start with a template and customize it for your workspace.
Deploy a Ready-Made AI Agent
Skip the setup. Pick a template and deploy in 60 seconds.