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. Can I reapply the department from my previous chat?
Answer
It’s expected that a new chat session doesn’t reapply the department after a visitor timeout. As a workaround, use the on chat:connected API callback to detect the reconnect, then call the updateSettings API to set the department for the new session.
The API runs when the reconnect occurs after a visitor timeout but before the visitor sends a new message. This ensures the new session gets the department.
However, this workflow isn’t possible when you use triggers to set the department. There’s no way to re-fire a chat trigger when the visitor reconnects.
Here’s an example API script that sets the Shopping Cart department when a visitor first connects or reconnects after a timeout.
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=ACCOUNT_KEY"></script>