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:
- Lark Enterprise Account - Requires administrator permissions to create applications
- OpenClaw Installed - Refer to the previous article
- API Key - Your AI model’s API Key
Step 1: Create a Lark Application
1.1 Access the Developer Console
- Open the Lark Open Platform
- Log in with your enterprise account
- 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 IDApp Secret
Step 2: Configure Bot Permissions
2.1 Add Permissions
Add the following permissions in “Permission Management”:
| Permission Name | Permission Description |
|---|---|
| im:chat:message:send_as_bot | Send messages as a bot |
| im:message:send.as | Send messages |
| im:chat:list | Get group list |
| im:chat:members | Get group members |
2.2 Publish Application
- Click “Version Management & Release”
- Create a new version
- Fill in version information
- 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"
}
}
}
3.3 Configure Environment Variables (Recommended)
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
-
Go to “Event Subscription” in the Lark Developer Console
-
Add the following events:
im.message.message_received_v1- Receive messagesim.chat.member.bot_added_v1- Bot added to groupim.chat.member.bot_removed_v1- Bot removed from group
-
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:
- User opens a direct message chat with the bot
- Sends a message
- AI replies automatically
5.2 Group Chat Mode
Add the bot to a group chat:
- Click “Add Bot” in group settings
- Select “OpenClaw AI Assistant”
- @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:
- Confirm the app has been published and approved
- Confirm event subscription is configured
- Check if the callback URL is accessible
- 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:
- Direct Message Test: Send “Hello” to the bot
- 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: