qqsqsqssqsqsq
This commit is contained in:
parent
f42f948ba1
commit
eace21c48a
67
index.js
67
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 });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user