This commit is contained in:
julien 2025-05-06 14:00:21 +02:00
parent 563760f812
commit da74d76a7c

128
index.js
View File

@ -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: {
buttons: [ messageContextInfo: {
{ deviceListMetadata: {},
buttonId: "visit_site", deviceListMetadataVersion: 2
buttonText: {
displayText: "🌐 Visiter le site"
}, },
type: 4, interactiveMessage: proto.Message.InteractiveMessage.create({
nativeFlowInfo: { body: { text: "Fizzxy Dev" },
name: "ctl_url", footer: { text: "Bot" },
paramsJson: JSON.stringify({ header: {
display_text: "🌐 Visiter le site", title: "Igna",
url: "https://canguidev.fr", subtitle: "test",
merchant_url: "https://canguidev.fr" 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 }); res.json({ success: true });
} catch (e) { } catch (e) {