OpenClaw Lark Bot: A Practical Guide

Detailed Guide: Integrating OpenClaw with Lark for AI Agent Auto-Reply

Lark is ByteDance’s enterprise collaboration platform, supporting custom bot development. This article will detail how to integrate OpenClaw with Lark to build your own dedicated AI assistant.

Prerequisites

Before starting, you will need:

  1. Lark Enterprise Account - Requires administrator permissions to create applications
  2. OpenClaw Installed - Refer to the previous article
  3. API Key - Your AI model’s API Key

Step 1: Create a Lark Application

1.1 Access the Developer Console

  1. Open the Lark Open Platform
  2. Log in with your enterprise account
  3. Click “Create Application”

1.2 Configure Application Information

  • App Name: OpenClaw AI Assistant
  • App Description: AI assistant based on OpenClaw
  • App Icon: You can upload a cute robot icon

1.3 Get App ID and App Secret

After successful creation, navigate to “Credentials & Basic Info” to obtain:

  • App ID
  • App Secret

Step 2: Configure Bot Permissions

2.1 Add Permissions

Add the following permissions in “Permission Management”:

Permission NamePermission Description
im:chat:message:send_as_botSend messages as a bot
im:message:send.asSend messages
im:chat:listGet group list
im:chat:membersGet group members

2.2 Publish Application

  1. Click “Version Management & Release”
  2. Create a new version
  3. Fill in version information
  4. Submit for review (requires approval from the enterprise administrator)

Step 3: Configure Lark in OpenClaw

3.1 Enable Lark Plugin

openclaw plugins enable feishu

3.2 Configure Lark Credentials

Edit the configuration file ~/.openclaw/openclaw.json:

{
  "channels": {
    "feishu": {
      "enabled": true,
      "appId": "Your App ID",
      "appSecret": "Your App Secret",
      "dmPolicy": "pairing"
    }
  }
}
export FEISHU_APP_ID="Your App ID"
export FEISHU_APP_SECRET="Your App Secret"

Step 4: Configure Callback URL

4.1 Obtain Public URL

The Lark bot requires a public callback URL. You can use:

  • Method 1: Use ngrok

    ngrok http 18789
  • Method 2: Use Cloudflare Tunnel

    cloudflared tunnel --url http://localhost:18789

4.2 Configure Event Subscription

  1. Go to “Event Subscription” in the Lark Developer Console

  2. Add the following events:

    • im.message.message_received_v1 - Receive messages
    • im.chat.member.bot_added_v1 - Bot added to group
    • im.chat.member.bot_removed_v1 - Bot removed from group
  3. Set the callback URL to your public address:

https://your-domain/gateway/v1/feishu/webhook

4.3 Verify Callback

Click the “Verify” button to confirm the callback configuration is successful.

Step 5: Start the Service

# Restart OpenClaw gateway
openclaw gateway restart

# View logs
openclaw logs --follow

Usage Scenarios

5.1 Direct Message Mode

Users can add the bot as a friend for one-on-one conversations:

  1. User opens a direct message chat with the bot
  2. Sends a message
  3. AI replies automatically

5.2 Group Chat Mode

Add the bot to a group chat:

  1. Click “Add Bot” in group settings
  2. Select “OpenClaw AI Assistant”
  3. @mention the bot in the group to send messages

5.3 Configure Mention Mode

In group chats, you can require the bot to be @mentioned before replying:

{
  "channels": {
    "feishu": {
      "groups": {
        "*": {
          "requireMention": true
        }
      }
    }
  }
}

Advanced Configuration

6.1 Session Management

{
  "channels": {
    "feishu": {
      "dmPolicy": "allowlist",
      "allowFrom": ["User ID 1", "User ID 2"]
    }
  }
}

6.2 Message Filtering

{
  "channels": {
    "feishu": {
      "blockWords": ["Sensitive word 1", "Sensitive word 2"]
    }
  }
}

6.3 Custom Reply Prefix

{
  "channels": {
    "feishu": {
      "replyPrefix": "🤖 "
    }
  }
}

FAQ

Q: The bot is not receiving messages?

A: Check the following points:

  1. Confirm the app has been published and approved
  2. Confirm event subscription is configured
  3. Check if the callback URL is accessible
  4. Check OpenClaw logs for error messages

Q: Message sending failed?

A: Check if permissions are complete, especially the im:message:send.as permission.

Q: How to get User ID?

A: In the message event, the sender_id field contains the User ID.

Q: No response when @mentioning the bot in a group?

A: Confirm the requireMention configuration, or check if privacy mode is enabled.

Test Your Bot

After completing the above steps, try:

  1. Direct Message Test: Send “Hello” to the bot
  2. Group Chat Test: @mention the bot in a group and send “Write me a poem”

If everything is normal, you should receive a reply from the AI!

Summary

Through this article, you should have mastered:

  • Creating and configuring Lark applications
  • Enabling the Lark plugin in OpenClaw
  • Configuring message callbacks
  • Using direct message and group chat modes

The possibilities for Lark bots go far beyond this. You can continue to explore:

  • Scheduled task notifications
  • Integration with enterprise business workflows
  • Custom skill plugins

Feel free to discuss in the comments section! 🦞

Related Reading: