log los eventos del webhook
All checks were successful
Deploy conversation layer / deploy (push) Successful in 19s

This commit is contained in:
2025-06-04 22:16:17 -06:00
parent 390c7da5fd
commit 7abb14f311

View File

@@ -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 {