Tutorial

Slack AI Bot: Self-Hosted Setup Guide 2026

Complete guide to building self-hosted Slack AI bot with OpenClaw. Connect Claude, GPT-4, or local models to Slack for team productivity automation with full data control.

By OpenClaw Team ¡

Slack AI Bot: Self-Hosted Setup Guide 2026

Slack is the central nervous system of modern teams—where conversations happen, decisions are made, and work gets coordinated. Adding AI to Slack multiplies team productivity: instant answers to questions, automated summaries of threads, document searches, meeting scheduling, and intelligent reminders. But commercial Slack AI bots send your team’s conversations to third-party servers, creating privacy concerns and vendor lock-in.

This guide shows you how to build a self-hosted Slack AI bot using OpenClaw that keeps all data under your control. You’ll connect your choice of AI model (GPT-4, Claude, or local Llama) to Slack, implement team-specific skills, and deploy on your own infrastructure—whether that’s a VPS, company server, or cloud VM. Complete data sovereignty with no monthly bot subscriptions.

What you’ll build: A Slack bot that responds to @mentions and direct messages, searches your internal knowledge base, integrates with Google Calendar, Notion, and GitHub, runs completely on your infrastructure, and costs only AI API fees (or $0 with local models).

Time to complete: 30-60 minutes for basic setup, plus time for custom skill additions.

Why Self-Host Your Slack AI Bot?

Data Privacy and Security

Every message sent to commercial Slack bots (Claude for Slack, ChatGPT bot, etc.) leaves your Slack workspace and enters the bot provider’s servers. Your internal discussions, customer information, strategy conversations, and code snippets are processed by third parties.

Self-hosted bots process messages on your own infrastructure. Conversations never leave your control. For teams handling sensitive information—client data, intellectual property, confidential strategies—self-hosting is essential.

Cost Control

Commercial Slack AI bots charge per user ($8-20/month per user). For a 50-person team, that’s $400-1,000 monthly ($4,800-$12,000 annually). Enterprise pricing is even higher.

Self-hosted bots eliminate per-user fees. You pay only for:

  • Hosting ($10-50/month VPS)
  • AI API calls ($20-200/month depending on usage)
  • Or $0 with local LLMs

Total: $30-250/month regardless of team size. Break-even at 5-15 users. Massive savings for larger teams.

Customization Freedom

Commercial bots offer predefined features with limited customization. Want to integrate with your internal tool? Connect to proprietary database? Implement company-specific workflows? You’re constrained by what the vendor allows.

Self-hosted bots are infinitely customizable:

  • Add any OpenClaw skill (5,700+ available)
  • Integrate with internal APIs and databases
  • Implement custom business logic
  • Fine-tune AI behavior for your domain
  • Create team-specific commands and workflows

No Vendor Lock-In

Committing to commercial bot creates dependency. If vendor raises prices, changes features, or shuts down, you’re stuck migrating hundreds of workflows and conversations.

Self-hosted bots are portable. Switch AI providers (GPT-4 → Claude → local models) with configuration changes. Move hosting providers freely. Export all data anytime. You control the roadmap.

Prerequisites

Before starting, ensure you have:

1. Slack workspace with admin permissions (to create bot and install app)

2. Server/hosting:

  • VPS (DigitalOcean, Linode, Hetzner): $10-50/month
  • Company server (if available)
  • Cloud VM (AWS, GCP, Azure)
  • Local machine for testing (can migrate to server later)

3. AI model access:

  • OpenAI API key (for GPT-4 or GPT-3.5)
  • Anthropic API key (for Claude)
  • Or Ollama installed for local models

4. Basic terminal skills: Comfortable with SSH, editing config files, running commands.

Optional:

  • Domain name (for prettier webhook URLs)
  • SSL certificate (Let’s Encrypt, free)
  • Docker (for containerized deployment)

Step 1: Create Slack App

First, create a Slack app that your bot will use to connect.

1.1 Create New App

  1. Go to api.slack.com/apps
  2. Click “Create New App”
  3. Choose “From scratch”
  4. App Name: “Team AI Assistant” (or your preferred name)
  5. Select your workspace
  6. Click “Create App”

1.2 Configure Bot User

  1. In left sidebar, go to “App Home”
  2. Under “Your App’s Presence in Slack”, click “Edit”
  3. Display Name: “AI Assistant”
  4. Default Username: “ai-assistant”
  5. Enable “Always Show My Bot as Online”
  6. Click “Save”

1.3 Add Bot Scopes

Scopes control what your bot can do.

  1. Go to “OAuth & Permissions” in sidebar
  2. Scroll to “Scopes” section
  3. Under “Bot Token Scopes”, click “Add an OAuth Scope”
  4. Add the following scopes:

Required scopes:

  • app_mentions:read - See @mentions of your bot
  • chat:write - Send messages as bot
  • im:history - Read direct messages to bot
  • im:read - Access direct message metadata
  • im:write - Start direct message conversations
  • channels:history - Read messages in public channels (where bot is added)
  • groups:history - Read messages in private channels (where bot is invited)
  • users:read - Get basic user information

Optional (for enhanced features):

  • files:read - Access files shared in conversations
  • reactions:write - React to messages with emoji
  • channels:read - List channels
  • groups:read - List private channels

1.4 Install App to Workspace

  1. Still in “OAuth & Permissions”
  2. Click “Install to Workspace” button at top
  3. Review permissions
  4. Click “Allow”
  5. Copy the “Bot User OAuth Token” (starts with xoxb-)
    • Save this securely—you’ll need it for OpenClaw configuration
    • Never commit to Git or share publicly

Step 2: Set Up Server and OpenClaw

Now configure your server and install OpenClaw.

2.1 Connect to Server

# SSH into your VPS/server
ssh user@your-server-ip

# Or use local machine for testing
# (can deploy to server later)

2.2 Install Dependencies

# Update system
sudo apt update && sudo apt upgrade -y

# Install Node.js 18+ (required for OpenClaw)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

# Verify installation
node --version  # Should be v18 or higher
npm --version

# Optional: Install PM2 for process management
sudo npm install -g pm2

2.3 Install OpenClaw

# Install OpenClaw globally
sudo npm install -g openclaw

# Verify installation
openclaw --version

# Create project directory
mkdir ~/slack-ai-bot
cd ~/slack-ai-bot

# Initialize OpenClaw project
openclaw init

# Install Slack platform support
openclaw add platform slack

Step 3: Configure OpenClaw

Now configure OpenClaw to connect to Slack and AI model.

3.1 Edit Configuration File

cd ~/slack-ai-bot
nano openclaw.config.yaml

Complete configuration:

name: slack-ai-bot
version: 1.0.0
description: Self-hosted Slack AI assistant for team productivity

# AI Model Configuration
ai:
  provider: anthropic  # or 'openai', 'ollama'
  model: claude-3-5-haiku-20241022  # Fast for chat
  temperature: 0.7
  max_tokens: 500  # Keep responses concise for Slack

  # Optional: Use different models for different complexity
  routing:
    simple_queries:
      model: claude-3-5-haiku-20241022
      triggers: ["greeting", "simple_question"]
    complex_queries:
      model: claude-3-5-sonnet-20241022
      triggers: ["analysis", "reasoning", "code"]

# Slack Platform Configuration
platforms:
  - type: slack
    enabled: true

    # Bot behavior
    respond_to:
      - mentions  # @ai-assistant
      - direct_messages  # DMs to bot
      # Optional: Add specific channels
      # - channel: C123ABC456  # Specific channel ID

    # Thread handling
    threads:
      auto_reply_in_thread: true  # Reply in thread vs main channel
      track_context: true  # Remember thread context

    # Reaction feedback
    reactions:
      processing: "eyes"  # 👀 while thinking
      success: "white_check_mark"  # ✅ when done
      error: "x"  # ❌ on errors

# System Instructions (Bot Personality)
instructions: |
  You are a helpful AI assistant for our team on Slack.

  Your name is AI Assistant. You help with:
  - Answering questions about our projects, tools, and processes
  - Searching internal documentation
  - Scheduling meetings and managing calendars
  - Summarizing long threads
  - Brainstorming and problem-solving

  Guidelines:
  - Keep responses concise (Slack messages should be scannable)
  - Use bullet points and formatting for clarity
  - If you need more context, ask clarifying questions
  - When searching knowledge base, cite sources
  - Be friendly and helpful
  - If you don't know something, admit it and suggest who to ask

# Optional: Skills for extended functionality
skills:
  - name: web-search
    enabled: true
  - name: knowledge-base
    enabled: true
    sources:
      - notion
      - google-drive
  - name: calendar
    enabled: true
    integration: google-calendar
  - name: github
    enabled: true

# Conversation Memory
conversation_memory:
  type: redis  # or 'buffer' for simple in-memory
  ttl: 86400  # 24 hours
  max_messages_per_conversation: 50

# Logging
logging:
  level: info
  file: ./logs/slack-bot.log
  rotate: daily

3.2 Configure Environment Variables

Create .env file for secrets:

nano .env

Add your credentials:

# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_APP_TOKEN=xapp-your-app-token-here  # If using Socket Mode
SLACK_SIGNING_SECRET=your-signing-secret  # From Slack app settings

# AI Provider Keys
ANTHROPIC_API_KEY=sk-ant-your-key-here
# or OPENAI_API_KEY=sk-your-key-here

# Optional: Integration credentials
GOOGLE_CALENDAR_CREDENTIALS=./google-credentials.json
GITHUB_TOKEN=ghp_your-github-token
NOTION_API_KEY=secret_your-notion-key

Important: Never commit .env to Git. Add to .gitignore:

echo ".env" >> .gitignore

Step 4: Configure Slack Event Subscriptions

Your bot needs to receive messages from Slack. Two options:

Option A: Socket Mode (Easier for Testing)

Socket Mode uses WebSocket connection—no public URL needed. Great for testing and development.

Enable Socket Mode:

  1. Go to Slack App settings → “Socket Mode”
  2. Enable Socket Mode
  3. Click “Generate” to create App-Level Token
  4. Token Name: “slack-bot-connection”
  5. Add scope: connections:write
  6. Copy token (starts with xapp-) → Add to .env as SLACK_APP_TOKEN

Update OpenClaw config:

platforms:
  - type: slack
    enabled: true
    mode: socket  # Use Socket Mode

Pros: No public URL needed, easier setup, instant updates. Cons: WebSocket can disconnect, not suitable for production at scale.

Option B: Events API (Production Setup)

Events API uses HTTP webhooks—requires public URL but more reliable for production.

Set up webhook endpoint:

  1. Ensure your server has public IP or domain
  2. Set up reverse proxy (nginx) with SSL (Let’s Encrypt)
  3. OpenClaw will expose webhook at http://localhost:3000/slack/events

Configure Events API in Slack:

  1. Go to Slack App settings → “Event Subscriptions”
  2. Enable Events
  3. Request URL: https://your-domain.com/slack/events (Slack will verify URL—OpenClaw must be running)
  4. Under “Subscribe to bot events”, add:
    • app_mention - Bot was mentioned
    • message.im - Direct message to bot
    • message.channels - Message in channel (if monitoring)
    • message.groups - Message in private channel
  5. Click “Save Changes”

Update OpenClaw config:

platforms:
  - type: slack
    enabled: true
    mode: events  # Use Events API
    port: 3000  # Port for webhook

Nginx configuration (if using):

server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Step 5: Start the Bot

Now start OpenClaw and test the bot.

5.1 Start OpenClaw

cd ~/slack-ai-bot

# Development mode (see logs in terminal)
openclaw start

# Or production mode with PM2 (runs in background)
pm2 start openclaw --name slack-bot -- start
pm2 save  # Save configuration
pm2 startup  # Auto-start on server reboot

