Skip to content

Instantly share code, notes, and snippets.

@luizfaias
Created February 26, 2020 13:18
Show Gist options
  • Save luizfaias/04a85b1c2cad89a3ca77cb091945ad69 to your computer and use it in GitHub Desktop.
Save luizfaias/04a85b1c2cad89a3ca77cb091945ad69 to your computer and use it in GitHub Desktop.
Zendesk Web Widget + Chat - shows the widget when a single department is online
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=YOUR_WEB_WIDGET_KEY_GOES_HERE"> </script>
<script type="text/javascript">
var department_name = 'Sales';
zE('webWidget:on', 'chat:connected', function() {
zE('webWidget', 'updateSettings', {
webWidget: {
chat: {
departments: {
enabled: [department_name],
select: department_name
}
}
}
});
var chatDepartment = zE('webWidget:get', 'chat:department', department_name);
chatDepartment.status === "online" ? zE('webWidget', 'show') : zE('webWidget', 'hide');
});
zE('webWidget:on', 'chat:departmentStatus', function(chatDepartment) {
if(chatDepartment.name == department_name) {
chatDepartment.status === "online" ? zE('webWidget', 'show') : zE('webWidget', 'hide');
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment