feishu-channel

Original🇨🇳 Chinese
Translated
1 scriptsChecked / no sensitive code detected

Two-way integration channel between Feishu (Lark/Feishu) and OpenClaw. It implements message receiving and sending through Feishu bot, supporting private chat, group chat, @mention detection, card messages, and file transfer. This skill is used when you need to interact with AI assistants via Feishu, receive Feishu messages to trigger AI responses, or send messages from OpenClaw to Feishu. Difference from feishu-automation: this skill focuses on message channel integration, while feishu-automation focuses on automated operations of Feishu platform (such as multidimensional tables, documents, etc.)

2installs
Added on

NPX Install

npx skill4agent add aaaaqwq/claude-code-skills feishu-channel

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Feishu Channel Integration

Integrate Feishu into OpenClaw to implement a two-way message channel.

Difference from feishu-automation

Featurefeishu-channelfeishu-automation
Main PurposeMessage channel integrationPlatform automation operations
Message Receiving✅ Webhook event subscription❌ Not supported
Message Sending✅ Real-time conversation✅ Notification push
Multidimensional Table❌ Not involved✅ Full support
Document Management❌ Not involved✅ Full support
Applicable ScenariosAI chatbotData synchronization, automated workflow

Architecture Overview

┌─────────────┐     ┌──────────────────┐     ┌─────────────┐
│   Feishu User   │ ←→  │   Feishu Open Platform    │ ←→  │  OpenClaw   │
│  (Private/Group Chat) │     │   (Webhook)      │     │   Gateway   │
└─────────────┘     └──────────────────┘     └─────────────┘
                    ┌──────────────────┐
                    │   Webhook Service    │
                    │   - Event Verification      │
                    │   - Message Parsing      │
                    │   - Format Conversion      │
                    └──────────────────┘

Core Components

1. Feishu Bot Application

A self-built enterprise application created on Feishu Open Platform, responsible for:
  • Receiving user messages (via event subscription)
  • Sending messages (via message API)
  • Managing permissions and security

2. Webhook Service

Receives Feishu event pushes and forwards them to OpenClaw Gateway.

3. Message Sending API

Send messages via lark-mcp tool or directly calling Feishu API.

Quick Start

Prerequisites

  • Feishu Open Platform account
  • Enterprise self-built application (with bot capability)
  • OpenClaw Gateway is running
  • Publicly accessible Webhook URL (or use intranet penetration)

1. Create Feishu Application

  1. Visit Feishu Open Platform
  2. Create an enterprise self-built application
  3. Add the "Bot" capability
  4. Configure permissions (see the permission list below)
  5. Obtain App ID and App Secret

2. Configure Event Subscription

  1. On the application management page, enter "Event Subscription"
  2. Configure request URL:
    https://your-domain.com/webhook/feishu
  3. Subscribe to events:
    • im.message.receive_v1
      - Receive messages
    • im.message.message_read_v1
      - Message read (optional)

3. Deploy Webhook Service

bash
cd /home/aa/clawd/skills/feishu-channel
npm install
cp .env.example .env
# Edit .env to fill in the configuration
npm start

4. Publish Application

  1. Submit for review on Feishu Open Platform
  2. Publish after passing the review
  3. Search for and add the bot in Feishu

Configuration Instructions

Environment Variables (.env)

env
# Feishu application configuration (required)
FEISHU_APP_ID=cli_xxxxxxxxxx
FEISHU_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx

# Event subscription verification Token
FEISHU_VERIFICATION_TOKEN=xxxxxxxxxxxxxxxx
# Event encryption Key (optional, recommended to enable)
FEISHU_ENCRYPT_KEY=xxxxxxxxxxxxxxxx

# OpenClaw Gateway configuration
OPENCLAW_GATEWAY_URL=http://127.0.0.1:18789
OPENCLAW_WEBHOOK_SECRET=your_webhook_secret

# Security configuration
# Allowed user open_id (comma separated, leave blank to allow all)
ALLOWED_USERS=ou_xxx,ou_yyy
# Allowed group chat chat_id (comma separated, leave blank to allow all)
ALLOWED_GROUPS=oc_xxx,oc_yyy

# Group chat behavior
REQUIRE_MENTION_IN_GROUP=true

# Service port
PORT=3002

# Log level
LOG_LEVEL=info

Feishu Application Permissions

PermissionDescriptionRequired
im:message
Get and send private and group messages
im:message.group_at_msg
Receive messages @bot in group chat
im:message.p2p_msg
Receive private messages sent by users to the bot
im:chat
Get group informationRecommended
contact:user.base
Get basic user informationRecommended
im:resource
Get and upload image or file resourcesOptional

OpenClaw Configuration (openclaw.json)

json
{
  "channels": {
    "feishu": {
      "enabled": true,
      "appId": "cli_xxxxxxxxxx",
      "appSecret": "env:FEISHU_APP_SECRET",
      "webhookUrl": "https://your-domain.com/webhook/feishu",
      "dmPolicy": "allowlist",
      "allowFrom": ["ou_xxx", "ou_yyy"],
      "groups": {
        "oc_xxx": {
          "name": "Work Group",
          "requireMention": true
        }
      }
    }
  }
}

Message Format

Received Message (Webhook Event)

