From 2a59c059fcc97bfec46f588a69a7b9e8a622c063 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 6 May 2025 11:43:48 +0200 Subject: [PATCH] d --- index.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/index.js b/index.js index 424ce93..26df984 100644 --- a/index.js +++ b/index.js @@ -81,6 +81,35 @@ app.post('/sendText', async (req, res) => { res.status(500).json({ error: error.message || 'Erreur interne' }); } }); +// ✅ API POST : envoie un menu interactif (liste) +app.post('/sendListMenu', async (req, res) => { + const { phone, title, subtitle, description, buttonText, sections } = req.body; + + console.log('📥 Requête LIST MENU :'); + console.log('Phone:', phone); + console.log('Title:', title); + console.log('Subtitle:', subtitle); + console.log('Description:', description); + console.log('ButtonText:', buttonText); + console.log('Sections:', sections); + + if (!client) return res.status(500).json({ error: 'Client WhatsApp non initialisé' }); + + try { + await client.sendListMenu( + `${phone}@c.us`, + title, + subtitle, + description, + buttonText, + sections + ); + res.json({ success: true }); + } catch (error) { + console.error('❌ Erreur sendListMenu:', error); + res.status(500).json({ error: error.message || 'Erreur interne' }); + } +});