dddddssss
This commit is contained in:
parent
eeff874305
commit
f336c9eaa5
51
index.js
51
index.js
@ -126,47 +126,32 @@ app.post('/sendButtons', async (req, res) => {
|
|||||||
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const content = {
|
const msg = {
|
||||||
viewOnceMessage: {
|
text: 'Choisis une option :',
|
||||||
message: {
|
footer: 'Clique sur un bouton ci-dessous',
|
||||||
interactiveMessage: proto.Message.InteractiveMessage.create({
|
buttons: [
|
||||||
body: { text: "Choisis une option :" },
|
{
|
||||||
footer: { text: "Réponds via un bouton" },
|
buttonId: 'id_produits',
|
||||||
nativeFlowMessage: {
|
buttonText: { displayText: '🛍 Voir produits' },
|
||||||
buttons: [
|
type: 1
|
||||||
{
|
},
|
||||||
name: "quick_reply",
|
{
|
||||||
buttonParamsJson: JSON.stringify({
|
buttonId: 'id_support',
|
||||||
display_text: "Option A",
|
buttonText: { displayText: '☎ Contacter support' },
|
||||||
id: ".optionA"
|
type: 1
|
||||||
})
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ctl_url",
|
|
||||||
buttonParamsJson: JSON.stringify({
|
|
||||||
display_text: "Ouvrir mon site",
|
|
||||||
url: "https://example.com",
|
|
||||||
merchant_url: "https://example.com"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
|
headerType: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
const msg = generateWAMessageFromContent(`${phone}@s.whatsapp.net`, content, {});
|
await sock.sendMessage(`${phone}@s.whatsapp.net`, msg);
|
||||||
console.log("📤 Message interactif généré :", JSON.stringify(msg.message, null, 2));
|
|
||||||
|
|
||||||
await sock.relayMessage(`${phone}@s.whatsapp.net`, msg.message, { messageId: msg.key.id });
|
|
||||||
|
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('❌ Erreur sendButtons:', e);
|
console.error('❌ Erreur bouton simple :', e);
|
||||||
res.status(500).json({ error: e.message });
|
res.status(500).json({ error: e.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.listen(3001, () => console.log('🚀 Serveur Baileys démarré sur http://localhost:3001'));
|
app.listen(3001, () => console.log('🚀 Serveur Baileys démarré sur http://localhost:3001'));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user