sdsddsds
This commit is contained in:
parent
792b439294
commit
ccfe2cf3b5
60
index.js
60
index.js
@ -122,48 +122,54 @@ app.post('/sendButtons', async (req, res) => {
|
||||
}
|
||||
});
|
||||
app.post('/sendInteractiveImage', async (req, res) => {
|
||||
const { phone, caption, title, subtitle, footer } = req.body;
|
||||
const { phone, caption, footer } = req.body;
|
||||
if (!sock || !isConnected) {
|
||||
return res.status(400).json({ error: 'Non connecté' });
|
||||
}
|
||||
|
||||
try {
|
||||
// URL publique vers votre image (hébergée dans ./public via express.static)
|
||||
const BASE = process.env.BASE_URL || 'https://wa.canguidev.fr';
|
||||
const imageUrl = `${BASE}/static/logo-merlo-cs-FR.jpg`;
|
||||
// URL publique de votre image (hébergée dans ./public via express.static)
|
||||
const BASE_URL = process.env.BASE_URL || 'https://wa.canguidev.fr';
|
||||
const imageUrl = `${BASE_URL}/static/logo-merlo-cs-FR.jpg`;
|
||||
|
||||
// Envoi du message “Interactive with media” (image en header + boutons URL)
|
||||
// **Envoi 100% “interactive”** — format officiel pris en charge par iOS
|
||||
await sock.sendMessage(
|
||||
`${phone}@s.whatsapp.net`,
|
||||
{
|
||||
image: { url: imageUrl }, // header média
|
||||
caption: caption || 'Description par défaut', // texte sous l’image
|
||||
title: title || 'Titre par défaut', // titre au-dessus
|
||||
subtitle: subtitle || 'Sous-titre', // sous-titre
|
||||
footer: footer || 'Pied de page', // pied
|
||||
media: true, // active le header image
|
||||
interactiveButtons: [ // vos boutons URL
|
||||
{
|
||||
name: 'cta_url',
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: '📄 Proposition',
|
||||
url: 'https://merlo-ch.com/uploads/proposition/f_p_250505_0000136_00008_EB00001909.pdf'
|
||||
})
|
||||
interactive: {
|
||||
type: 'button',
|
||||
header: {
|
||||
type: 'IMAGE',
|
||||
image: { url: imageUrl }
|
||||
},
|
||||
{
|
||||
name: 'cta_url',
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: '🔧 Spécifications',
|
||||
url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf'
|
||||
})
|
||||
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'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
);
|
||||
res.json({ success: true });
|
||||
|
||||
return res.json({ success: true });
|
||||
} catch (e) {
|
||||
console.error('❌ Erreur interactive image :', e);
|
||||
res.status(500).json({ error: e.message });
|
||||
return res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
// app.post('/sendInteractiveImage', async (req, res) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user