Add complete Feishu (Lark) channel plugin with WebSocket support for real-time messaging. Features: - Send and receive text messages in direct chats and group chats - WebSocket-based event subscription (im.message.receive_v1) - Multi-account support - Interactive CLI onboarding (pnpm clawdbot channels add feishu) - Optional encryption and verification token support Implementation: - Client wrapper for @larksuiteoapi/node-sdk - Event dispatcher for message handling - Account management and configuration - Comprehensive README with setup guide and troubleshooting Files: - package.json, clawdbot.plugin.json: Plugin metadata and dependencies - index.ts: Plugin entry point - src/accounts.ts: Account resolution and validation - src/channel.ts: Channel plugin and dock definitions - src/client.ts: Feishu API client wrapper - src/monitor.ts: WebSocket event monitoring - src/onboarding.ts: Interactive CLI setup wizard - src/runtime.ts: Runtime context management - src/types.ts: TypeScript type definitions - README.md: Configuration guide and documentation |
||
|---|---|---|
| .. | ||
| src | ||
| clawdbot.plugin.json | ||
| index.ts | ||
| package.json | ||
| README.md | ||
Feishu Extension for Clawdbot
This extension allows Clawdbot to integrate with Feishu (Lark), enabling it to send and receive messages within your Feishu organization.
Configuration
To use this extension, you need to configure it with credentials from the Feishu Open Platform.
Prerequisites
- A Feishu (Lark) account and an organization.
- Access to the Feishu Open Platform.
Quick Start
You can interactively configure this extension using the CLI:
pnpm clawdbot channels add feishu
This wizard will guide you through entering the required credentials.
Features
- Send & Receive Messages: Supports sending and receiving Text messages in direct chats and group chats.
- Note: Other message types (images, files, etc.) may be displayed as generic placeholders.
- Multi-Account Support: Configure multiple Feishu bots/accounts.
Step-by-Step Configuration Guide
-
Create a Feishu Application:
- Log in to the Feishu Open Platform.
- Create a specific "Enterprise Self-Built App" for your bot.
-
Get App Credentials:
- Navigate to Credentials & Basic Info.
- Copy the App ID and App Secret. These correspond to
appIdandappSecretin the configuration.
-
Configure Event Subscriptions:
- Navigate to Event Subscriptions.
- Set the Encrypt Key (Optional, but recommended).
- Set the Verification Token (Optional).
- Set the Request URL to your bot's endpoint (e.g.,
https://your-bot-domain.com/api/feishu). - Add Events: Search for and add the following event:
im.message.receive_v1(Receive messages)
-
Add Permissions:
- Navigate to Permissions & Scopes.
- Add the necessary permissions:
im:message(Access messages)im:message:send_as_bot(Send messages as bot)im:chat(Access group chats)
- Important: Create and publish a version of your app to apply these permissions.
-
Enable Bot Capability:
- Navigate to App Capabilities -> Bot.
- Enable the bot capability.
Configuration Example
Add the following to your clawdbot configuration (e.g., in clawdbot.config.json or via environment variables):
{
"extensions": {
"feishu": {
"appId": "cli_...",
"appSecret": "...",
"encryptKey": "...", // Optional: Required if encryption is enabled
"verificationToken": "..." // Optional: Required for event verification
}
}
}
Note
encryptKeyandverificationTokenare optional for basic bot functionality (sending messages). However, they are required if you want to:
- Receive events securely (verify the source).
- Have enabled Encrypt Key in the Feishu Event Subscriptions settings.
Multi-Account Configuration
If you need to configure multiple Feishu bots, you can use the accounts structure:
{
"channels": {
"feishu": {
"enabled": true,
"accounts": {
"default": {
"enabled": true,
"appId": "cli_xxx",
"appSecret": "xxx",
"encryptKey": "xxx",
"verificationToken": "xxx"
},
"team-bot": {
"enabled": true,
"name": "Team Bot",
"appId": "cli_yyy",
"appSecret": "yyy",
"encryptKey": "yyy",
"verificationToken": "yyy"
}
}
}
}
}
Troubleshooting
Bot not receiving messages
- Check Event Subscription URL: Ensure the Request URL is correctly configured and accessible from Feishu servers.
- Verify Event Subscription: Make sure
im.message.receive_v1event is added and the app version is published. - Check Permissions: Ensure all required permissions are granted and the app version is published.
- Review Logs: Check Clawdbot logs for connection errors or event processing issues.
Authentication errors
- Verify Credentials: Double-check that
appIdandappSecretare correct. - Check App Status: Ensure the app is enabled and not suspended in Feishu Open Platform.
Encryption/Verification errors
- Match Configuration: Ensure
encryptKeyandverificationTokenin your config match exactly what's set in Feishu Event Subscriptions. - Optional Fields: If you haven't enabled encryption in Feishu, you can leave these fields empty.
Current Limitations
- Message Types: Currently only text messages are fully supported. Other types (images, files, cards) will be displayed as generic placeholders.
- Reactions: Message reactions are not yet supported.
- Threads: Message threads are not yet supported.
- Media Upload: Sending images/files is not yet implemented.