Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Please post any issues you have in the comments section or try searching for a solution online.
My customers can still chat with us after all agents have gone offline. Why is this happening?
In Zendesk Chat, once a chat has begun, an agent does not have the ability to end the chat on behalf of the customer. The connection is still open until the end user ends the chat (for other reasons that a chat session could end, see When do chats time out?).
If a customer starts a chat, and then the conversation completes, and the agent ends the chat in the user interface, the customer could still have the chat dialogue open and begin a chat conversation that will not be answered. This can cause confusion, because there are no agents to take a chat, but the customer can still begin a new chat that will live in limbo.
It is possible to write a custom script that ends a chat as soon as an account goes offline.
Important: This workaround is intended to be used by Chat Phase 4 customers and Support customers who have the integrated Web Widget experience. If you have troubles determining your Zendesk Chat account version, see About Zendesk Chat account types.
<!--Callback to end chat when account goes offline -->
For more information, consult the Web Widget API documentation.