From b22fc85f2f215e5b740f9d6337dae295f10036c6 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 6 May 2025 11:38:23 +0200 Subject: [PATCH] v --- index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.js b/index.js index c709c5f..424ce93 100644 --- a/index.js +++ b/index.js @@ -61,7 +61,26 @@ app.post('/sendButtons', async (req, res) => { } }); +app.post('/sendText', async (req, res) => { + const { phone, message } = req.body; + console.log('đŸ“„ RequĂȘte TEXT :'); + console.log('Phone:', phone); + console.log('Message:', message); + + if (!client) return res.status(500).json({ error: 'Client WhatsApp non initialisĂ©' }); + if (!phone || !message) { + return res.status(400).json({ error: 'ParamĂštres manquants' }); + } + + try { + await client.sendText(`${phone}@c.us`, message); + res.json({ success: true }); + } catch (error) { + console.error('❌ Erreur sendText:', error); + res.status(500).json({ error: error.message || 'Erreur interne' }); + } +});