Show Chat in the Web Widget (Classic) only when a specific department is online
Yes. By default, the widget doesn't appear only when specific departments are online, but you can add a custom script with the Zendesk API. With a custom script, you configure the Web Widget (Classic) to show Chat only when a specific department is online. The script detects a change in the department status of the account and the API updates the Web Widget (Classic) settings based on the current status.
The example below applies this method. It shows the Web Widget as online for Chat only when the CRM department is online. If the CRM department isn't online, the script suppresses Chat. When the script suppresses Chat, the Web Widget (Classic) shows only other features that you turned on for the visitor, such as the contact form or help center search.
<script id="ze-snippet"
src="https://static.zdassets.com/ekr/snippet.js?key=ACCOUNT_KEY"> </script>
<script>
zE('webWidget:on', 'chat:departmentStatus', function(dept) {
if (dept.name === 'CRM' && dept.status === 'online') {
zE('webWidget', 'updateSettings', {
webWidget: {
chat: {
departments: {
enabled: [''],
select: 'CRM'
},
suppress: false
}
}
});
} else if (dept.name === 'CRM' && dept.status !== 'online') {
zE('webWidget', 'updateSettings', {
webWidget: {
chat: {
suppress: true
}
}
});
}
});
</script>