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

Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online.

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>
Powered by Zendesk