I would like to end a chat if the user has been inactive for x seconds/minutes in order to free up our agents from having to wait for the chat to close on its own. I would also like to attach a tag to the chat before ending it so I can see that it was due to inactivity.
Credits to johnnyRose for this one, which you can find here https://stackoverflow.com/a/34516735/11499604 and to vijay for inspiring him!
The majority of this is his code with the zopim javascript inserted. This was the only code that I was able to get to play nice with zopim's javascript API. I saw a lot of people looking for triggers to end chat so I hope this helps others.
The trigger for this code is a user's inactivity. After 10 seconds of being idle on the page, it adds a tag to the user and ends the chat.
You can use this Zopim Javascript page for reference on other things you can do. https://api.zopim.com/files/meshim/widget/controllers/LiveChatAPI-js.html