Check logs:

# If using openclaw start directly
# Logs appear in terminal

# If using PM2
pm2 logs slack-bot

# Or check log file
tail -f logs/slack-bot.log

You should see:

[Slack] Connected to workspace: Your Team Name
[Slack] Bot user: @ai-assistant
[Slack] Listening for mentions and DMs...

5.2 Test the Bot

In Slack:

  1. Open your Slack workspace
  2. Find the bot in Apps or DM it directly

Test 1: Direct Message

You: Hello!

Bot: Hi! I'm AI Assistant, here to help your team. I can:
• Answer questions about projects and processes
• Search our knowledge base
• Help with scheduling
• Summarize threads
• And much more!

How can I assist you today?

Test 2: Channel Mention

In any channel where bot is added:

You: @ai-assistant What's the weather in Tokyo?

Bot: Let me search for current weather in Tokyo...

[Bot responds with weather information]

Test 3: Thread Context

User1: We need to decide on the API authentication method.
User2: I think OAuth 2.0 is best.
You: @ai-assistant summarize this discussion

Bot: Summary of this thread:
• Topic: API authentication method selection
• Proposal: OAuth 2.0 (suggested by User2)
• Status: Open for discussion
• Recommendation: Confirm OAuth 2.0 requirements and implementation timeline

Need me to create a decision document?

Step 6: Add Custom Skills

Extend your bot with OpenClaw skills.

openclaw add skill web-search

Usage:

You: @ai-assistant search for latest react 19 features

Bot: [Searches web and summarizes findings]

Key features in React 19:
• Server Components (stable)
• Actions for form handling
• Enhanced Suspense
• New use() hook for async data

Sources: [Links to articles]

6.2 Connect Knowledge Base

For Notion integration:

skills:
  - name: knowledge-base
    enabled: true
    sources:
      - type: notion
        database_id: your-notion-database-id
        api_key: ${NOTION_API_KEY}

Usage:

You: @ai-assistant how do we handle customer refunds?

Bot: According to our Customer Service Handbook (Notion):

Refund Policy:
1. Requests within 30 days: Full refund
2. After 30 days: Store credit
3. Approval required for amounts >$500

Process:
- Check order status
- Verify refund eligibility
- Submit via admin panel
- Notify customer within 24 hours

[Link to full documentation]

6.3 Calendar Integration

openclaw add skill calendar

Configure Google Calendar:

  1. Create service account at Google Cloud Console
  2. Enable Google Calendar API
  3. Download JSON credentials → Save as google-credentials.json
  4. Share calendar with service account email

Usage:

You: @ai-assistant schedule a meeting with @john and @sarah next Tuesday 2pm

Bot: Checking availability...

Available time found: Tuesday, Feb 27 at 2:00pm PST

Sending calendar invites to:
- @john (john@company.com)
- @sarah (sarah@company.com)

Meeting title: Discussion with John and Sarah
Duration: 1 hour

Confirmed! ✅

6.4 GitHub Integration

openclaw add skill github

Add GitHub personal access token to .env.

Usage:

You: @ai-assistant list open PRs in main repo

Bot: Open Pull Requests in company/main-repo:

1. feat: Add user dashboard (#234)
   Author: @alice | +450/-120 lines
   Status: 2 approvals, CI passing ✅

2. fix: Memory leak in data processor (#231)
   Author: @bob | +45/-38 lines
   Status: 1 approval, awaiting review

3. docs: Update API documentation (#228)
   Author: @charlie | +200/-15 lines
   Status: Draft (not ready for review)

Total: 3 open PRs
[View all PRs]

6.5 Custom Skill Development

Create custom skills for your team’s specific needs.

Example: Company Wiki Search

# skills/wiki-search.yaml
name: wiki-search
description: Search company internal wiki

commands:
  - trigger: wiki
    pattern: "(?:search |find |lookup )?wiki:? (.*)"
    action: search_wiki

config:
  wiki_url: https://wiki.company.internal
  api_key: ${WIKI_API_KEY}

actions:
  search_wiki:
    type: http_request
    method: POST
    url: "{config.wiki_url}/api/search"
    headers:
      Authorization: "Bearer {config.api_key}"
    body:
      query: "{match.1}"
      limit: 5
    response_format: |
      Found {results.count} results:

      {for result in results}
      • {result.title}
        {result.excerpt}
        {result.url}
      {endfor}

Step 7: Production Deployment

For production, add reliability and monitoring.

7.1 Use Process Manager

PM2 keeps bot running and auto-restarts on crashes:

# Start with PM2
pm2 start openclaw --name slack-bot -- start

# Configure auto-restart on crashes
pm2 startup
pm2 save

# Monitor
pm2 status
pm2 logs slack-bot
pm2 monit

7.2 Set Up Monitoring

Log monitoring:

# Install log rotation
sudo apt install logrotate

# Create rotation config
sudo nano /etc/logrotate.d/slack-bot

Logrotate config:

/home/user/slack-ai-bot/logs/*.log {
    daily
    missingok
    rotate 30
    compress
    notifempty
    create 0640 user user
    sharedscripts
    postrotate
        pm2 reload slack-bot
    endscript
}

Health checks:

# Add to openclaw.config.yaml
monitoring:
  health_check:
    enabled: true
    endpoint: /health
    port: 3001

  alerts:
    - type: email
      email: admin@company.com
      triggers:
        - bot_offline
        - error_rate_high
        - response_time_slow

  metrics:
    - messages_processed
    - response_time
    - error_rate
    - active_conversations

7.3 Database for Conversation Memory

For multi-server deployments or persistence, use Redis:

# Install Redis
sudo apt install redis-server

# Start Redis
sudo systemctl start redis
sudo systemctl enable redis

Update config:

conversation_memory:
  type: redis
  redis_url: redis://localhost:6379
  ttl: 86400  # 24 hours
  max_messages_per_conversation: 50

7.4 SSL and Security

Enable HTTPS (required for production Events API):

# Install Certbot
sudo apt install certbot python3-certbot-nginx

# Get SSL certificate
sudo certbot --nginx -d your-domain.com

# Auto-renewal
sudo certbot renew --dry-run

Security hardening:

  1. Firewall: Only open necessary ports (22, 80, 443)
  2. SSH: Disable password auth, use keys only
  3. Updates: Enable automatic security updates
  4. Backups: Regular backups of configuration and logs
  5. API keys: Rotate periodically, use environment variables

7.5 Docker Deployment (Optional)

Dockerfile:

FROM node:18-alpine

WORKDIR /app

# Install OpenClaw
RUN npm install -g openclaw

# Copy configuration
COPY openclaw.config.yaml .
COPY .env .
COPY skills/ ./skills/

# Expose port
EXPOSE 3000

# Start bot
CMD ["openclaw", "start"]

docker-compose.yml:

version: '3.8'

services:
  slack-bot:
    build: .
    container_name: slack-ai-bot
    restart: unless-stopped
    environment:
      - NODE_ENV=production
    env_file:
      - .env
    ports:
      - "3000:3000"
    volumes:
      - ./logs:/app/logs
    depends_on:
      - redis

  redis:
    image: redis:7-alpine
    container_name: slack-bot-redis
    restart: unless-stopped
    volumes:
      - redis_data:/data

volumes:
  redis_data:

Deploy:

docker-compose up -d
docker-compose logs -f slack-bot

Advanced Features

Multi-Channel Routing

Direct different channels to different configurations:

platforms:
  - type: slack
    channel_config:
      - channel: C123ABC456  # #engineering
        skills: [github, code-review, docs-search]
        ai_model: claude-3-5-sonnet-20241022  # Smarter model

      - channel: C789DEF123  # #support
        skills: [knowledge-base, ticket-system]
        ai_model: claude-3-5-haiku-20241022  # Faster model

      - channel: C456GHI789  # #general
        skills: [web-search, calendar, reminders]
        ai_model: claude-3-5-haiku-20241022

Admin Commands

Restrict certain commands to admins:

admin_commands:
  enabled: true
  admins:
    - U123ABC456  # Slack user IDs
    - U789DEF123

  commands:
    - trigger: "/bot reload"
      action: reload_configuration

    - trigger: "/bot stats"
      action: show_statistics

    - trigger: "/bot logs"
      action: show_recent_logs

Usage Analytics

Track bot usage:

analytics:
  enabled: true
  track:
    - user_interactions
    - skill_usage
    - response_times
    - error_rates

  reporting:
    daily_summary: true
    post_to_channel: C987ZYX654  # #bot-analytics
    format: |
      📊 Daily Bot Analytics:

      Total messages: {total_messages}
      Unique users: {unique_users}
      Avg response time: {avg_response_time}

      Top skills:
      1. {top_skill_1}: {usage_count_1}
      2. {top_skill_2}: {usage_count_2}
      3. {top_skill_3}: {usage_count_3}

      Errors: {error_count}

Troubleshooting

Bot Not Responding

Check bot is running:

pm2 status
# or
ps aux | grep openclaw

Check logs:

pm2 logs slack-bot
# or
tail -f logs/slack-bot.log

Common issues:

  • Bot token incorrect or expired → Regenerate in Slack app settings
  • Bot not invited to channel → Invite bot: /invite @ai-assistant
  • Scopes insufficient → Add missing scopes and reinstall app
  • Events API URL unreachable → Check firewall, nginx config, SSL

Slow Responses

Causes and fixes:

  1. Slow AI model: Switch to faster model (Haiku instead of Opus)
  2. Network latency: Check API endpoint ping times
  3. Server overload: Check CPU/memory usage, scale up
  4. Database slow: Optimize Redis, add caching

High API Costs

Optimize costs:

ai:
  cost_optimization:
    - route_simple_to_cheap_model: true
    - compress_conversation_history: true
    - cache_frequent_queries: true
    - use_shorter_system_prompts: true

  models:
    cheap: claude-3-5-haiku-20241022  # $0.25 / 1M tokens
    expensive: claude-3-5-sonnet-20241022  # $3 / 1M tokens

  routing:
    - if: simple_query
      model: cheap
    - if: complex_query
      model: expensive

Or use local models for zero API costs:

ai:
  provider: ollama
  model: llama3  # Free, runs locally

See local LLM guide.

Cost Breakdown

Setup costs:

  • Server: $0 (if existing) to $500 (if buying dedicated hardware)
  • Development time: 1-2 hours for basic setup

Monthly costs:

  • VPS hosting: $10-50
  • AI API (moderate use, 10,000 messages/month):
    • Claude Haiku: ~$20
    • GPT-3.5: ~$15
    • GPT-4: ~$100
    • Local LLM: $0 (only electricity ~$5)
  • Total: $15-150/month

Comparison to commercial bots:

  • Slack AI bots: $10-20 per user/month
  • 25-user team: $250-500/month ($3,000-6,000/year)
  • Self-hosted break-even: 2-5 users

For 50+ person teams, self-hosting saves $10,000-30,000 annually.

Next Steps

You now have a fully functional self-hosted Slack AI bot.

To expand:

  1. Add more OpenClaw skills
  2. Implement custom skills for your workflows
  3. Fine-tune prompts for your team’s language
  4. Set up monitoring and alerting
  5. Migrate to local LLMs for zero API costs

For other platforms:

Join the community:

  • Star OpenClaw on GitHub
  • Share your Slack bot configuration
  • Learn from others’ implementations

Self-hosted Slack AI bots give you the productivity benefits of AI assistants while maintaining complete control over your team’s data. No subscriptions, no vendor lock-in, no privacy compromises.

Build your team’s AI assistant today.

Ready to Get Started?

Install OpenClaw and build your own AI assistant today.

Related Articles