upd4
This commit is contained in:
parent
563760f812
commit
da74d76a7c
118
index.js
118
index.js
@ -124,31 +124,115 @@ app.post('/sendText', async (req, res) => {
|
|||||||
app.post('/sendButtons', async (req, res) => {
|
app.post('/sendButtons', async (req, res) => {
|
||||||
const { phone } = req.body;
|
const { phone } = req.body;
|
||||||
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sock.sendMessage(`${phone}@s.whatsapp.net`, {
|
const content = {
|
||||||
text: "Découvre nos services",
|
viewOnceMessage: {
|
||||||
footer: "Powered by Fizzxy",
|
message: {
|
||||||
|
messageContextInfo: {
|
||||||
|
deviceListMetadata: {},
|
||||||
|
deviceListMetadataVersion: 2
|
||||||
|
},
|
||||||
|
interactiveMessage: proto.Message.InteractiveMessage.create({
|
||||||
|
body: { text: "Fizzxy Dev" },
|
||||||
|
footer: { text: "Bot" },
|
||||||
|
header: {
|
||||||
|
title: "Igna",
|
||||||
|
subtitle: "test",
|
||||||
|
hasMediaAttachment: false
|
||||||
|
},
|
||||||
|
nativeFlowMessage: {
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
buttonId: "visit_site",
|
name: "single_select",
|
||||||
buttonText: {
|
buttonParamsJson: JSON.stringify({
|
||||||
displayText: "🌐 Visiter le site"
|
title: "title",
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
title: "menu",
|
||||||
|
highlight_label: "label",
|
||||||
|
rows: [
|
||||||
|
{
|
||||||
|
header: "header",
|
||||||
|
title: "title",
|
||||||
|
description: "description",
|
||||||
|
id: "id1"
|
||||||
},
|
},
|
||||||
type: 4,
|
{
|
||||||
nativeFlowInfo: {
|
header: "header",
|
||||||
name: "ctl_url",
|
title: "title",
|
||||||
paramsJson: JSON.stringify({
|
description: "description",
|
||||||
display_text: "🌐 Visiter le site",
|
id: "id2"
|
||||||
url: "https://canguidev.fr",
|
}
|
||||||
merchant_url: "https://canguidev.fr"
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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 });
|
res.json({ success: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user