dssfesfz
This commit is contained in:
parent
f336c9eaa5
commit
432c43c0d7
18
index.js
18
index.js
@ -126,9 +126,10 @@ 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 msg = {
|
const msgContent = {
|
||||||
text: 'Choisis une option :',
|
buttonsMessage: {
|
||||||
footer: 'Clique sur un bouton ci-dessous',
|
contentText: 'Choisis une option :',
|
||||||
|
footerText: 'Clique sur un bouton ci-dessous',
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
buttonId: 'id_produits',
|
buttonId: 'id_produits',
|
||||||
@ -142,9 +143,18 @@ app.post('/sendButtons', async (req, res) => {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
headerType: 1
|
headerType: 1
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await sock.sendMessage(`${phone}@s.whatsapp.net`, msg);
|
const msg = generateWAMessageFromContent(
|
||||||
|
`${phone}@s.whatsapp.net`,
|
||||||
|
{ buttonsMessage: msgContent.buttonsMessage },
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('✅ Message 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 bouton simple :', e);
|
console.error('❌ Erreur bouton simple :', e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user