From 86c26bd1715d247fa4373ba5991e1fbddf555fcd Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 15 Mar 2026 18:53:41 -0700 Subject: [PATCH] Outbound: deliver shared interactive payloads --- src/infra/outbound/deliver.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/infra/outbound/deliver.ts b/src/infra/outbound/deliver.ts index 509ff278a1d..2a9e119de7d 100644 --- a/src/infra/outbound/deliver.ts +++ b/src/infra/outbound/deliver.ts @@ -238,17 +238,22 @@ function hasChannelDataPayload(payload: ReplyPayload): boolean { return Boolean(payload.channelData && Object.keys(payload.channelData).length > 0); } +function hasInteractivePayload(payload: ReplyPayload): boolean { + return (payload.interactive?.blocks.length ?? 0) > 0; +} + function normalizePayloadForChannelDelivery( payload: ReplyPayload, channelId: string, ): ReplyPayload | null { const hasMedia = hasMediaPayload(payload); const hasChannelData = hasChannelDataPayload(payload); + const hasInteractive = hasInteractivePayload(payload); const rawText = typeof payload.text === "string" ? payload.text : ""; const normalizedText = channelId === "whatsapp" ? rawText.replace(/^(?:[ \t]*\r?\n)+/, "") : rawText; if (!normalizedText.trim()) { - if (!hasMedia && !hasChannelData) { + if (!hasMedia && !hasInteractive && !hasChannelData) { return null; } return { @@ -299,6 +304,7 @@ function buildPayloadSummary(payload: ReplyPayload): NormalizedOutboundPayload { return { text: payload.text ?? "", mediaUrls: payload.mediaUrls ?? (payload.mediaUrl ? [payload.mediaUrl] : []), + interactive: payload.interactive, channelData: payload.channelData, }; } @@ -697,7 +703,10 @@ async function deliverOutboundPayloadsCore( threadId: params.threadId ?? undefined, forceDocument: params.forceDocument, }; - if (handler.sendPayload && effectivePayload.channelData) { + if ( + handler.sendPayload && + (effectivePayload.channelData || hasInteractivePayload(effectivePayload)) + ) { const delivery = await handler.sendPayload(effectivePayload, sendOverrides); results.push(delivery); emitMessageSent({