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) => {
|
app.post('/sendInteractiveImage', async (req, res) => {
|
||||||
const { phone, caption, title, subtitle, footer } = req.body;
|
const { phone, caption, footer } = req.body;
|
||||||
if (!sock || !isConnected) {
|
if (!sock || !isConnected) {
|
||||||
return res.status(400).json({ error: 'Non connecté' });
|
return res.status(400).json({ error: 'Non connecté' });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// URL publique vers votre image (hébergée dans ./public via express.static)
|
// URL publique de votre image (hébergée dans ./public via express.static)
|
||||||
const BASE = process.env.BASE_URL || 'https://wa.canguidev.fr';
|
const BASE_URL = process.env.BASE_URL || 'https://wa.canguidev.fr';
|
||||||
const imageUrl = `${BASE}/static/logo-merlo-cs-FR.jpg`;
|
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(
|
await sock.sendMessage(
|
||||||
`${phone}@s.whatsapp.net`,
|
`${phone}@s.whatsapp.net`,
|
||||||
{
|
{
|
||||||
image: { url: imageUrl }, // header média
|
interactive: {
|
||||||
caption: caption || 'Description par défaut', // texte sous l’image
|
type: 'button',
|
||||||
title: title || 'Titre par défaut', // titre au-dessus
|
header: {
|
||||||
subtitle: subtitle || 'Sous-titre', // sous-titre
|
type: 'IMAGE',
|
||||||
footer: footer || 'Pied de page', // pied
|
image: { url: imageUrl }
|
||||||
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'
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
{
|
body: {
|
||||||
name: 'cta_url',
|
text: caption || 'Description par défaut'
|
||||||
buttonParamsJson: JSON.stringify({
|
},
|
||||||
display_text: '🔧 Spécifications',
|
footer: {
|
||||||
url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf'
|
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) {
|
} catch (e) {
|
||||||
console.error('❌ Erreur interactive image :', 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) => {
|
// app.post('/sendInteractiveImage', async (req, res) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user