Created
February 26, 2020 13:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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