Skip to content

fix(feishu): parse interactive card post-format fallback content#1919

Open
BingqingLyu wants to merge 3 commits intomainfrom
fork-pr-60383-fix-feishu-interactive-card-fallback-parsing
Open

fix(feishu): parse interactive card post-format fallback content#1919
BingqingLyu wants to merge 3 commits intomainfrom
fork-pr-60383-fix-feishu-interactive-card-fallback-parsing

Conversation

@BingqingLyu
Copy link
Copy Markdown
Owner

@BingqingLyu BingqingLyu commented Apr 28, 2026

Summary

Fix parseInteractiveCardContent() to handle Feishu API post-format fallback content for interactive card messages.

Fixes openclaw#60380
Related: openclaw#41609 openclaw#48281

Problem

When reading card messages via GET /im/v1/messages/{message_id}, Feishu returns body.content in a post-style fallback format — nested arrays with tag:"text" elements — instead of the original card template JSON. The existing parser only handled card template format (div/markdown tags), causing all fallback content to silently return "[Interactive Card]".

Before: Any message(action=read) on a card → "[Interactive Card]"
After: Extracts title + text content from both card template and post-format fallback

Example

API returns this for a card message:

{
  "title": "🤖 clawdbot",
  "elements": [[
    {"tag": "img", "image_key": "img_v3_02ad_..."},
    {"tag": "text", "text": "Daily report summary"},
    {"tag": "text", "text": "13 people missing reports"}
  ]]
}
  • Before: "[Interactive Card]"
  • After: "🤖 clawdbot\nDaily report summary\n13 people missing reports"

Changes

extensions/feishu/src/send.ts

  • Handle nested arrays in elements (post-format fallback [[...]])
  • Extract tag:"text" and tag:"a" elements from fallback content
  • Extract card title from header.title.content (template) or top-level title (fallback)
  • Support tag:"plain_text" elements
  • Return title even when elements array is missing

extensions/feishu/src/send.test.ts

  • Add test: post-format fallback with nested arrays and title
  • Add test: card template with header.title.content
  • Add test: link extraction from tag:"a" elements with href

Testing

  • Verified with real Feishu API responses from production bot
  • Existing card template format tests still pass (div/markdown)
  • 3 new test cases covering fallback scenarios

edy and others added 3 commits April 3, 2026 23:27
When reading card messages via GET /im/v1/messages/{message_id}, Feishu
returns body.content in a post-style fallback format (nested arrays with
tag:'text' elements) instead of the original card template JSON. The
existing parseInteractiveCardContent() only handled card template format
(div/markdown tags), causing all fallback content to return
'[Interactive Card]'.

Changes:
- Handle nested arrays in elements (post-format fallback)
- Extract tag:'text' and tag:'a' elements from fallback content
- Extract card title from header.title.content or top-level title
- Support tag:'plain_text' elements
- Return title even when elements array is missing

Fixes openclaw#60380
Related: openclaw#41609 openclaw#48281
Address review feedback from Greptile bot — trailing whitespace in
tag:'text' elements would cause join('\n') to produce interior
trailing spaces that the final .trim() cannot remove. Trim each
segment on push for cleaner extracted content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Feishu: parseInteractiveCardContent fails on fallback post-format content

2 participants