dffdfd
This commit is contained in:
parent
4aa0b2061f
commit
8c4992074b
71
index.js
71
index.js
@ -454,44 +454,45 @@ app.post('/sendProductMessage', async (req, res) => {
|
||||
try {
|
||||
const jid = `${phone}@s.whatsapp.net`;
|
||||
|
||||
// Build product payload exactly comme avant
|
||||
const productPayload = {
|
||||
productImage: { url: productImageUrl },
|
||||
productImageCount,
|
||||
title: productTitle, // ici productTitle
|
||||
description: productDescription,
|
||||
priceAmount1000: priceAmount1000 * 1000, // ajustez si besoin
|
||||
currencyCode,
|
||||
retailerId,
|
||||
url: productUrl
|
||||
};
|
||||
|
||||
// Transformer les boutons
|
||||
const buttons = interactiveButtons.map(btn => {
|
||||
const params = {};
|
||||
if (btn.id) params.id = btn.id;
|
||||
if (btn.url) params.url = btn.url;
|
||||
if (btn.display_text) params.display_text = btn.display_text;
|
||||
return {
|
||||
name: btn.name,
|
||||
buttonParamsJson: JSON.stringify(params)
|
||||
};
|
||||
});
|
||||
|
||||
// **On utilise sock.sendMessage** et non client.sendMessage
|
||||
await sock.sendMessage(
|
||||
await client.sendMessage(
|
||||
jid,
|
||||
{
|
||||
product: productPayload,
|
||||
businessOwnerJid,
|
||||
caption,
|
||||
title: messageTitle,
|
||||
footer,
|
||||
media: true,
|
||||
interactiveButtons: buttons
|
||||
product: {
|
||||
productImage: { url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTc9APxkj0xClmrU3PpMZglHQkx446nQPG6lA&s"},
|
||||
productImageCount: 1,
|
||||
title: "Title Product",
|
||||
description: "Description Product",
|
||||
priceAmount1000: 20000 * 1000,
|
||||
currencyCode: "IDR",
|
||||
retailerId: "Retail",
|
||||
url: "https://example.com",
|
||||
},
|
||||
businessOwnerJid: "1234@s.whatsapp.net",
|
||||
caption: "Description Of Messages", //Additional information
|
||||
title: "Title Of Messages",
|
||||
footer: "Footer Messages",
|
||||
media: true,
|
||||
interactiveButtons: [
|
||||
{
|
||||
name: "quick_reply",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Display Button",
|
||||
id: "ID"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_url",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "Display Button",
|
||||
url: "https://www.example.com"
|
||||
})
|
||||
}
|
||||
]
|
||||
},
|
||||
quoted ? { quoted } : {}
|
||||
);
|
||||
{
|
||||
quoted : message
|
||||
}
|
||||
)
|
||||
|
||||
return res.json({ success: true });
|
||||
} catch (e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user