From c8824de9012c8385fc997846bee542c0125d079e Mon Sep 17 00:00:00 2001 From: Jelson Stoelben Rodrigues Date: Mon, 15 Sep 2025 07:27:57 -0300 Subject: [PATCH] chore: filter no comercial agent available chats --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1dee7d2..1666581 100644 --- a/src/main.rs +++ b/src/main.rs @@ -268,6 +268,15 @@ fn main() -> anyhow::Result<()> { if portal_link_offer.is_some() {return None;} + // Filter no comercial agent available + let comercial_agents_unavailable = talk_histories.as_array().expect("Wrong message type received from talk histories").into_iter().find(|message_object|{ + let message = message_object["message"].as_str().expect("Failed to decode message as string"); + let found = message.to_uppercase().find(&"Transbordo automático para a fila [NovaNet -> Atendimento -> Suporte], pois não havia agentes disponíveis na fila [NovaNet -> Atendimento -> Comercial]".to_uppercase()); + found.is_some() + }); + + if comercial_agents_unavailable.is_some() {return None;} + // Filter Bot finished chats if json["agent"]["user"]["name"].as_str().unwrap_or("unknown_user") == "PipeBot" {return None;}