I want to have my own button placed on page, on click it opens chat widget. And when chat is closed, again set iframe to 1px height and width. I didnt find any events for this.
var chatFrontLoaded = false;
let chatBtnFront = document.querySelector(".spider-front-chat-btn");
chatBtnFront.addEventListener("click", function(e) {
e.preventDefault();
if(!chatFrontLoaded) return;
window.FrontChat("show");
});
setTimeout(()=>{
window.FrontChat("init", {chatId: "",shouldHideExpandButton:true, useDefaultLauncher: true, onInitCompleted: () => {
chatFrontLoaded = true;
window.FrontChat("hide");
const chatIframe = document.querySelector("#front-chat-iframe");
chatIframe.style.height = "1px";
chatIframe.style.width = "1px";
}});
if(chatFrontLoaded) {
}
}, 1500);
It is also very sad that I need wrap it all in setTimeout, because window.FrontChat returns error.