Commit 4d68464c authored by Gabriel's avatar Gabriel

Redirige el flujo segun el websiteId

parent 2f7d06eb
const axios = require('axios'); const axios = require('axios');
const config = require('config'); const config = require('config');
const handlers = require('./handlers/is_turnos_programados.js'); const handlerTurnosProgramados = require('./handlers/is_turnos_programados.js');
const crisp = require('./crisp.js'); const crisp = require('./crisp.js');
const utils = require('./utils.js'); const utils = require('./utils.js');
const pasos = require('./handlers/pasos_is_turnos_programados.js'); const pasosTurnosProgramados = require('./handlers/pasos_is_turnos_programados.js');
const is = require('./endpoints/is.js'); const is = require('./endpoints/is.js');
const sendinblue = require('./endpoints/sendinblue.js'); const sendinblue = require('./endpoints/sendinblue.js');
...@@ -24,8 +24,10 @@ crisp.CrispClient.on("message:send", async function (message) { ...@@ -24,8 +24,10 @@ crisp.CrispClient.on("message:send", async function (message) {
} }
let siguientePaso = await crisp.getSiguientePaso(message.website_id, message.session_id); let siguientePaso = await crisp.getSiguientePaso(message.website_id, message.session_id);
if (siguientePaso == null) { if (siguientePaso == null) {
if(message.website_id === WEBSITE_ID_TURNOS_PROGRAMADOS){
enviarUserAListaSendingblue(message.website_id, message.session_id, config.get('sendingblueListId')); enviarUserAListaSendingblue(message.website_id, message.session_id, config.get('sendingblueListId'));
await crisp.setSiguientePaso(message.website_id, message.session_id, pasos.ASK_RESERVAR_TURNO) await crisp.setSiguientePaso(message.website_id, message.session_id, pasosTurnosProgramados.ASK_RESERVAR_TURNO)
}
} }
await darSiguientePaso(message, message.website_id, message.session_id); await darSiguientePaso(message, message.website_id, message.session_id);
...@@ -34,7 +36,9 @@ crisp.CrispClient.on("message:send", async function (message) { ...@@ -34,7 +36,9 @@ crisp.CrispClient.on("message:send", async function (message) {
async function darSiguientePaso(message, website_id, session_id) { async function darSiguientePaso(message, website_id, session_id) {
let siguientePaso = await crisp.getSiguientePaso(message.website_id, message.session_id); let siguientePaso = await crisp.getSiguientePaso(message.website_id, message.session_id);
let userData = await crisp.getUserData(website_id, session_id); let userData = await crisp.getUserData(website_id, session_id);
handlers[siguientePaso](message, userData, website_id, session_id); if(website_id === WEBSITE_ID_TURNOS_PROGRAMADOS){
handlerTurnosProgramados[siguientePaso](message, userData, website_id, session_id);
}
} }
async function enviarUserAListaSendingblue(website_id, session_id, listId){ async function enviarUserAListaSendingblue(website_id, session_id, listId){
......
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