Correção para exibir mensagens de configuração de ticket apos transferir o atendimento para fila

pull/20/head
adriano 2023-08-09 18:03:38 -03:00
parent d670d879e5
commit cf67523bab
2 changed files with 56 additions and 45 deletions

View File

@ -7,16 +7,16 @@ import ListUsersService from "../services/UserServices/ListUsersService";
import { isHoliday, isOutBusinessTime, isWeekend } from "./TicketConfig";
const _botIsOnQueue = async (botName: string) => {
// MESSAGE TO HOLIDAY
const holiday: any = await isHoliday();
// MESSAGES TO SATURDAY OR SUNDAY
const weekend: any = await isWeekend();
// MESSAGE TO BUSINESS TIME
const businessTime: any = await isOutBusinessTime();
// // MESSAGE TO HOLIDAY
// const holiday: any = await isHoliday();
// // MESSAGES TO SATURDAY OR SUNDAY
// const weekend: any = await isWeekend();
// // MESSAGE TO BUSINESS TIME
// const businessTime: any = await isOutBusinessTime();
if (holiday?.set || weekend?.set || businessTime?.set) {
return { isOnQueue: false };
}
// if (holiday?.set || weekend?.set || businessTime?.set) {
// return { isOnQueue: false };
// }
const botInfoFile = dir.join(os.tmpdir(), `botInfo.json`);

View File

@ -99,8 +99,6 @@ import ShowQueryItemService from "../SLM/ShowQueryItemService";
import QueryItem from "../../models/QueryItem";
import SettingTicket from "../../models/SettingTicket";
var lst: any[] = getWhatsappIds();
interface Session extends Client {
@ -435,7 +433,7 @@ async function sendDelayedMessages(
} else {
botSendMessage(
ticket,
`Ops! Não foi possível validar seu protocolo devido a um erro na comunicação com o servidor.Tente novamente mais tarde.\n_Digite *0* para falar com a HIT._`
`Ops! Não foi possível validar seu protocolo devido a um erro na comunicação com o servidor.Tente novamente mais tarde.\n_Digite *0* para voltar ao menu anterior._`
);
}
}
@ -476,7 +474,7 @@ async function sendDelayedMessages(
if (response.trim().length == 0) {
botSendMessage(
ticket,
`Não existe nenhum chamado para essa operação!\n _Digite *0* para falar com a HIT._`
`Não existe nenhum chamado para essa operação!\n _Digite *0* para voltar ao menu anterior._`
);
} else if (response.trim().length > 0) {
let valid = await chamadoStatus(params[1]);
@ -508,7 +506,7 @@ async function sendDelayedMessages(
} catch (error) {
botSendMessage(
ticket,
`Houve um erro ao realizar a consulta!\n _Digite *0* para falar com a HIT._`
`Houve um erro ao realizar a consulta!\n _Digite *0* para voltar ao menu anterior._`
);
}
} else if (msgAction.actions[0] == "queue_transfer") {
@ -609,7 +607,7 @@ const sendDialogflowAwswer = async (
if (msg.type != "chat") {
botSendMessage(
ticket,
`Desculpe, nao compreendi!\nEnvie apenas texto quando estiver interagindo com o bot!\n _Digite *0* para falar com a HIT._`
`Desculpe, nao compreendi!\nEnvie apenas texto quando estiver interagindo com o bot!\n _Digite *0* para voltar ao menu anterior._`
);
return;
}
@ -617,7 +615,7 @@ const sendDialogflowAwswer = async (
if (msg.type == "chat" && String(msg.body).length > 120) {
botSendMessage(
ticket,
`Desculpe, nao compreendi!\nTexto acima de 120 caracteres!\n _Digite *0* para falar com a HIT._`
`Desculpe, nao compreendi!\nTexto acima de 120 caracteres!\n _Digite *0* para voltar ao menu anterior._`
);
return;
}
@ -1239,6 +1237,21 @@ const handleMessage = async (msg: any, wbot: any): Promise<void> => {
await setMessageAsRead(ticket);
}
let ticketHasQueue = false;
if (
botInfo.isOnQueue &&
ticket?.queueId &&
botInfo.botQueueId != ticket?.queueId
) {
console.log("BOT SECTION");
ticketHasQueue = true;
} else if (!botInfo.isOnQueue && ticket?.queueId) {
console.log("NO BOT SECTION");
ticketHasQueue = true;
}
if (ticketHasQueue) {
// MESSAGE TO HOLIDAY
const holiday: any = await isHoliday();
@ -1277,14 +1290,12 @@ const handleMessage = async (msg: any, wbot: any): Promise<void> => {
botSendMessage(ticket, businessTime.msg);
return;
}
}
} catch (err) {
Sentry.captureException(err);
console.log("xxxxxxxxxxxxx err: ", err);
logger.error(`Error handling whatsapp message: Err: ${err}`);
}
};
const handleMsgAck = async (msg_id: any, ack: any) => {