Skip to main content

Slack

Connect your OpenClaw agent to Slack so it can respond to direct messages and mentions in your workspace. OpenClaw uses Slack's Socket Mode, which means no public URL or webhook setup is required.

Prerequisites​

  • A Slack workspace where you have permission to install apps
  • Access to your OpenClaw Dashboard

Step-by-Step Setup​

1. Create a Slack App​

  1. Go to the Slack API Apps page.
  2. Click Create New App.
  3. Select From Scratch.
  4. Enter an app name (e.g., "My AI Agent").
  5. Select the workspace you want to install it in.
  6. Click Create App.

2. Enable Socket Mode​

  1. In the left sidebar, click Socket Mode.
  2. Toggle Enable Socket Mode to on.
Why Socket Mode?

Socket Mode lets your bot connect to Slack via a WebSocket connection instead of requiring a publicly accessible URL. This is simpler to set up and works well with OpenClaw's architecture.

3. Set Bot Permissions​

  1. In the left sidebar, click OAuth & Permissions.
  2. Scroll down to Scopes > Bot Token Scopes.
  3. Add the following scopes:
    • chat:write -- send messages
    • channels:history -- read messages in public channels
    • im:history -- read direct messages
    • users:read -- access user information
  4. Scroll back up and click Install to Workspace.
  5. Click Allow on the authorization screen.
  6. Copy the Bot User OAuth Token that appears (starts with xoxb-).

4. Subscribe to Events​

  1. In the left sidebar, click Event Subscriptions.
  2. Toggle Enable Events to on.
  3. Under Subscribe to bot events, add:
    • message.im -- triggers when someone DMs the bot
    • app_mention -- triggers when someone @mentions the bot
  4. Click Save Changes.

5. Generate an App-Level Token​

  1. In the left sidebar, click Basic Information.
  2. Scroll down to App-Level Tokens.
  3. Click Generate Token and Scopes.
  4. Give it a name (e.g., "socket-token").
  5. Add the scope: connections:write.
  6. Click Generate.
  7. Copy the token (starts with xapp-).

6. Connect in OpenClaw​

  1. Go to your OpenClaw Dashboard.
  2. Navigate to Instance > Channels.
  3. Click Slack.
  4. Click Connect.
  5. Paste the Bot Token (xoxb-...) in the first field.
  6. Paste the App-Level Token (xapp-...) in the second field.
  7. Click Save.

OpenClaw will connect to Slack using Socket Mode. You should see the channel status change to Connected within a few seconds.

7. Test It​

Open Slack and send a direct message to your bot, or @mention it in a channel. Your OpenClaw agent should respond.

tip

If the bot does not appear in your DM list, click the + button next to "Direct Messages" in Slack and search for your app's name.

Token Reference​

TokenPrefixWhere to Find
Bot User OAuth Tokenxoxb-OAuth & Permissions page
App-Level Tokenxapp-Basic Information > App-Level Tokens

Troubleshooting​

  • Bot does not respond to DMs: Make sure you subscribed to the message.im event in step 4 and that the im:history scope is added in step 3.
  • Bot does not respond to @mentions: Make sure you subscribed to the app_mention event.
  • "Invalid token" error: Verify you are pasting the correct tokens in the correct fields. The bot token starts with xoxb- and the app-level token starts with xapp-.
  • Bot is not visible in workspace: Ensure you completed the "Install to Workspace" step in OAuth & Permissions.