From 2532e8b7a41f4980d40bb8fba58135d43893a003 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Tue, 27 Jan 2026 09:58:37 -0300 Subject: [PATCH] fix: detect list-type nativeFlowMessage for correct biz node Lists sent as nativeFlowMessage (with single_select/multi_select buttons) still need type='list' in the biz node to work properly. Added isListNativeFlow() function to detect list-type messages by checking for single_select or multi_select button names. Co-Authored-By: Claude Opus 4.5 --- src/Socket/messages-send.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 8b2df7c2..2da6f15e 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -761,6 +761,25 @@ export const makeMessagesSocket = (config: SocketConfig) => { return false } + /** + * Checks if the nativeFlowMessage is a list (single_select button) + * Lists need type='list' in the biz node instead of type='native_flow' + */ + const isListNativeFlow = (message: proto.IMessage): boolean => { + const interactiveMsg = message.interactiveMessage || + message.viewOnceMessage?.message?.interactiveMessage + + const nativeFlow = interactiveMsg?.nativeFlowMessage + if (nativeFlow?.buttons?.length) { + // Check if any button is a list-type button (single_select or multi_select) + return nativeFlow.buttons.some( + (btn: any) => btn?.name === 'single_select' || btn?.name === 'multi_select' + ) + } + + return false + } + const relayMessage = async ( jid: string, message: proto.IMessage, @@ -1141,7 +1160,9 @@ export const makeMessagesSocket = (config: SocketConfig) => { // This matches the working Astra-Api implementation // For native_flow: biz > interactive(type=native_flow) > native_flow // For list: biz > interactive(type=list) > list - const interactiveType = buttonType === 'list' ? 'list' : 'native_flow' + // Note: Lists sent as nativeFlowMessage still need type='list' + const isListMessage = buttonType === 'list' || isListNativeFlow(message) + const interactiveType = isListMessage ? 'list' : 'native_flow' ;(stanza.content as BinaryNode[]).push({ tag: 'biz', attrs: {},