Skip to content

Commit 975dc2c

Browse files
committed
fix(n8n): drop Telegram fromId fallback — silently misrouted group chats
`meta.fromId` is the Telegram sender's *user* id, which equals the chat id only in private 1:1 DMs. In group chats / channels the chat id is a distinct (typically negative) integer. Falling back to fromId silently routed group-chat workflows back to the user's DM instead of the group (Greptile P1). Drop the fallback. Only use the canonical `metadata.telegram.chatId`. If the upstream Telegram plugin hasn't populated that yet (pre-existing schema gap — flat `metadata.fromId` is the de-facto inbound shape today for Telegram), Telegram routing is skipped rather than guessed. Discord and Slack routing are unaffected.
1 parent c0f3cbc commit 975dc2c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/app-core/src/api/n8n-routes.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,17 @@ async function buildTriggerContextFromConversation(
695695
const discordThreadId =
696696
typeof discord.threadId === "string" ? discord.threadId : undefined;
697697

698+
// No `meta.fromId` fallback for Telegram: `fromId` is the sender's user
699+
// id, which equals the chat id only in private 1:1 DMs. In group chats /
700+
// channels the chat id is a distinct (typically negative) integer, so
701+
// falling back to fromId would silently route the workflow to the wrong
702+
// entity. Only use the canonical `metadata.telegram.chatId`. If the
703+
// upstream Telegram plugin hasn't populated it yet, we skip Telegram
704+
// routing rather than guess.
698705
const telegramChatId =
699-
(typeof telegram.chatId === "string" || typeof telegram.chatId === "number"
706+
typeof telegram.chatId === "string" || typeof telegram.chatId === "number"
700707
? telegram.chatId
701-
: undefined) ??
702-
(typeof meta.fromId === "string" || typeof meta.fromId === "number"
703-
? (meta.fromId as string | number)
704-
: undefined);
708+
: undefined;
705709
const telegramThreadId =
706710
typeof telegram.threadId === "string" ||
707711
typeof telegram.threadId === "number"

0 commit comments

Comments
 (0)