From eace21c48af7c88c55449541f0f7b238f235d3e5 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 6 May 2025 16:35:12 +0200 Subject: [PATCH] qqsqsqssqsqsq --- index.js | 67 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/index.js b/index.js index 5a3826b..95346b5 100644 --- a/index.js +++ b/index.js @@ -128,45 +128,44 @@ app.post('/sendInteractiveImage', async (req, res) => { } try { - // 2) Construire l'URL publique de l'image - // Remplacez “https://votre-domaine.com” par votre vrai domaine ou IP publique - const imageUrl = `${'https://wa.canguidev.fr'}/static/logo-merlo-cs-FR.jpg`; + // 2) Construire l'URL publique + const imageUrl = `https://wa.canguidev.fr/static/logo-merlo-cs-FR.jpg`; - // 3) Envoyer directement le message interactif en référant l'image par URL - await sock.sendMessage( - `${phone}@s.whatsapp.net`, - { - interactive: { - type: 'button', - header: { - type: 'IMAGE', - image: { url: imageUrl } - }, - body: { - text: caption || 'Description par défaut' - }, - footer: { - text: footer || 'Pied de page' - }, - action: { - buttons: [ - { - type: 'url', - title: '📄 Proposition', - url: 'https://merlo-ch.com/uploads/proposition/f_p_250505_0000136_00008_EB00001909.pdf' - }, - { - type: 'url', - title: '🔧 Spécifications', - url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf' - } - ] - } + // 3) Contenu du message interactif + const message = { + interactive: { + type: 'button', + header: { + type: 'IMAGE', + image: { url: imageUrl } + }, + body: { + text: caption || 'Description par défaut' + }, + footer: { + text: footer || 'Pied de page' + }, + action: { + buttons: [ + { + type: 'url', + title: '📄 Proposition', + url: 'https://merlo-ch.com/uploads/proposition/f_p_250505_0000136_00008_EB00001909.pdf' + }, + { + type: 'url', + title: '🔧 Spécifications', + url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf' + } + ] } } - ); + }; + // 4) Envoi + await sock.sendMessage(`${phone}@s.whatsapp.net`, message); res.json({ success: true }); + } catch (e) { console.error('❌ Erreur interactive image :', e); res.status(500).json({ error: e.message });