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;}