Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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