Button

The structure presented is as follows:

function Buttons(number, bodyText, 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",    
        "recipient_type": "individual",
        "to": number,
        "type": "interactive",
        "interactive": {
            "type": "button",
            "body": {
                "text": bodyText
            },
            "action": {
                "buttons": buttonsArray
            }
        }
    });
    return data;
}

In this one the parameters received are a number, bodyText and buttonTitles.

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

The name of the function you can place it as you prefer this case is a mere example, then you must configure it in the whatsappModel file, here is an example:

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