Click to Chat - tutorial

A sample to show a chat button on your site. Box hide before chat start.
<style>
#comBoxAll{display:none}
</style>
<script type="text/javascript" src="https://cloud.apizee.com/contactBox/loaderIzeeChat.js"/>
<script> const buttonId= 'chat-button'; const clickButton = document.getElementById(buttonId); //callback from box const applicationCallback = function(contactBox, type, params) { switch (type) { case 'init': console.info('[ComBox] init', params); break; case 'newAgentSelected': clickButton.removeAttribute('disabled'); break; case 'noAgentAvailable': clickButton.setAttribute('disabled',false); break; } }; // box loader params const customParam = { applicationCallback:applicationCallback }; //video call function const chat = () =>{ let contactBox = Apizee.getContactBox(); let box = Apizee.getComBox(); if(box && contactBox){ document.getElementById('comBoxAll').style.display='block'; box.openBox(contactBox.publishedAgentId); } } // close/ hide box const closeBox = ()=>{ let contactBox = Apizee.getContactBox(); let box = Apizee.getComBox(); if(box && contactBox){ document.getElementById('comBoxAll').style.display='none'; box.close(contactBox.publishedAgentId); } }; //link chat button to chat function clickButton.onclick = chat; // load box loaderIzeeChat("YOUR_SITE_KEY",customParam);
</script>