Skip to main content

Bom Dia Gente, poderia me ajudar com o seguinte problema ?



Estou utilizando o código:



function run() {


let workSchedule =


{


“num”: 1,


“name”: “Monday”,


“portugueseName”: “Segunda”,


“workTime”: /


{


“start”: “08:00”,


“end”: “18:00”


}


]


},


{


“num”: 2,


“name”: “Tuesday”,


“portugueseName”: “Terça”,


“workTime”: �


{


“start”: “08:00”,


“end”: “18:00”


}


]


},


{


“num”: 3,


“name”: “Wednesday”,


“portugueseName”: “Quarta”,


“workTime”: �


{


“start”: “08:00”,


“end”: “18:00”


}


]


},


{


“num”: 4,


“name”: “Thursday”,


“portugueseName”: “Quinta”,


“workTime”:


{


“start”: “08:00”,


“end”: “18:00”


}


]


},


{


“num”: 5,


“name”: “Friday”,


“portugueseName”: “Sexta”,


“workTime”:


{


“start”: “08:00”,


“end”: “18:00”


}


]


}


];



return JSON.stringify(workSchedule);



}



E para verificar o:


// Receive the variables as parameters



function run(offset, weekSchedule) {



offset = parseInt(offset);



weekSchedule = JSON.parse(weekSchedule);



let today = nowUTC(offset);



if (isWorkDay(today, weekSchedule)) {



let todaySchedule = getTodaySchedule(weekSchedule, today);



let intervalTime = getIntervalTime(todaySchedule, today);



return checkTime(intervalTime, today);



}



return false;



}



function getIntervalTime(todaySchedule, today) {



let intervalTime = n];



for (let i = 0; i < todaySchedule.workTime.length; i++) {



intervalTime.push({



start: utcDate(todaySchedule.workTime i].start, today),



end: utcDate(todaySchedule.workTimeyi].end, today)



});



}



return intervalTime;



}



function checkTime(intervalTime, today) {



for (let i = 0; i < intervalTime.length; i++) {



if (today - intervalTimeli].start > 0 && intervalTime i].end - today > 0)



return true;



}



return false;



}



function getTodaySchedule(weekSchedule, today) {



for (let i = 0; i < weekSchedule.length; i++) {



if (weekSchedule i].num == today.getUTCDay()) return weekScheduleui];



}



}



//Get now UTC Date



function nowUTC(offset) {



let now = new Date();



let utc_timestamp = Date.UTC(



now.getUTCFullYear(),



now.getUTCMonth(),



now.getUTCDate(),



now.getUTCHours(),



now.getUTCMinutes(),



now.getUTCSeconds(),



now.getUTCMilliseconds()



);



return new Date(utc_timestamp + offset * 3600 * 1000);



}



//Get UTC Date



function utcDate(timeString, today) {



let hour = getValueByString(“hour”, timeString);



let minutes = getValueByString(“minutes”, timeString);



let utc_timestamp = Date.UTC(



today.getUTCFullYear(),



today.getUTCMonth(),



today.getUTCDate(),



hour,



minutes,



0,



0



);



return new Date(utc_timestamp);



}



//Get hour/minute by string with pattern HH:mm



function getValueByString(type, timeString) {



if (type === “hour”) {



return parseInt(timeString.substring(0, timeString.indexOf(“:”)));



} else if (type === “minutes”) {



return parseInt(



timeString.substring(timeString.indexOf(“:”) + 1, timeString.length)



);



}



return 0;



}



//Get if today is a work day



function isWorkDay(today, workDays) {



for (let i = 0; i < workDays.length; i++) {



if (workDays0i].num == today.getDay().toString()) return true;



}



return false;



}



E em Preprod (Blip) ele verificar normal o horario de atendimento, mas quando passo para o WhatsApp não, alguém conseguiria me ajudar ?

Olá @Gabriel_Lutz tudo bem ?



No caso tem que ver se quem vem do whatsapp, está passando realmente pelo bloco, pode usar a extensão do beholder para validar passo a passo e se não tem outro tipo de direcionamento devido a notificação ativa que ignora esse bloco e já cai no atendimento humano.


Comente