Button with images

The structure presented is as follows:

function ImageButton(number, linkImage, bodyText, footerText, buttonTitles){

    const buttonsArray = buttonTitles.slice(0, 3).map((title, index) => {
        return {
            type: 'reply',
            reply: {
                id: String(index).padStart(5, '0'),
                title: title
            }
        };
    });

    const data = JSON.stringify({
        "messaging_product": "whatsapp",
        "to": number,
        "type": "interactive",
        "interactive": {
            "type": "button",
            "header": {
                "type": "image",
                "image": {
                    "link": linkImage
                }
            },
            "body": {
                "text": bodyText
            },
            "footer": {
                "text": footerText
            },
            "action": {
                "buttons": buttonsArray
            }
        }
    });
    return data;
}

The parameters received are a number, linkImage, bodyText, footerText and buttonTitles

We recommend sending in the following way in the process files:

In whatsappModels we can configure it:

The maximum number of buttons is 3 and the minimum number of buttons is 1. You can add as many buttons as you need, always complying with these parameters.

Última actualización