From a05c4fca5cb2f1779e6ca29f492adfa39ea1041c Mon Sep 17 00:00:00 2001 From: Tu Nombre Real Date: Fri, 9 Jan 2026 00:08:36 +0100 Subject: [PATCH 1/2] fix(web): pass accountId in WhatsApp provider activity tracking Recent changes added recordProviderActivity calls with accountId, but the type definition and usage didn't include accountId in ActiveWebSendOptions. This fix adds the optional accountId field and uses optional chaining when accessing it to handle cases where options is undefined. Co-Authored-By: Claude Opus 4.5 --- src/web/active-listener.ts | 1 + src/web/inbound.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/web/active-listener.ts b/src/web/active-listener.ts index bf1ff4c6f..633d03c7d 100644 --- a/src/web/active-listener.ts +++ b/src/web/active-listener.ts @@ -3,6 +3,7 @@ import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; export type ActiveWebSendOptions = { gifPlayback?: boolean; + accountId?: string; }; export type ActiveWebListener = { diff --git a/src/web/inbound.ts b/src/web/inbound.ts index 589e7ddde..f4645509f 100644 --- a/src/web/inbound.ts +++ b/src/web/inbound.ts @@ -587,7 +587,7 @@ export async function monitorWebInbox(options: { const result = await sock.sendMessage(jid, payload); recordProviderActivity({ provider: "whatsapp", - accountId: options.accountId, + accountId: options?.accountId, direction: "outbound", }); return { messageId: result?.key?.id ?? "unknown" }; @@ -610,7 +610,7 @@ export async function monitorWebInbox(options: { }); recordProviderActivity({ provider: "whatsapp", - accountId: options.accountId, + accountId: options?.accountId, direction: "outbound", }); return { messageId: result?.key?.id ?? "unknown" }; From a65455e25d1e0490ac3d181414cef5f186c0075d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 20:42:35 +0100 Subject: [PATCH 2/2] fix: align WhatsApp activity account id (#537) (thanks @Nachx639) --- CHANGELOG.md | 1 + src/web/inbound.ts | 5 +++-- src/web/outbound.ts | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ea5ae402..d87f7c099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ - Config: fix Minimax hosted onboarding to write `agents.defaults` and allow `msteams` as a heartbeat target. — thanks @steipete - Discord: add channel/category management actions (create/edit/move/delete + category removal). (#487) - thanks @NicholasSpisak - Docs: split CLI install commands into separate code blocks. (#601) — thanks @martinpucik +- WhatsApp: record outbound provider activity using the active account id. (#537) — thanks @Nachx639 ## 2026.1.8 diff --git a/src/web/inbound.ts b/src/web/inbound.ts index f4645509f..f456d351e 100644 --- a/src/web/inbound.ts +++ b/src/web/inbound.ts @@ -585,9 +585,10 @@ export async function monitorWebInbox(options: { payload = { text }; } const result = await sock.sendMessage(jid, payload); + const accountId = sendOptions?.accountId ?? options.accountId; recordProviderActivity({ provider: "whatsapp", - accountId: options?.accountId, + accountId, direction: "outbound", }); return { messageId: result?.key?.id ?? "unknown" }; @@ -610,7 +611,7 @@ export async function monitorWebInbox(options: { }); recordProviderActivity({ provider: "whatsapp", - accountId: options?.accountId, + accountId: options.accountId, direction: "outbound", }); return { messageId: result?.key?.id ?? "unknown" }; diff --git a/src/web/outbound.ts b/src/web/outbound.ts index c8d99f7a3..6c6235dbd 100644 --- a/src/web/outbound.ts +++ b/src/web/outbound.ts @@ -69,9 +69,13 @@ export async function sendMessageWhatsApp( ); if (!active) throw new Error("Active web listener missing"); await active.sendComposingTo(to); - const sendOptions: ActiveWebSendOptions | undefined = options.gifPlayback - ? { gifPlayback: true } - : undefined; + const sendOptions: ActiveWebSendOptions | undefined = + options.gifPlayback || options.accountId + ? { + ...(options.gifPlayback ? { gifPlayback: true } : {}), + accountId: options.accountId, + } + : undefined; const result = sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType);