From da74d76a7cef9c6556dff4073ff99693d9f64acf Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 6 May 2025 14:00:21 +0200 Subject: [PATCH] upd4 --- index.js | 128 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 106 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index af8f30e..0c29b91 100644 --- a/index.js +++ b/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) {