Button with images
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;
}Última actualización