ddddd
This commit is contained in:
parent
f2df504c39
commit
eeff874305
40
index.js
40
index.js
@ -124,13 +124,49 @@ app.post('/sendText', async (req, res) => {
|
|||||||
app.post('/sendButtons', async (req, res) => {
|
app.post('/sendButtons', async (req, res) => {
|
||||||
const { phone } = req.body;
|
const { phone } = req.body;
|
||||||
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendInteractive(sock, `${phone}@s.whatsapp.net`, 'https://picsum.photos/200/300');
|
const content = {
|
||||||
|
viewOnceMessage: {
|
||||||
|
message: {
|
||||||
|
interactiveMessage: proto.Message.InteractiveMessage.create({
|
||||||
|
body: { text: "Choisis une option :" },
|
||||||
|
footer: { text: "Réponds via un bouton" },
|
||||||
|
nativeFlowMessage: {
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
name: "quick_reply",
|
||||||
|
buttonParamsJson: JSON.stringify({
|
||||||
|
display_text: "Option A",
|
||||||
|
id: ".optionA"
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ctl_url",
|
||||||
|
buttonParamsJson: JSON.stringify({
|
||||||
|
display_text: "Ouvrir mon site",
|
||||||
|
url: "https://example.com",
|
||||||
|
merchant_url: "https://example.com"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const msg = generateWAMessageFromContent(`${phone}@s.whatsapp.net`, content, {});
|
||||||
|
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(e);
|
console.error('❌ Erreur sendButtons:', 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