Skip to main content

Overview

klaw provides native Slack integration, allowing your team to interact with AI agents directly in Slack channels and threads. This guide walks you through setting up and configuring the integration.

Prerequisites

  • klaw installed and configured
  • Slack workspace admin access
  • API key configured

Step 1: Create a Slack App

1

Go to Slack API

Visit api.slack.com/apps and click Create New App.
2

Choose creation method

Select From scratch and give your app a name (e.g., “klaw”) and select your workspace.
3

Enable Socket Mode

Go to Socket Mode in the sidebar and enable it. Generate an App-Level Token with connections:write scope. Save this as SLACK_APP_TOKEN.
4

Configure OAuth scopes

Go to OAuth & Permissions and add these Bot Token Scopes:
  • app_mentions:read - Receive @mentions
  • chat:write - Send messages
  • channels:history - Read channel messages
  • channels:read - View channel info
  • groups:history - Read private channel messages
  • groups:read - View private channel info
  • im:history - Read DMs
  • im:read - View DM info
  • im:write - Send DMs
  • users:read - View user info
5

Enable Events

Go to Event Subscriptions and enable events. Subscribe to these bot events:
  • app_mention - When someone @mentions the bot
  • message.channels - Messages in channels
  • message.groups - Messages in private channels
  • message.im - Direct messages
6

Install to Workspace

Go to Install App and click Install to Workspace. Save the Bot User OAuth Token as SLACK_BOT_TOKEN.

Step 2: Configure Environment

Set the required environment variables:
For permanent configuration, add to your shell profile or ~/.klaw/config.toml:

Step 3: Start klaw

Start the klaw platform with Slack integration:
You should see:

Step 4: Invite the Bot

In Slack, invite your bot to channels:
  1. Go to the channel where you want the bot
  2. Type /invite @klaw (or your bot’s name)
  3. The bot is now active in that channel

Interacting with the Bot

@Mention the Bot

Thread Conversations

Start a thread and continue the conversation:
The bot maintains context within threads.

Route to Specific Agents

Use @agent syntax to route to specific agents:

Setting Up Agents

Create agents for your Slack workspace:
View your agents:

Scheduled Tasks (Cron)

Set up automated tasks in Slack:

Create from CLI

Create from Slack

In Slack, tell the bot to create a cron job:
The bot will use the cron_create tool automatically.

Manage Cron Jobs

Channel-Specific Monitoring

Set up monitoring for specific channels:
The bot will create a cron job that:
  1. Reads new messages from the channel
  2. Analyzes them based on your criteria
  3. Responds in threads when matches are found

Configuration Options

Namespace Binding

Bind Slack channels to specific namespaces:

Orchestrator Rules

Configure message routing:

Best Practices

Only invite the bot to channels where it’s needed. This reduces noise and improves response relevance.
Encourage users to start threads for conversations. This keeps channels clean and maintains context better.
Consider creating dedicated channels like #klaw-tasks or #ai-assistant for AI interactions.
For busy channels, consider rate limiting to prevent overwhelming the system.

Troubleshooting

  1. Check if the bot is invited to the channel
  2. Verify Socket Mode is enabled in Slack app settings
  3. Check klaw start output for errors
  4. Ensure tokens are correctly set
  1. Check your API provider’s status
  2. Consider using a faster model (Haiku for simple tasks)
  3. Reduce the number of tools/skills for faster processing
  1. Ensure channels:history scope is granted
  2. Check if the bot has access to the channel
  3. For private channels, add groups:history scope

Next Steps

Multi-Agent Workflows

Orchestrate multiple agents

Distributed Deployment

Scale your Slack bot