fix(buttons): remove bot node for ALL native_flow buttons (Web/Deskto…

fix(buttons): remove bot node for ALL native_flow buttons (Web/Deskto…
This commit is contained in:
Renato Alcara
2026-02-06 11:58:01 -03:00
committed by GitHub
+10 -8
View File
@@ -1335,18 +1335,20 @@ export const makeMessagesSocket = (config: SocketConfig) => {
}) })
} }
// For private 1:1 chats, conditionally add bot node // Bot node (<bot biz_bot="1"/>) MUST NOT be injected for native_flow buttons
// - quick_reply buttons need bot node for response handling // It prevents WhatsApp Web/Desktop from rendering ALL button types
// - CTA-only buttons (cta_url, cta_copy, cta_call) should NOT have bot node // (both quick_reply and CTA buttons). Confirmed by testing:
// as they are business actions and the bot node prevents WhatsApp Web rendering // - CTA buttons without bot node: works on Web ✅
// - Carousels and catalog messages should NOT have bot node // - quick_reply buttons with bot node: only smartphone, not Web ❌
const isNativeFlowButtons = buttonType === 'native_flow'
const isPrivateUserChat = ( const isPrivateUserChat = (
isPnUser(destinationJid) || isPnUser(destinationJid) ||
isLidUser(destinationJid) || isLidUser(destinationJid) ||
destinationJid?.endsWith('@c.us') destinationJid?.endsWith('@c.us')
) && !isJidBot(destinationJid) ) && !isJidBot(destinationJid)
if (isPrivateUserChat && !isCarousel && !isCatalog && buttonType !== 'list' && !isCTAOnly) { if (isPrivateUserChat && !isCarousel && !isCatalog && buttonType !== 'list' && !isNativeFlowButtons) {
;(stanza.content as BinaryNode[]).push({ ;(stanza.content as BinaryNode[]).push({
tag: 'bot', tag: 'bot',
attrs: { biz_bot: '1' } attrs: { biz_bot: '1' }
@@ -1355,10 +1357,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
{ msgId, to: destinationJid }, { msgId, to: destinationJid },
'[EXPERIMENTAL] Added bot node for private chat interactive message' '[EXPERIMENTAL] Added bot node for private chat interactive message'
) )
} else if (isCTAOnly) { } else if (isNativeFlowButtons) {
logger.debug( logger.debug(
{ msgId, to: destinationJid, buttonNames: allButtonNames }, { msgId, to: destinationJid, buttonNames: allButtonNames },
'[EXPERIMENTAL] Skipping bot node for CTA-only buttons (Web compatibility)' '[EXPERIMENTAL] Skipping bot node for native_flow buttons (Web/Desktop compatibility)'
) )
} else if (isCarousel) { } else if (isCarousel) {
logger.debug( logger.debug(