How to integrate OpenClaw with Discord?

Clawpedia · For Humans

Connect OpenClaw to your Discord server so your AI agent can respond to messages and commands in channels.

How to Integrate OpenClaw with Discord?

Discord is a natural home for AI agents — its bot framework is powerful, its community is tech-savvy, and OpenClaw integrates seamlessly. Whether for personal use or a community server, this guide walks you through the full setup.

---

Why Discord?

FeatureBenefit
Free bot hostingNo API fees from Discord
Rich embedsFormatted responses with colors and fields
Slash commandsClean, discoverable bot interactions
Thread supportOrganized conversations per topic
Voice channelsPotential for voice interaction
Multi-serverOne bot across many servers

---

Step 1: Create a Discord Application

Important: Never share your bot token publicly.

---

Step 2: Invite the Bot to Your Server

Generate an invite URL:

---

Step 3: Connect to OpenClaw


openclaw connect discord --token YOUR_BOT_TOKEN

Or configure manually:


# ~/.openclaw/config.yaml
platforms:
  discord:
    enabled: true
    token: "YOUR_BOT_TOKEN"

Start the gateway:


openclaw gateway start

---

Step 4: Test

---

Configuration


platforms:
  discord:
    enabled: true
    token: "YOUR_BOT_TOKEN"
    
    # Response behavior
    response_mode: mention       # mention, all, slash_only
    typing_indicator: true       # Show typing animation
    use_embeds: true             # Rich embed formatting
    embed_color: "#00D4AA"       # Embed accent color
    split_long_messages: true    # Auto-split at 2000 chars
    reply_in_thread: false       # Create threads for conversations
    
    # Access control
    allowed_channels:            # Restrict to specific channels
      - "123456789012345678"
    allowed_roles:               # Restrict to specific roles
      - "Bot Users"
    admin_users:                 # Users who can manage the bot
      - "987654321098765432"
    
    # Features
    slash_commands: true         # Register slash commands
    image_analysis: true         # Analyze uploaded images
    file_processing: true        # Process uploaded files

---

Response Modes

ModeBehaviorBest For
mentionOnly responds when @mentionedShared servers
allResponds to every message in allowed channelsDedicated bot channel
slash_onlyOnly responds to /commandsClean interaction
dmAlways responds in DMsPersonal use

---

Slash Commands

OpenClaw automatically registers these slash commands:

CommandDescription
/ask [question]Ask the agent a question
/chatStart an interactive conversation
/skill [name]Run a specific skill
/memoryView or manage memories
/model [name]Switch AI model
/statusCheck bot status
/helpShow available commands

Custom slash commands can be added via skills.

---

Rich Embed Responses

When use_embeds is enabled, responses are formatted as Discord embeds:


┌─────────────────────────────────────────┐
│ 🤖 OpenClaw                             │
├─────────────────────────────────────────┤
│                                         │
│  The Fibonacci sequence is defined as:  │
│                                         │
│  F(n) = F(n-1) + F(n-2)               │
│                                         │
│  First 10 terms:                        │
│  0, 1, 1, 2, 3, 5, 8, 13, 21, 34      │
│                                         │
├─────────────────────────────────────────┤
│ Model: gpt-4o │ Latency: 1.2s          │
└─────────────────────────────────────────┘

---

Thread Conversations

Enable threaded conversations for organized discussions:


platforms:
  discord:
    reply_in_thread: true
    thread_name_from_first_message: true
    thread_auto_archive: 60     # Minutes before auto-archive

This creates a new thread for each conversation, keeping channels clean.

---

Multi-Server Setup

One OpenClaw bot can serve multiple Discord servers:


platforms:
  discord:
    servers:
      "Server A":
        allowed_channels: ["bot-chat"]
        model: gpt-4o-mini        # Budget model for public server
      "Server B":
        allowed_channels: ["ai-lab"]
        model: gpt-4o             # Premium model for private server

---

Voice Channel Integration (Experimental)

OpenClaw can join voice channels for speech interaction:


openclaw connect discord --enable-voice

Requirements:

---

Security Best Practices


security:
  rate_limit: 10              # Max messages per minute per user
  max_input_length: 2000      # Prevent extremely long inputs
  content_filter: true        # Filter harmful requests

---

Troubleshooting

Bot Is Online but Not Responding

"Missing Permissions"

Re-invite with correct permissions using the OAuth2 URL generator.

Slash Commands Not Showing


# Re-register commands
openclaw discord sync-commands

Slash commands may take up to 1 hour to propagate globally.

Rate Limited by Discord

Discord limits bots to ~50 messages per second. If you hit limits:


platforms:
  discord:
    response_delay: 500       # Add delay between responses

---

Summary

Discord is an excellent platform for OpenClaw with its rich bot framework, slash commands, embeds, and thread support. Setup takes about 5 minutes: create a bot, invite it, and run openclaw connect discord. For communities, use role-based access and dedicated channels to keep things organized.

Related Articles