Question
When a chat session is timed out, and the visitor requests a new chat, the new chat request does not retain the department assigned from the previous session. Is there a way to reapply the department assigned from the previous chat?
Answer
It is expected behavior for a new chat session to not reapply the department automatically after a visitor timeout. As a workaround, use the on chat:connected API callback to identify the reconnection event and update the user settings with updateSettings API to set the department for the new chat session.
The API is applied when the reconnect event occurs after a visitor time out but before the new message is sent by the visitor. This ensures the department gets assigned to the new session.
Below is an example API script that uses these methods to reapply the Shopping Cart department whenever a visitor first connects or reconnects from a timed-out session.
<script id="ze-snippet"
src="https://static.zdassets.com/ekr/snippet.js?key=ACCOUNT_KEY"> </script>
<script type="text/javascript">
zE('webWidget:on', 'chat:connected', function() {
zE('webWidget', 'updateSettings', {
webWidget: {
chat: {
departments: {
select: 'Shopping Cart'
}
}
}
});
});
</script>
5 comments
CJ Johnson
How would you make this work if there's 5 departments that the customer may have selected from, prior to the reconnect?
0
Eric Ypsilantis
Hi CJ, the script in this article is specifically for setting (and setting again if needed) a single specified department.
Unfortunately there isn't an API to get the prior session's department, which would be required to know which of these 5 departments to use again upon reconnection.
0
moment long
Zendesk messaging I see doesn't have as many callbacks for us to use as the classic version does.
How do I know when the exp is about to expire and re-call the loginUser APi?
Using a timer to keep track and then calling loginUser is a bad solution
0
Jason Schaeffer
Thank you for the callout, I will be sharing this feedback with out product team. Messaging is still relatively new and there will be improvements and updates made along the way.
Thanks!
0
Jon
+1 we need department field to assign on re-connect. There is a reason for the department field applying to the initial chat so it makes sense for the reconnected chat to still have the department field assigned. It's a negative user and business experience not to have this functionality.
0