From 7abb14f311277ae0d2ada514da2d1b6f7ba77da4 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Wed, 4 Jun 2025 22:16:17 -0600 Subject: [PATCH] log los eventos del webhook --- whatsapp-router/src/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/whatsapp-router/src/index.ts b/whatsapp-router/src/index.ts index 3e15ebc..ed9f069 100644 --- a/whatsapp-router/src/index.ts +++ b/whatsapp-router/src/index.ts @@ -113,6 +113,13 @@ app.use(express.json()); app.post('/webhook', async (req: express.Request, res: express.Response) => { const { message, text, from } = req.body as { message?: WhatsAppMessage; text?: string; from?: string }; const incoming = message || text; + + if (incoming) { + const tipo = typeof incoming === 'string' ? 'texto' : 'objeto'; + const origen = from || (message?.chatId ?? 'desconocido'); + log('info', `📩 Mensaje recibido (${tipo}) de ${origen}`); + } + try { if (!incoming) return res.sendStatus(200); if (!openWaUrl) throw new Error('Service URLs not configured'); @@ -125,9 +132,11 @@ app.post('/webhook', async (req: express.Request, res: express.Response) => { } catch (err: any) { console.error('Error processing message', err.message); } + res.sendStatus(200); }); + app.listen(port, async () => { console.log(`WhatsApp router listening on ${port}`); try {