ONKLNL
This commit is contained in:
parent
fdece82ee5
commit
4a3cd2ee18
74
index.js
74
index.js
@ -503,45 +503,47 @@ app.post('/testInteractiveImage', async (req, res) => {
|
|||||||
return res.status(400).json({ error: 'Non connecté à WhatsApp' });
|
return res.status(400).json({ error: 'Non connecté à WhatsApp' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const jid = `${phone}@s.whatsapp.net`;
|
const content = {
|
||||||
|
viewOnceMessage: {
|
||||||
try {
|
message: {
|
||||||
await sock.sendMessage(
|
messageContextInfo: {
|
||||||
jid,
|
deviceListMetadata: {},
|
||||||
{
|
deviceListMetadataVersion: 2
|
||||||
image: { url: "https://wa.canguidev.fr/static/logo-merlo-cs-FR.jpg" }, // remplace par une vraie image en HTTPS
|
},
|
||||||
caption: "📌 Découvrez notre service interactif !",
|
interactiveMessage: proto.Message.InteractiveMessage.create({
|
||||||
title: "Merlo Interactive Demo",
|
header: {
|
||||||
subtitle: "Choisissez une action",
|
hasMediaAttachment: true,
|
||||||
footer: "MERLO France © 2025",
|
imageMessage: { url: "https://canguidev.fr/static/logo-merlo-cs-FR.jpg" }
|
||||||
media: true,
|
|
||||||
interactiveButtons: [
|
|
||||||
{
|
|
||||||
name: "quick_reply",
|
|
||||||
buttonParamsJson: JSON.stringify({
|
|
||||||
display_text: "📩 Contacter un conseiller",
|
|
||||||
id: "contact_support"
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
{
|
body: { text: "Bienvenue chez Merlo France 🇫🇷\nChoisissez une action ci-dessous." },
|
||||||
name: "cta_url",
|
footer: { text: "MERLO - Support & Documentation" },
|
||||||
buttonParamsJson: JSON.stringify({
|
nativeFlowMessage: {
|
||||||
display_text: "🌐 Voir notre site",
|
buttons: [
|
||||||
url: "https://canguidev.fr"
|
{
|
||||||
})
|
name: "cta_reply",
|
||||||
|
buttonParamsJson: JSON.stringify({
|
||||||
|
display_text: "📩 Contacter support",
|
||||||
|
id: "support_action"
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "cta_url",
|
||||||
|
buttonParamsJson: JSON.stringify({
|
||||||
|
display_text: "🌐 Voir la fiche produit",
|
||||||
|
url: "https://example.com/product"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
})
|
||||||
},
|
|
||||||
{
|
|
||||||
quoted: null // tu peux y mettre un message si tu veux répondre à un msg précédent
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
};
|
||||||
res.json({ success: true });
|
|
||||||
} catch (e) {
|
const jid = `${phone}@s.whatsapp.net`;
|
||||||
console.error("❌ Erreur interactive image :", e);
|
const msg = generateWAMessageFromContent(jid, content, {});
|
||||||
res.status(500).json({ error: e.message });
|
await sock.relayMessage(jid, msg.message, { messageId: msg.key.id });
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 5) 404 et gestion des erreurs
|
// 5) 404 et gestion des erreurs
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user