Question
Is it possible to control when the chat widget displays?
Answer
You can delay the chat widget from showing up on a page after a specific amount of time by using the function show() of the Javascript API.
In the sample below, the widget is delayed for 60 seconds. The time is entered in milliseconds in the script setTimeout() function.
<script type="text/javascript">
var bool = true;
$zopim( function() {
bool = $zopim.livechat.isChatting();
if(bool==false) {
$zopim.livechat.hideAll();
setTimeout(showzopim,60000); //time in milliseconds - 60 seconds = 60000
function showzopim() {
$zopim.livechat.window.show()
}
}
});
</script>
If you use the Web Widget (Classic), see this article: Can I delay the Web Widget from popping up?
Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online.
8 Comments
Hi,
I just implemented the same, and it worked well. Thanks for the code. I have faced the issue that the widget is showing when offline. I want to hide the widget when offline. Since we forcefully showing the widget $zopim.livechat.window.show() so that the $zopim.livechat.button.setHideWhenOffline is not working any more.
Also is there any method to check the status?
Hi Sumith,
To hide the widget when offline, you will just need to make sure that the offline form is deactivated from your Chat Widget settings, Forms tab. Please take note that the chat widget status depends on your Agent Status in the Chat dashboard.
Hope this helps! Thanks!
Hi, I tried this solution to delay the loading of the chat on the site, it works, the only thing that then shows it open and not closed. There is a way that to show closed chat after loading otherwise it becomes invasive.
Hi Guilio,
Hope you are well.
If you would like to show only "chat button" after delaying the chat widget from showing up, you can then replace the "$zopim.livechat.window.show()" to "$zopim.livechat.button.show()" instead.
So, the whole thing ends like this on the <HEAD>?
<!-- Start of ghostfiregaming Zendesk Widget script -->
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=XXXXXXX-XXXXX-XXXXXXXXX> </script>
<script type="text/javascript">
var bool = true;
$zopim( function() {
bool = $zopim.livechat.isChatting();
if(bool==false) {
$zopim.livechat.hideAll();
setTimeout(showzopim,60000); //time in milliseconds - 60 seconds = 60000
function showzopim() {
$zopim.livechat.window.show()
}
}
});
</script>
<!-- End of ghostfiregaming Zendesk Widget script -->
Hi Eduardo,
I can see that you have already submitted a ticket about this. I'll go ahead and respond via ticket so we can move forward on your request. Thanks!
Hi ricardo,
would you mind sharing the link here with web widget case? the one you shared is already dead link. seems like broken? or would you mind sharing the code with classic web widget? thank
Regards,
Hello Sergio Lio. Sorry for that. I have updated the article. The article's link is Can I delay the Web Widget from popping up?
Please sign in to leave a comment.