Skip to content

fix(feishu): group reply targets root message instead of the triggering message #32980

@miaciswang

Description

@miaciswang

Problem

In Feishu group chats, when a user replies to (quotes) an earlier message and @mentions the bot, the bot's response is attached to the root message of the reply chain instead of the user's actual message.

For example:

  1. User A posts message M1
  2. User B replies to M1 with message M2
  3. User C replies to M2 and @mentions the bot (message M3)
  4. Bot responds — but the reply appears under M1 (root), not M3 (the triggering message)

This makes the bot's reply hard to find in active group chats, since it gets buried under an earlier message.

Root Cause

In extensions/feishu/src/bot.ts line ~1282:

const replyTargetMessageId = ctx.rootId ?? ctx.messageId;

When a message is part of a reply chain, Feishu provides root_id (the topmost message in the chain). The code prioritizes root_id over messageId, causing the bot's reply to target the root message instead of the actual triggering message.

Proposed Fix

Change the reply target to always use the triggering message ID:

// Before
const replyTargetMessageId = ctx.rootId ?? ctx.messageId;

// After
const replyTargetMessageId = ctx.messageId;

rootId should still be preserved for thread/topic routing (groupSession.peerId, session key resolution, etc.) — it just shouldn't be used as the reply target.

Files to Change

File Line Change
extensions/feishu/src/bot.ts ~1282 ctx.rootId ?? ctx.messageIdctx.messageId

Note: rootId is still passed to createFeishuReplyDispatcher for thread affinity — only the replyTargetMessageId variable needs to change.

Context

  • Feishu group chat with requireMention: false (bot receives all messages)
  • User @mentions bot in a reply chain
  • Bot reply ends up on the wrong message (root of chain instead of the @mention)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions