const buttons = [
{ buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
{ buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
]
const buttonMessage = {
text: "Hi it's button message",
footer: 'Hello World',
buttons,
headerType: 1,
viewOnce: true
}
await sock.sendMessage(id, buttonMessage, { quoted: null })
- To send button with image
const buttons = [
{ buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
{ buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
]
const buttonMessage = {
image: { url: "https://example.com/abcd.jpg" },
caption: "Hi it's button message with image",
footer: 'Hello World',
buttons,
headerType: 1,
viewOnce: true
}
await sock.sendMessage(id, buttonMessage, { quoted: null })
- To send button with video
const buttons = [
{ buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
{ buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
]
const buttonMessage = {
video: { url: "https://example.com/abcd.mp4" },
caption: "Hi it's button message with video",
footer: 'Hello World',
buttons,
headerType: 1,
viewOnce: true
}
await sock.sendMessage(id, buttonMessage, { quoted: null })
- To send interactive message
const interactiveButtons = [
{
name: "quick_reply",
buttonParamsJson: JSON.stringify({
display_text: "Quick Reply",
id: "ID"
})
},
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "Tap Here!",
url: "https://www.example.com/"
})
},
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "Copy Code",
id: "12345",
copy_code: "12345"
})
}
]
const interactiveMessage = {
text: "Hello World!",
title: "this is the title",
footer: "this is the footer",
interactiveButtons
}
await sock.sendMessage(id, interactiveMessage, { quoted: null })
- To send interactive message with image
const interactiveButtons = [
{
name: "quick_reply",
buttonParamsJson: JSON.stringify({
display_text: "Quick Reply",
id: "ID"
})
},
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "Tap Here!",
url: "https://www.example.com/"
})
},
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "Copy Code",
id: "12345",
copy_code: "12345"
})
}
]
const interactiveMessage = {
image: { url: "https://example.com/abcd.jpg" },
caption: "this is the caption",
title: "this is the title",
footer: "this is the footer",
interactiveButtons
}
await sock.sendMessage(id, interactiveMessage, { quoted: null })
- To send interactive message with video
const interactiveButtons = [
{
name: "quick_reply",
buttonParamsJson: JSON.stringify({
display_text: "Quick Reply",
id: "ID"
})
},
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "Tap Here!",
url: "https://www.example.com/"
})
},
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "Copy Code",
id: "12345",
copy_code: "12345"
})
}
]
const interactiveMessage = {
video: { url: "https://example.com/abcd.mp4" },
caption: "this is the caption",
title: "this is the title",
footer: "this is the footer",
interactiveButtons
}
await sock.sendMessage(id, interactiveMessage, { quoted: null })