Actualizar server.js
This commit is contained in:
14
server.js
14
server.js
@@ -440,8 +440,17 @@ async function procesarConIA(ownerId, mensajeCliente, datosExpediente) {
|
||||
const userQ = await pool.query("SELECT wa_settings, full_name, portal_settings FROM users WHERE id=$1", [ownerId]);
|
||||
const userData = userQ.rows[0];
|
||||
const settings = userData?.wa_settings || {};
|
||||
const instruccionesExtra = settings.ai_custom_prompt || "";
|
||||
const empresaNombre = userData?.full_name || "nuestra empresa";
|
||||
const horarios = userData?.portal_settings || { m_start: "09:00", m_end: "14:00", a_start: "16:00", a_end: "19:00" };
|
||||
|
||||
// 🛠️ BLINDAJE DE HORARIOS: Extraemos campo a campo para evitar fallos de lectura
|
||||
const pSettings = userData?.portal_settings || {};
|
||||
const horarios = {
|
||||
m_start: pSettings.m_start || "09:00",
|
||||
m_end: pSettings.m_end || "14:00",
|
||||
a_start: pSettings.a_start || "16:00",
|
||||
a_end: pSettings.a_end || "19:00"
|
||||
};
|
||||
|
||||
if (!settings.wa_ai_enabled) return null;
|
||||
|
||||
@@ -541,6 +550,9 @@ async function procesarConIA(ownerId, mensajeCliente, datosExpediente) {
|
||||
--- 🎯 DIRECTIVA ESTRICTA PARA ESTE MENSAJE ---
|
||||
${directivaEstricta}
|
||||
|
||||
--- 📝 INSTRUCCIONES PERSONALIZADAS DE LA EMPRESA ---
|
||||
${instruccionesExtra ? instruccionesExtra : 'No hay reglas extra.'}
|
||||
|
||||
--- REGLAS DE ORO DE COMUNICACIÓN ---
|
||||
1. Máximo 2 frases. Los mensajes de WhatsApp deben ser cortos.
|
||||
2. Lee el historial de la conversación. Si el cliente solo responde "Ok" o "Gracias", dile "De nada, aquí estamos para lo que necesites" y cierra la charla. No le des la chapa.
|
||||
|
||||
Reference in New Issue
Block a user