diff --git a/server.js b/server.js index 3a484a7..b5938db 100644 --- a/server.js +++ b/server.js @@ -2976,8 +2976,9 @@ app.post("/webhook/evolution", async (req, res) => { const cleanPhone = telefonoCliente.slice(-9); // 1. BUSCAMOS EL SINIESTRO (Extrayendo urgencia y población) + // 1. Añadimos s.assigned_to a la consulta const svcQ = await pool.query(` - SELECT s.id, s.service_ref, u.full_name as worker_name, s.is_urgent, + SELECT s.id, s.service_ref, s.assigned_to, u.full_name as worker_name, s.is_urgent, st.name as status_name, s.raw_data->>'scheduled_date' as cita, s.raw_data->>'Población' as poblacion FROM scraped_services s @@ -3017,6 +3018,7 @@ app.post("/webhook/evolution", async (req, res) => { estado: service.status_name || "En proceso", operario: service.worker_name, cita: service.cita, + worker_id: service.assigned_to, poblacion: service.poblacion || "", // 👈 CRÍTICO para buscar rutas en la misma zona is_urgent: service.is_urgent // 👈 CRÍTICO para que no pida cita en urgencias });