qqsqsqssqsqsq

This commit is contained in:
julien 2025-05-06 16:35:12 +02:00
parent f42f948ba1
commit eace21c48a

View File

@ -128,45 +128,44 @@ app.post('/sendInteractiveImage', async (req, res) => {
} }
try { try {
// 2) Construire l'URL publique de l'image // 2) Construire l'URL publique
// Remplacez “https://votre-domaine.com” par votre vrai domaine ou IP publique const imageUrl = `https://wa.canguidev.fr/static/logo-merlo-cs-FR.jpg`;
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 // 3) Contenu du message interactif
await sock.sendMessage( const message = {
`${phone}@s.whatsapp.net`, interactive: {
{ type: 'button',
interactive: { header: {
type: 'button', type: 'IMAGE',
header: { image: { url: imageUrl }
type: 'IMAGE', },
image: { url: imageUrl } body: {
}, text: caption || 'Description par défaut'
body: { },
text: caption || 'Description par défaut' footer: {
}, text: footer || 'Pied de page'
footer: { },
text: footer || 'Pied de page' action: {
}, buttons: [
action: { {
buttons: [ type: 'url',
{ title: '📄 Proposition',
type: 'url', url: 'https://merlo-ch.com/uploads/proposition/f_p_250505_0000136_00008_EB00001909.pdf'
title: '📄 Proposition', },
url: 'https://merlo-ch.com/uploads/proposition/f_p_250505_0000136_00008_EB00001909.pdf' {
}, type: 'url',
{ title: '🔧 Spécifications',
type: 'url', url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf'
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 }); res.json({ success: true });
} catch (e) { } catch (e) {
console.error('❌ Erreur interactive image :', e); console.error('❌ Erreur interactive image :', e);
res.status(500).json({ error: e.message }); res.status(500).json({ error: e.message });