Original Feishu event format:
json
{
  "schema": "2.0",
  "header": {
    "event_id": "xxx",
    "event_type": "im.message.receive_v1",
    "create_time": "1706745600000",
    "token": "verification_token",
    "app_id": "cli_xxx"
  },
  "event": {
    "sender": {
      "sender_id": {
        "open_id": "ou_xxx",
        "user_id": "xxx",
        "union_id": "on_xxx"
      },
      "sender_type": "user"
    },
    "message": {
      "message_id": "om_xxx",
      "root_id": "",
      "parent_id": "",
      "create_time": "1706745600000",
      "chat_id": "oc_xxx",
      "chat_type": "group",
      "message_type": "text",
      "content": "{\"text\":\"@_user_1 你好\"}",
      "mentions": [
        {
          "key": "@_user_1",
          "id": {
            "open_id": "ou_bot"
          },
          "name": "OpenClaw Assistant"
        }
      ]
    }
  }
}
Converted OpenClaw format:
json
{
  "type": "message",
  "channel": "feishu",
  "messageId": "om_xxx",
  "from": {
    "id": "ou_xxx",
    "name": "Zhang San"
  },
  "chat": {
    "id": "oc_xxx",
    "type": "group",
    "name": "Work Group"
  },
  "text": "Hello",
  "mentions": ["ou_bot"],
  "isMentioned": true,
  "timestamp": 1706745600000
}

Sending Message

Using lark-mcp Tool

javascript
// Send text message
await mcp__lark-mcp_sendMessage({
  receive_id: "ou_xxx",  // or oc_xxx (group chat)
  receive_id_type: "open_id",  // or chat_id
  msg_type: "text",
  content: JSON.stringify({
    text: "Received, processing..."
  })
});

// Send rich text message
await mcp__lark-mcp_sendMessage({
  receive_id: "oc_xxx",
  receive_id_type: "chat_id",
  msg_type: "post",
  content: JSON.stringify({
    zh_cn: {
      title: "Task Completed",
      content: [
        [
          { tag: "text", text: "Completed " },
          { tag: "a", text: "View Details", href: "https://example.com" }
        ]
      ]
    }
  })
});

// Send card message
await mcp__lark-mcp_sendMessage({
  receive_id: "oc_xxx",
  receive_id_type: "chat_id",
  msg_type: "interactive",
  content: JSON.stringify({
    config: { wide_screen_mode: true },
    header: {
      template: "turquoise",
      title: { content: "Notification", tag: "plain_text" }
    },
    elements: [
      {
        tag: "div",
        text: { content: "**Important Notice**", tag: "lark_md" }
      },
      {
        tag: "action",
        actions: [
          {
            tag: "button",
            text: { content: "Confirm", tag: "plain_text" },
            type: "primary"
          }
        ]
      }
    ]
  })
});

Using HTTP API

bash
# Send text message
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "receive_id": "ou_xxx",
    "msg_type": "text",
    "content": "{\"text\":\"Hello!\"}"
  }'

Security Policy

Event Verification

Feishu event subscription supports two verification methods:
  1. Verification Token: Simple Token verification
  2. Encrypt Key: AES encryption (recommended)
javascript
// Verification example
function verifyEvent(body, token) {
  if (body.token !== token) {
    throw new Error('Invalid verification token');
  }
}

// Decryption example
function decryptEvent(encrypt, key) {
  const crypto = require('crypto');
  const decipher = crypto.createDecipheriv(
    'aes-256-cbc',
    crypto.createHash('sha256').update(key).digest(),
    Buffer.alloc(16, 0)
  );
  return JSON.parse(
    decipher.update(encrypt, 'base64', 'utf8') + decipher.final('utf8')
  );
}

Private Chat Policy

PolicyDescription
open
Allow all users to send private chats (dangerous)
allowlist
Only allow users in the allowFrom list

Group Chat Policy

ConfigurationDescription
requireMention: true
Must @the bot to respond
allowFrom
List of users allowed to trigger in the group

Usage Scenarios

1. Intelligent Q&A Bot

User: @OpenClaw Assistant Help me check today's meeting schedule
Bot: Today's meeting schedule:
- 10:00 Product Review Meeting (Conference Room A)
- 14:00 Technology Sharing Meeting (Online)
- 16:00 Weekly Meeting (Conference Room B)

2. Workflow Notification

javascript
// Send notification when task is completed
await mcp__lark-mcp_sendMessage({
  receive_id: "oc_work_group",
  receive_id_type: "chat_id",
  msg_type: "interactive",
  content: JSON.stringify({
    header: {
      template: "green",
      title: { content: "✅ Task Completed", tag: "plain_text" }
    },
    elements: [
      {
        tag: "div",
        text: { content: "Data synchronization task completed\nProcessed records: 1,234 entries", tag: "lark_md" }
      }
    ]
  })
});

3. Approval Process

User: @OpenClaw Assistant Submit leave application, take one day off tomorrow
Bot: Leave application received, submitting for approval...
     [Card message: Leave application details + Approval button]

Troubleshooting

Webhook Cannot Receive Messages

  1. Check if the Webhook URL is publicly accessible
  2. Check if the Verification Token is correct
  3. View the event push log of Feishu Open Platform
  4. Confirm that the application has been published and the user has added the robot

Message Sending Failed

  1. Check App ID and App Secret
  2. Confirm that the application permissions are enabled
  3. Check if access_token is expired
  4. View the error code returned by the API

Insufficient Permissions

  1. Check application permissions on Feishu Open Platform
  2. Confirm that the permissions have been approved
  3. Re-obtain access_token

Limit Description

Feishu Platform Limits

  • API call frequency limit (refer to official documentation)
  • Message length limit
  • File size limit

Functional Limits

  • Voice messages are not supported
  • Card message interaction requires additional callback configuration
  • Some advanced functions require enterprise authentication

Related Files

  • scripts/feishu-webhook.js
    - Webhook service code
  • .env.example
    - Environment variable template
  • references/feishu-api.md
    - Feishu API reference
  • references/message-types.md
    - Message type description

TODO

  • Create Feishu application and obtain credentials
  • Configure event subscription
  • Deploy Webhook service
  • Test private chat message sending and receiving
  • Test group chat @mention
  • Configure security policy
  • Implement card message interaction