This commit is contained in:
julien 2025-05-06 12:54:32 +02:00
parent f336c9eaa5
commit 432c43c0d7

View File

@ -126,9 +126,10 @@ app.post('/sendButtons', async (req, res) => {
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
try {
const msg = {
text: 'Choisis une option :',
footer: 'Clique sur un bouton ci-dessous',
const msgContent = {
buttonsMessage: {
contentText: 'Choisis une option :',
footerText: 'Clique sur un bouton ci-dessous',
buttons: [
{
buttonId: 'id_produits',
@ -142,9 +143,18 @@ app.post('/sendButtons', async (req, res) => {
}
],
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 });
} catch (e) {
console.error('❌ Erreur bouton simple :', e);