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 {