Commit a5f56bac authored by Gabriel's avatar Gabriel

Agrega un try-catch para capturar errores de conexion con sendinblue

parent 6de9840e
......@@ -31,13 +31,17 @@ crisp.CrispClient.on("message:send", async function (message) {
});
async function enviarUserAListaSendingblue(website_id, session_id, listId){
let crispUsrData = await crisp.getCrispData(website_id, session_id);
let nombreCompleto = crispUsrData['nickname']; // ej: "Lucas Mariano | Rodriguez"
let nombres = nombreCompleto.split("|")[0].slice(0, -1);
let apellidos = nombreCompleto.split("|")[1].substring(1);
let email = crispUsrData['email'];
let phone = crispUsrData['phone'];
try{
let crispUsrData = await crisp.getCrispData(website_id, session_id);
let nombreCompleto = crispUsrData['nickname']; // ej: "Lucas Mariano | Rodriguez"
let nombres = nombreCompleto.split("|")[0].slice(0, -1);
let apellidos = nombreCompleto.split("|")[1].substring(1);
let email = crispUsrData['email'];
let phone = crispUsrData['phone'];
console.log(nombres, apellidos, email, phone);
sendinblue.saveContactToList(email, nombres, apellidos, phone, listId);
console.log(nombres, apellidos, email, phone);
sendinblue.saveContactToList(email, nombres, apellidos, phone, listId);
} catch (e) {
console.log(`Hubo un error al intentar enviar el usuario a la lista de sendinblue. Error: ${e}`);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment