Credit for this solution goes to Ramin Shokrizadeh.
The use case
My use case involves sites in different countries, but the solution could work equally well if you need to control online/offline status between brands or some other setup.
I wanted to make sure that I could show chat as offline for sites in one country, when that country had a holiday, without having to shut down chat for all other countries that were not on holiday.
The solution
So, the solution for me was to have departments based on countries, and all the chat agents who can service this country (and only this country) be members of this Department.
The example script below is for our swedish sites, the Department is named SWEDEN, it should be appended to the Zendesk Web Widget embed code.
Make sure that the name is spelled exactly the same in script and on the Department form! On the Departments overview all names appear CAPITALIZED, but that may not be the case when edited.
<script>
zE(function(){
$zopim(function() {
$zopim.livechat.departments.setVisitorDepartment('SWEDEN');
$zopim.livechat.departments.filter('');
$zopim.livechat.setOnStatus(function(e) {
if (e === 'offline') return;
var dep = $zopim.livechat.departments.getDepartment('SWEDEN');
if(dep.status=="offline"){
$zopim.livechat.setStatus('offline');
}
});
});
});
</script>
Other scripts should be made for each country and Department you service using Zopim chat.
So the way this works is (with the above in place)
When they are having a holiday in Sweden and the swedish support staff are having a day off (everyone in the Department SWEDEN are offline), sites in Sweden will show chat as offline.
And sites in countries where Department agents are online will still show chat as online.