← Back to PRs

#22598: feat(feishu): support card action callback handler

by yingyixu open 2026-02-21 10:57 View on GitHub →
channel: feishu size: S
## Summary Add first-class support for Feishu card action callbacks (`card.action.trigger`) in the Feishu channel extension. This PR introduces a configurable callback handler script path and wires card action events into the Feishu event dispatcher flow. ## Changes ### 1) Register card action event in monitor - File: `extensions/feishu/src/monitor.ts` - Add event handler for `card.action.trigger` - Delegate handling to a dedicated module (`handleFeishuCardAction`) - Keep existing error handling / fire-and-forget behavior consistent with other event paths ### 2) Add configurable handler path in channel config schema - File: `extensions/feishu/src/channel.ts` - Add `cardActionHandler` config field: - Type: `string` - Meaning: path to a Node.js script that receives base64 event payload and returns JSON response - Response shape supports Feishu callback format (`toast`, `card`) ### 3) New card action handling module - File: `extensions/feishu/src/card-action.ts` - Define event/response types: - `FeishuCardActionEvent` - `CardActionResponse` - Implement `handleFeishuCardAction(...)`: - Log callback context - Emit a system event to the routed agent session - Optionally invoke external handler script (`cardActionHandler`) and return parsed callback response - Graceful error handling with `undefined` fallback ## Why This enables interactive Feishu card workflows (e.g. confirm/cancel buttons) while keeping OpenClaw core behavior generic: - event routing is native - business logic stays in user-provided handler script ## Notes - No behavior change unless `cardActionHandler` is configured. - Existing message handling flow remains unchanged. ## Manual test 1. Configure `channels.feishu.cardActionHandler` to a valid Node.js script path. 2. Send an interactive card with actions. 3. Click a card action button in Feishu. 4. Verify: - callback event is handled - system event is enqueued to the correct session - handler output (toast/card update) is returned when script emits valid JSON <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds support for Feishu card action callbacks by introducing a new `cardActionHandler` config option and wiring `card.action.trigger` events through the event dispatcher. When a card action is triggered, the handler emits a system event to the agent session and optionally invokes an external Node.js script to generate a callback response (toast/card update). - New module `card-action.ts` implements `handleFeishuCardAction` with event routing and optional script invocation - Config schema updated in `channel.ts` to accept `cardActionHandler` script path - Event handler registered in `monitor.ts` for `card.action.trigger` events with consistent fire-and-forget error handling <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with one shell escaping fix - The implementation follows established patterns for event handling and adds a well-scoped feature with proper error handling. However, there's a shell escaping issue with `execSync` that could cause problems if the handler path contains special characters like quotes - Check `extensions/feishu/src/card-action.ts` line 116 for the shell escaping fix <sub>Last reviewed commit: 702fdb0</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs