From 686b3f884c480b7386d3301555da3b20c0db4c5c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 10 Jan 2026 21:02:48 +0100 Subject: [PATCH] fix: expose WhatsApp sender ids in group context --- src/auto-reply/reply.triggers.test.ts | 2 +- src/auto-reply/reply/groups.ts | 5 +++++ src/web/auto-reply.ts | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auto-reply/reply.triggers.test.ts b/src/auto-reply/reply.triggers.test.ts index 0e129c928..d8afe0a33 100644 --- a/src/auto-reply/reply.triggers.test.ts +++ b/src/auto-reply/reply.triggers.test.ts @@ -1517,7 +1517,7 @@ describe("group intro prompts", () => { vi.mocked(runEmbeddedPiAgent).mock.calls.at(-1)?.[0] ?.extraSystemPrompt ?? ""; expect(extraSystemPrompt).toBe( - `You are replying inside the WhatsApp group "Ops". Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included). ${groupParticipationNote} Address the specific sender noted in the message context.`, + `You are replying inside the WhatsApp group "Ops". Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included). WhatsApp IDs: SenderId is the participant JID; [message_id: ...] is the message id for reactions (use SenderId as participant). ${groupParticipationNote} Address the specific sender noted in the message context.`, ); }); }); diff --git a/src/auto-reply/reply/groups.ts b/src/auto-reply/reply/groups.ts index f3445001a..2cf4dcd0c 100644 --- a/src/auto-reply/reply/groups.ts +++ b/src/auto-reply/reply/groups.ts @@ -213,6 +213,10 @@ export function buildGroupIntro(params: { activation === "always" ? "Activation: always-on (you receive every group message)." : "Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included)."; + const whatsappIdsLine = + provider === "whatsapp" + ? "WhatsApp IDs: SenderId is the participant JID; [message_id: ...] is the message id for reactions (use SenderId as participant)." + : undefined; const silenceLine = activation === "always" ? `If no response is needed, reply with exactly "${params.silentToken}" (and nothing else) so Clawdbot stays silent. Do not add any other words, punctuation, tags, markdown/code blocks, or explanations.` @@ -227,6 +231,7 @@ export function buildGroupIntro(params: { subjectLine, membersLine, activationLine, + whatsappIdsLine, silenceLine, cautionLine, lurkLine, diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index 5da3376c1..ee9786680 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -1261,6 +1261,7 @@ export async function monitorWebProvider( msg.senderE164, ), SenderName: msg.senderName, + SenderId: msg.senderJid ?? msg.senderE164, SenderE164: msg.senderE164, WasMentioned: msg.wasMentioned, ...(msg.location ? toLocationContext(msg.location) : {}),