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 {
|
try {
|
||||||
const jid = `${phone}@s.whatsapp.net`;
|
const jid = `${phone}@s.whatsapp.net`;
|
||||||
|
|
||||||
// Build product payload exactly comme avant
|
await client.sendMessage(
|
||||||
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(
|
|
||||||
jid,
|
jid,
|
||||||
{
|
{
|
||||||
product: productPayload,
|
product: {
|
||||||
businessOwnerJid,
|
productImage: { url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTc9APxkj0xClmrU3PpMZglHQkx446nQPG6lA&s"},
|
||||||
caption,
|
productImageCount: 1,
|
||||||
title: messageTitle,
|
title: "Title Product",
|
||||||
footer,
|
description: "Description Product",
|
||||||
media: true,
|
priceAmount1000: 20000 * 1000,
|
||||||
interactiveButtons: buttons
|
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 });
|
return res.json({ success: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user