Clawctl
Tutorial
7 min

Build an AI Slack Assistant with OpenClaw (Step-by-Step)

Step-by-step tutorial to build an AI Slack assistant with OpenClaw. Connect your knowledge base, set up DM policies, and deploy securely.

Clawctl Team

Product & Engineering

Build an AI Slack Assistant with OpenClaw (Step-by-Step)

Last Friday, our new hire asked the same question for the third time. On Monday, an AI agent answered it.

The agent lives in Slack. It reads our internal docs. It answers questions in seconds. It cost us 45 minutes to set up.

Here's the full walkthrough.

What You're Building

A Slack bot powered by OpenClaw that:

  • Lives in a Slack channel (or responds to DMs)
  • Answers questions from your company's knowledge base
  • Runs commands when asked (search files, summarize docs, pull data)
  • Logs every interaction for compliance

By the end of this tutorial, your team will stop pinging you for answers.

Prerequisites

You need:

  • An OpenClaw instance (self-hosted or Clawctl)
  • A Slack workspace where you're an admin
  • Your LLM API key (Anthropic, OpenAI, etc.)
  • 45 minutes

Step 1: Create a Slack App

Go to api.slack.com/apps and click Create New App.

Choose From scratch. Name it something your team will recognize. "Team Assistant" works. "AI Bot 3000" doesn't.

Select your workspace.

Configure Bot Permissions

Under OAuth & Permissions, add these Bot Token Scopes:

  • chat:write — send messages
  • channels:history — read channel messages
  • channels:read — see channel list
  • im:history — read DMs
  • im:read — access DM channels
  • im:write — send DMs
  • groups:history — read private channel messages
  • users:read — see user info

Enable Events

Under Event Subscriptions, toggle it on. You'll need your OpenClaw gateway URL for the Request URL. We'll come back to this.

Subscribe to these bot events:

  • message.channels — messages in public channels
  • message.im — direct messages
  • message.groups — messages in private channels

Install to Workspace

Click Install to Workspace under OAuth & Permissions. Authorize the app. Copy the Bot User OAuth Token — you'll need it in Step 2.

Deploying this for a customer? API tokens in plaintext are a security incident waiting to happen. Clawctl encrypts every credential →

Step 2: Connect Slack to OpenClaw

If you're using Clawctl

Open your Clawctl dashboard. Go to Channels and click Add Channel.

Select Slack. Paste your Bot User OAuth Token. Click Connect.

That's it. Clawctl handles the webhook URL, token encryption, and channel routing.

If you're self-hosting

You need to configure the Slack channel in your OpenClaw setup.

Add the Slack bot token to your environment:

SLACK_BOT_TOKEN=xoxb-your-token-here

Update your OpenClaw configuration to enable the Slack channel. The exact config depends on your version, but it looks like:

{
  "channels": {
    "slack": {
      "accounts": {
        "default": {
          "botToken": "xoxb-your-token-here"
        }
      }
    }
  }
}

Then go back to your Slack app's Event Subscriptions and set the Request URL to:

https://your-openclaw-domain.com/api/slack/events

Slack will send a verification challenge. If your OpenClaw instance is running and configured, it'll respond and the URL will verify.

Step 3: Add Your Knowledge Base

Your bot is connected. But it doesn't know anything about your company yet.

Upload your docs to the OpenClaw workspace. SSH into your server (or use the Clawctl file manager) and add files:

# Copy your docs into the workspace
cp -r /path/to/your/docs /workspace/knowledge-base/

Supported formats: Markdown, text files, PDFs, code files. The agent reads them on demand.

Set Up the System Prompt

Configure your agent's system prompt to reference the knowledge base:

You are a helpful team assistant for [Company Name].

When answering questions, first check the files in /workspace/knowledge-base/
for relevant information. Always cite which document you found the answer in.

If you can't find the answer in the knowledge base, say so. Don't make things up.

Be concise. Most people are reading this on a phone between meetings.

This is the most important step. A good system prompt turns a chatbot into a useful assistant.

Step 4: Test It

Go to Slack. DM your bot or mention it in a channel:

@Team Assistant What's our refund policy?

The agent will search your knowledge base, find the relevant doc, and respond with the answer.

If it doesn't respond:

  1. Check that Event Subscriptions are verified in your Slack app
  2. Check your OpenClaw logs for connection errors
  3. Make sure the bot is invited to the channel (/invite @Team Assistant)

Step 5: Security Configuration

Your bot works. Now lock it down.

DM Policy

By default, OpenClaw channels use a "pairing" DM policy. Only users who've been paired can DM the bot. This prevents random people from querying your knowledge base.

Options:

  • pairing (default) — users must be approved before they can DM
  • open — anyone in the workspace can DM (fine for internal teams)
  • allowlist — only specific Slack user IDs can interact

For an internal team bot, open is fine. For anything customer-facing, use allowlist.

In Clawctl, configure this under Channels → Slack → DM Access Control.

For self-hosted setups, set it in your channel config:

{
  "dmPolicy": "allowlist",
  "allowFrom": ["U01ABC123", "U02DEF456"]
}

Egress Controls

Your agent can access the internet by default. For a knowledge-base bot, it probably shouldn't.

Restrict egress to only the domains it needs:

  • Your LLM provider's API endpoint
  • Any internal APIs the agent should access
  • Nothing else

In Clawctl, set this under Security → Egress Controls.

Self-hosted? You'll need iptables rules or Docker network policies. See our network security guide for the full setup.

Audit Logging

Every question your team asks, every file the agent reads, every response it gives. If you're in a regulated industry, you need this trail.

Clawctl logs everything by default. Self-hosted, you'll need to build this yourself. Our audit logging guide walks through the options.

Step 6: Roll It Out

Don't announce it to the whole company on day one.

Start with one team. Five to ten people. Let them use it for a week. Collect feedback.

Common feedback you'll get:

  • "It didn't know about X" — add the relevant doc to the knowledge base
  • "It gave a wrong answer about Y" — update the source doc or refine the system prompt
  • "It's too slow" — check your LLM provider latency, consider a faster model for simple questions

After a week of refinement, expand to the next team.

What This Looks Like in Practice

Here's what our team's bot handles in a typical week:

  • 40-60 questions answered (things that would've been Slack DMs to someone)
  • 8-10 doc lookups (onboarding info, process docs, API references)
  • 3-4 "I don't know" responses (signals for knowledge base gaps)

The new hire who asked the same question three times? Now asks the bot. Gets an answer in 5 seconds. With a link to the source doc.

The senior engineer who used to answer those questions? Ships code instead.

Going Further

Once your team bot works, you can extend it:

  • Connect multiple channels. Same agent in Slack, Discord, and Telegram. See our channels documentation for all supported messaging apps.
  • Add tools. Let the agent query your database, check deploy status, or pull metrics.
  • Multi-agent setup. One agent for engineering questions, another for sales, another for HR. Each with its own knowledge base and permissions.

For the full multi-agent architecture, check our multi-agent orchestration guide.

Ready to stop worrying?

Clawctl locks down your OpenClaw instance in 60 seconds. Encrypted keys, audit logs, egress controls, human approvals. $49/mo. No contracts. Start now →

This content is for informational purposes only and does not constitute financial, legal, medical, tax, or other professional advice. Individual results vary. See our Terms of Service for important disclaimers.

Ready to deploy your OpenClaw securely?

Get your OpenClaw running in production with Clawctl's enterprise-grade security.