Skip to main content

Search Results

const createScriptAivo = () => { const token = "7e5f442c675d05d90e1b751e9fb55f28"; // add web channel const scriptAivo = document.createElement("script"); scriptAivo.classList = "script-aivo"; scriptAivo.type = "text/javascript"; scriptAivo.src = `https://cdn.agentbot.net/core/latest/core.js?Myjagsd4wLjY===`; // === Utility function to wait for elements === const waitForElement = ( selector, root, callback, maxTries = 20, interval = 300 ) => { let tries = 0; const timer = setInterval(() => { const el = root.querySelector(selector); if (el) { clearInterval(timer); callback(el); } else if (++tries >= maxTries) { clearInterval(timer); console.warn(`Selector not found: ${selector}`); } }, interval); }; // === When the Aivo script loads === scriptAivo.onload = function () { $aivo.run(token); $aivo.shadowRoot(false); $aivo.ready(() => { try { $aivo.chat.minimize(true); } catch (error) { console.warn(error); } $aivo.chat.onOpenWindow(() => { const AgentAppContainerExist = $aivo.query.exists("#AgentAppContainer"); const showNotificationComponent = () => { const agentAppContainerElement = document.querySelector("#AgentAppContainer")?.shadowRoot; if (!agentAppContainerElement) return console.warn("No se encontrĂ³ #AgentAppContainer"); // Wait for chat input to be available waitForElement( ".aivochat-content", agentAppContainerElement, (textinput) => { textinput.style.fontSize = "13px"; // change font size } ); // Wait for the main chat container to exist waitForElement( ".aivochat-container", agentAppContainerElement, (aivochatContainerElement) => { const notificationComponent = document.createElement("span"); notificationComponent.classList.add("aivo-custom-notification"); notificationComponent.textContent = "By using this ChatBot / Virtual Assistant, you understand that this communication is being recorded and may be reviewed by the credit union or its vendor. Please do not submit any personal information."; // message styles Object.assign(notificationComponent.style, { position: "absolute", display: "block", top: "48px", zIndex: "999999", width: "auto", minWidth: "300px", height: "auto", maxHeight: "60px", overflow: "auto", background: "#E7E7E7", padding: "4px 10px", fontSize: "10px", textAlign: "center", lineHeight: "normal", }); aivochatContainerElement.appendChild(notificationComponent); // Wait for messages and close button waitForElement( ".aivochat-messages", agentAppContainerElement, (aivochatMessages) => { aivochatMessages.style.top = "63px"; aivochatMessages.style.maxHeight = "calc(100% - 61px - 63px)"; } ); waitForElement( ".aivochat-header-close", agentAppContainerElement, (closeShadowElement) => { closeShadowElement.addEventListener("click", () => { const customNotification = agentAppContainerElement.querySelector( ".aivo-custom-notification" ); const aivochatMessages = agentAppContainerElement.querySelector( ".aivochat-messages" ); if (customNotification) { customNotification.remove(); if (aivochatMessages) { aivochatMessages.style.top = "0px"; aivochatMessages.style.maxHeight = "calc(100% - 61px)"; } } }); } ); } ); }; if (AgentAppContainerExist) { showNotificationComponent(); } else { setTimeout(showNotificationComponent, 2000); } }); }); }; return scriptAivo; }; document.head.appendChild(createScriptAivo());