sezfZFEZFE
This commit is contained in:
parent
791967b226
commit
816b57b6fc
19
index.js
19
index.js
@ -127,20 +127,21 @@ app.post('/sendInteractiveImage', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1) Charger l'image en buffer
|
// 1) Lire l’image en Buffer
|
||||||
const imagePath = path.join(__dirname, 'public', 'logo-merlo-cs-FR.jpg');
|
const imagePath = path.join(__dirname, 'public', 'logo-merlo-cs-FR.jpg');
|
||||||
const imageBuffer = fs.readFileSync(imagePath);
|
const imageBuffer = fs.readFileSync(imagePath);
|
||||||
|
|
||||||
// 2) Envoyer directement avec sendMessage
|
// 2) Envoyer un message interactif AVEC MEDIA
|
||||||
await sock.sendMessage(
|
await sock.sendMessage(
|
||||||
`${phone}@s.whatsapp.net`,
|
`${phone}@s.whatsapp.net`,
|
||||||
{
|
{
|
||||||
image: { url: imageBuffer }, // Buffer pris en charge nativement
|
// on passe le Buffer directement (pas d'objet url)
|
||||||
caption: caption || 'Description par défaut',
|
image: imageBuffer,
|
||||||
title: title || 'Titre par défaut',
|
caption: caption || 'Description par défaut',
|
||||||
subtitle: subtitle || 'Sous-titre',
|
title: title || 'Titre par défaut',
|
||||||
footer: footer || 'Pied de page',
|
subtitle: subtitle || 'Sous-titre',
|
||||||
media: true, // indique un header media
|
footer: footer || 'Pied de page',
|
||||||
|
media: true, // active l’en-tête média
|
||||||
interactiveButtons: [
|
interactiveButtons: [
|
||||||
{
|
{
|
||||||
name: 'cta_url',
|
name: 'cta_url',
|
||||||
@ -152,7 +153,7 @@ app.post('/sendInteractiveImage', async (req, res) => {
|
|||||||
{
|
{
|
||||||
name: 'cta_url',
|
name: 'cta_url',
|
||||||
buttonParamsJson: JSON.stringify({
|
buttonParamsJson: JSON.stringify({
|
||||||
display_text: '🔧 Spec machine',
|
display_text: '🔧 Spécifications',
|
||||||
url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf'
|
url: 'https://merlo-ch.com/uploads/proposition/d_p_250505_0000136_00008_EB00001909.pdf'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user