2.4 KiB
2.4 KiB
Feishu/Lark Bot Integration
This directory contains the Feishu bot integration for MimiClaw.
Features
- Send text messages to Feishu chats
- Receive messages via webhook (HTTP event subscription)
- Automatic message chunking (4096 chars per message)
- Tenant access token management with auto-refresh
- Message deduplication
- Reply to specific messages
- Support for both DM (p2p) and group chats
Configuration
Option 1: Build-time Configuration
- Copy the secrets template:
cp main/mimi_secrets.h.example main/mimi_secrets.h
- Edit
main/mimi_secrets.h:
#define MIMI_SECRET_FEISHU_APP_ID "cli_xxxxxxxxxxxxxx"
#define MIMI_SECRET_FEISHU_APP_SECRET "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
- Rebuild:
idf.py fullclean && idf.py build
Option 2: Runtime Configuration (CLI)
mimi> set_feishu_creds cli_xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Feishu App Setup
- Go to Feishu Open Platform
- Create an app and get App ID / App Secret
- Enable permissions:
im:message- Send and receive messagesim:message:send_as_bot- Send messages as bot
- Configure Event Subscription:
- Request URL:
http://<ESP32_IP>:18790/feishu/events - Subscribe to:
im.message.receive_v1
- Request URL:
- The ESP32 will auto-respond to the URL verification challenge
Architecture
Feishu Server
|
v (HTTP POST /feishu/events)
[ESP32 Webhook Server :18790]
|
v (message_bus_push_inbound)
[Message Bus] --> [Agent Loop] --> [Message Bus]
| |
v (outbound dispatch) |
[feishu_send_message] <-----------------+
|
v (POST /im/v1/messages)
Feishu API
API Reference
| Function | Description |
|---|---|
feishu_bot_init() |
Load credentials from NVS/build-time |
feishu_bot_start() |
Start webhook HTTP server |
feishu_send_message(chat_id, text) |
Send text message |
feishu_reply_message(message_id, text) |
Reply to a specific message |
feishu_set_credentials(app_id, secret) |
Save credentials to NVS |