### Send Interactive Message with Quick Replies and Catalog Button Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This example shows how to send an interactive message that includes quick reply buttons for user interaction and a catalog button to direct users to a product catalog. The sendInteractiveMessage function is used with 'quick_reply' and 'cta_catalog' button types. ```javascript await sendInteractiveMessage(sock, jid, { text: 'Explore products or reply', interactiveButtons: [ { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Hello', id: 'hi' }) }, { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Pricing', id: 'pricing' }) }, { name: 'cta_catalog', buttonParamsJson: JSON.stringify({}) } ] }); ``` -------------------------------- ### Send Interactive Message with Mixed Buttons and List (JavaScript) Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This example demonstrates how to use the `sendInteractiveMessage` function from the `baileys_helper` library to send a message containing various interactive elements like quick replies, CTA URLs, and a single-select list. It also shows how to inject custom binary nodes. ```javascript const { sendInteractiveMessage } = require('baileys_helper'); await sendInteractiveMessage(sock, jid, { text: 'Pick or explore', footer: 'Advanced demo', interactiveButtons: [ { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Hi', id: 'hi' }) }, { name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: 'Docs', url: 'https://example.com' }) }, { name: 'single_select', buttonParamsJson: JSON.stringify({ title: 'Menu', sections: [ { title: 'Options', rows: [ { id: 'a', title: 'Alpha', description: 'First item' }, { id: 'b', title: 'Beta', description: 'Second item' } ] } ] }) } ] }, { additionalNodes: [ { tag: 'biz', attrs: { experimental_flag: '1' } } ] // will be merged before auto interactive nodes }); ``` -------------------------------- ### Send Interactive Message Requesting Location (Experimental) Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This example demonstrates sending an experimental interactive message designed to request the user's location. It uses the 'send_location' button type within the interactiveButtons array, with a display text for the button. ```javascript await sendInteractiveMessage(sock, jid, { text: 'Please share your location', interactiveButtons: [ { name: 'send_location', buttonParamsJson: JSON.stringify({ display_text: 'Share Location' }) } ] }); ``` -------------------------------- ### Send Interactive Message with URL, Copy, and Call Buttons Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This example demonstrates how to send an interactive message with three types of buttons: a call-to-action URL button, a copy code button, and a call button. It utilizes the sendInteractiveMessage function with specific button names and their corresponding parameters. ```javascript await sendInteractiveMessage(sock, jid, { text: 'Contact actions', interactiveButtons: [ { name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: 'Docs', url: 'https://example.com' }) }, { name: 'cta_copy', buttonParamsJson: JSON.stringify({ display_text: 'Copy Code', copy_code: 'ABC-123' }) }, { name: 'cta_call', buttonParamsJson: JSON.stringify({ display_text: 'Call Support', phone_number: '+1234567890' }) } ] }); ``` -------------------------------- ### Send Interactive Message with Single Select Menu Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This example illustrates how to create an interactive message featuring a single select menu. Users can choose one option from predefined sections and rows. The sendInteractiveMessage function is configured with 'single_select' button type and detailed menu structure. ```javascript await sendInteractiveMessage(sock, jid, { text: 'Choose one item', interactiveButtons: [ { name: 'single_select', buttonParamsJson: JSON.stringify({ title: 'Menu', sections: [{ title: 'Main', rows: [ { id: 'it_1', title: 'First', description: 'First choice' }, { id: 'it_2', title: 'Second', description: 'Second choice' } ] }] }) } ] }); ``` -------------------------------- ### Send Interactive Message with Quick Reply Button (JavaScript) Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md Demonstrates how to send an interactive message with a quick reply button using the sendInteractiveMessage function. The helper automatically injects necessary binary nodes and bot nodes. This function requires a valid socket, JID, and an interactiveMessage object. ```javascript await sendInteractiveMessage(sock, jid, { interactiveMessage: { nativeFlowMessage: { buttons: [ { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Hi', id: 'hi' }) } ] }, body: { text: 'Direct native flow' } } }); ``` -------------------------------- ### Authoring Format for sendInteractiveMessage Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This code snippet shows the high-level authoring object structure expected by the sendInteractiveMessage function. It includes text, footer, and an array of interactiveButtons, where each button has a name and JSON stringified parameters. ```javascript { text, footer, interactiveButtons: [{ name, buttonParamsJson }, ...] } ``` -------------------------------- ### Wrapper's Internal Message Structure Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This code snippet represents the structure of the interactive message as built internally by the wrapper before being sent to WhatsApp. It shows the nesting of nativeFlowMessage, buttons, body, and footer. ```javascript { interactiveMessage: { nativeFlowMessage: { buttons: [...] }, body:{ text }, footer:{ text } } } ``` -------------------------------- ### Send WhatsApp Buttons using baileys_helper Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This function sends WhatsApp interactive buttons to a specified JID. It handles various button types, including quick replies and URL calls. It's designed for common use cases and automatically handles chat type requirements. ```javascript const { sendButtons } = require('baileys_helper'); await sendButtons(sock, jid, { title: 'Header Title', // optional header text: 'Pick one option below', footer: 'Footer text', // optional footer buttons: [ { id: 'quick_1', text: 'Quick Reply' }, // legacy simple shape auto‑converted { name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: 'Open Site', url: 'https://example.com' }) } ] }); ``` -------------------------------- ### Send Advanced Interactive Messages with baileys_helper Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This function allows sending advanced interactive messages with multiple button kinds in a single message. It leverages the 'interactiveButtons' format for explicit control over button types like quick replies and single-select pickers. ```javascript const { sendInteractiveMessage } = require('baileys_helper'); await sendInteractiveMessage(sock, jid, { text: 'Advanced native flow demo', footer: 'All the things', interactiveButtons: [ // Quick reply (explicit form) { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Reply A', id: 'reply_a' }) }, // Single select picker (list inside a button) { name: 'single_select', buttonParamsJson: JSON.stringify({ title: 'Pick One', sections: [{ title: 'Choices', rows: [ { header: 'H', title: 'Hello', description: 'Says hi', id: 'opt_hello' }, { header: 'B', title: 'Bye', description: 'Says bye', id: 'opt_bye' } ] }] }) } ] }); ``` -------------------------------- ### sendInteractiveMessage Function Signature Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md This details the signature of the sendInteractiveMessage asynchronous function, outlining its parameters: sock (the WhatsApp socket), jid (the destination JID), content (the message structure), and optional options. ```javascript async function sendInteractiveMessage(sock, jid, content, options = {}) ``` -------------------------------- ### sendInteractiveMessage API Reference Source: https://github.com/mehebub648/scratchive-module-baileyshelper/blob/main/README.md The sendInteractiveMessage function is a low-level helper used to send various advanced interactive messages. It allows mixing button types, providing pre-built message content, and attaching custom relay options. ```APIDOC ## POST /sendInteractiveMessage ### Description Sends an interactive message to a specified WhatsApp JID. This function is versatile and can handle various button types, message formats, and custom options. ### Method POST ### Endpoint /sendInteractiveMessage ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **sock** (object) - Required - Active WhiskeySockets/Baileys socket. - **jid** (string) - Required - Destination WhatsApp JID. - **content** (object) - Required - High-level authoring object for the message content. Can include: - **text** (string) - Optional - Body text. - **footer** (string) - Optional - Footer text. - **title** (string) - Optional - Header title. - **subtitle** (string) - Optional - Header subtitle. - **interactiveButtons** (array) - Optional - Array of button descriptors. - Any other Baileys message keys. - **options** (object) - Optional - Extra relay and generation options. ### Request Example ```json { "sock": "", "jid": "", "content": { "text": "Choose an option:", "interactiveButtons": [ { "name": "quick_reply", "buttonParamsJson": "{\"display_text\": \"Option 1\", \"id\": \"opt1\"}" }, { "name": "cta_url", "buttonParamsJson": "{\"display_text\": \"Learn More\", \"url\": \"https://example.com\"}" } ] } } ``` ### Response #### Success Response (200) - **result** (string) - Indicates the success of the message sending operation. #### Response Example ```json { "result": "success" } ``` ### Error Handling - Returns an error message if the message sending fails. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.