diff --git a/backend/src/controllers/HitController.ts b/backend/src/controllers/HitController.ts index 97d2904..644b2bd 100644 --- a/backend/src/controllers/HitController.ts +++ b/backend/src/controllers/HitController.ts @@ -94,7 +94,9 @@ export const hit = async (req: Request, res: Response): Promise => { let response: any = ""; - if (["atdabriu", "atdatualizou"].includes(req.body["action"])) { + if ( + ["atdabriu", "atdatualizou", "atdreabriu"].includes(req.body["action"]) + ) { response = await hitPortalMonitoring({ "params[n_chamado_web]": req.body["n_chamado_web"], method: "omnihit.consultachamado" @@ -234,10 +236,17 @@ async function sendMessageInsertInfoSLM( await new Promise(f => setTimeout(f, 1000)); await sendMessageHitMonitoring( - `O Protocolo *${n_chamado_web?.queryItem}* foi encerrado. Não é mais possível adicionar informação. Se desejar consultar o historico digite 1`, + `O Protocolo *${n_chamado_web?.queryItem}* foi encerrado. Não é mais possível adicionar informação. Sendo necessário algum tipo de interação, digite 0 e na sequencia fale com o nosso time de suporte técnico na opção 4.`, ticket ); } + } else { + await new Promise(f => setTimeout(f, 1000)); + + await sendMessageHitMonitoring( + `O Protocolo *${req.body["n_chamado_web"]}* foi encerrado. Sendo necessário algum tipo de interação, digite *0* e na sequencia fale com o nosso time de suporte técnico na opção *4*.`, + ticket + ); } } } diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index 4b2c774..883c83e 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -389,14 +389,7 @@ async function sendDelayedMessages( name: "n_chamado_web" }); - let valid = await endPointQuery( - "http://177.107.192.247:8095/labs/monitoramentohit/api/api.php", - "post", - { - "params[n_chamado_web]": params[1], - method: "omnihit.consultachamadostatus" - } - ); + let valid = await chamadoStatus(params[1]); if (valid && valid.data.result == "open") { botSendMessage( @@ -465,7 +458,20 @@ async function sendDelayedMessages( `Não existe nenhum chamado para essa operação!\n _Digite *0* para falar com a HIT._` ); } else if (response.trim().length > 0) { + let valid = await chamadoStatus(params[1]); + await SendWhatsAppMessage({ body: response, ticket }); + + if (valid && valid.data.result == "open") { + } else if (valid && valid.data.result == "notfound") { + } else if (valid && valid.data.result == "close") { + await new Promise(f => setTimeout(f, 1000)); + + await SendWhatsAppMessage({ + body: `O Protocolo *${params[1]}* foi encerrado. Sendo necessário algum tipo de interação, digite *0* e na sequencia fale com o nosso time de suporte técnico na opção *4*.`, + ticket + }); + } } } catch (error) { botSendMessage( @@ -527,6 +533,17 @@ async function sendDelayedMessages( // await new Promise(f => setTimeout(f, 1000)); // } } + + async function chamadoStatus(params: string) { + return await endPointQuery( + "http://177.107.192.247:8095/labs/monitoramentohit/api/api.php", + "post", + { + "params[n_chamado_web]": params, + method: "omnihit.consultachamadostatus" + } + ); + } } const extractCallCode = (str: string) => {