#22598: feat(feishu): support card action callback handler
channel: feishu
size: S
Cluster:
Feishu Messaging Fixes
## 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
#17863: Fix Feishu card button callback parameters dropped (missing handler)
by Clawborn · 2026-02-16
84.0%
#16716: feat(feishu): add reaction event support (created/deleted)
by schumilin · 2026-02-15
76.5%
#16123: Feishu card default
by QiuYi111 · 2026-02-14
76.4%
#11084: feat(feishu): implement CardKit streaming card output with typewrit...
by liuhui201069 · 2026-02-07
75.9%
#13917: fix(feishu): card rendering for tables, blockquotes, images, and ou...
by yaoting · 2026-02-11
75.4%
#14674: feat(feishu): add feishu_chat tool for chat info/member queries
by liuweifly · 2026-02-12
75.2%
#9410: docs: add cardkit permissions to Feishu channel setup
by Cassius0924 · 2026-02-05
74.1%
#19027: fix(feishu): keep chunked messages in topic/thread context
by qiangu · 2026-02-17
73.6%
#21848: feat(feishu): improve agent card experience with single-card stream...
by songshikang0111 · 2026-02-20
73.2%
#10675: feat(feishu): add audio message support and fix file upload
by YumoeZhung · 2026-02-06
72.9%