upd4
This commit is contained in:
parent
563760f812
commit
da74d76a7c
128
index.js
128
index.js
@ -124,31 +124,115 @@ app.post('/sendText', async (req, res) => {
|
||||
app.post('/sendButtons', async (req, res) => {
|
||||
const { phone } = req.body;
|
||||
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
||||
|
||||
try {
|
||||
await sock.sendMessage(`${phone}@s.whatsapp.net`, {
|
||||
text: "Découvre nos services",
|
||||
footer: "Powered by Fizzxy",
|
||||
buttons: [
|
||||
{
|
||||
buttonId: "visit_site",
|
||||
buttonText: {
|
||||
displayText: "🌐 Visiter le site"
|
||||
const content = {
|
||||
viewOnceMessage: {
|
||||
message: {
|
||||
messageContextInfo: {
|
||||
deviceListMetadata: {},
|
||||
deviceListMetadataVersion: 2
|
||||
},
|
||||
type: 4,
|
||||
nativeFlowInfo: {
|
||||
name: "ctl_url",
|
||||
paramsJson: JSON.stringify({
|
||||
display_text: "🌐 Visiter le site",
|
||||
url: "https://canguidev.fr",
|
||||
merchant_url: "https://canguidev.fr"
|
||||
})
|
||||
}
|
||||
interactiveMessage: proto.Message.InteractiveMessage.create({
|
||||
body: { text: "Fizzxy Dev" },
|
||||
footer: { text: "Bot" },
|
||||
header: {
|
||||
title: "Igna",
|
||||
subtitle: "test",
|
||||
hasMediaAttachment: false
|
||||
},
|
||||
nativeFlowMessage: {
|
||||
buttons: [
|
||||
{
|
||||
name: "single_select",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
title: "title",
|
||||
sections: [
|
||||
{
|
||||
title: "menu",
|
||||
highlight_label: "label",
|
||||
rows: [
|
||||
{
|
||||
header: "header",
|
||||
title: "title",
|
||||
description: "description",
|
||||
id: "id1"
|
||||
},
|
||||
{
|
||||
header: "header",
|
||||
title: "title",
|
||||
description: "description",
|
||||
id: "id2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_reply",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "quick_reply",
|
||||
id: "message"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_url",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Visiter Google",
|
||||
url: "https://www.google.com",
|
||||
merchant_url: "https://www.google.com"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_call",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Appeler support",
|
||||
id: "+33600000000"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_copy",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Copier code",
|
||||
id: "codecopie",
|
||||
copy_code: "123456789"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_reminder",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Ajouter rappel",
|
||||
id: "reminder_id"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_cancel_reminder",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Annuler rappel",
|
||||
id: "reminder_id"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "address_message",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Adresse",
|
||||
id: "adresse_id"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "send_location",
|
||||
buttonParamsJson: ""
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
],
|
||||
headerType: 1,
|
||||
viewOnce: true
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const msg = generateWAMessageFromContent(`${phone}@s.whatsapp.net`, content, {});
|
||||
await sock.relayMessage(`${phone}@s.whatsapp.net`, msg.message, { messageId: msg.key.id });
|
||||
|
||||
res.json({ success: true });
|
||||
} catch (e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user