Preventing multiple LiveAgent chat windows from being opened

I’ve been looking through the Live Agent Developer’s Guide without much success in trying to determine if there is a way to determine if a visitor is currently engaged in a Live Agent chat, and if so preventing them from engaging in another chat simultaneously (and tying up more than 1 agent). Is there any standard or custom functionality that would drive this?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

There is no way to do this from the Live Agent configuration. The following is not a practical solution but it could be an option if this was a MUST HAVE type of requirement.

I would create a custom object that would be created as soon as the chat is accepted, that custom object would represent a chat session and would have a status such as “Started” and “Completed”, and would reference the Visitorid (unique to each visitor), the status would be set to completed as soon as the chat ends. This would allow you to query for this object for the current visitor and prevent the pre-chat form submission if the visitor has a chat session with status of “started”, which would mean the visitor is currently engaged in a chat. However, there are many factors to consider if you decide to implement something like this, such as lags in the API and what happens during temporary disconnections that could potentially cause issues.

I could not find anything in the developer guide that would make me think that there is a proper method that would allow us to query for current session for a particular visitor.

Method 2

I was able to solve this using JavaScript by detecting if there is still a live agent window open, and calling the .focus() method on that open window.

The problem with Deployment API is that when liveagent.startChat() is called to create a new window, it does not assign the returned value of, so it does not keep track of which windows have been created and whether any of the windows are still open. (Check function ‘xa’ in the deployment.js source code).

However, you can hack this by overriding the default function. In the global scope, create an object to store all created windows:

var openedLiveChatWindows = {};

Create a wrapper function for liveagent.startChat() that goes through all created windows in openedLiveChatWindows and checks if there is one that is still open. If there is an open window, focus on that window instead instead of creating a new one:

function initChat(){
    var defaultWindow =;

    for (lcw in openedLiveChatWindows) {

    liveagent.startChat(...); = defaultWindow;

Lastly, create a function that returns the default, but also adds each newly created window to the openedLiveChatWindows object:

function overrideWindowSettings(defaultWindow){ = function (url,windowName,windowFeatures) {
        openedLiveChatWindows[windowName] = (defaultWindow(url,windowName,windowFeatures));
        return defaultWindow(url,windowName,windowFeatures); 

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x