Home > How to get your agent status via the getAgentStatusAsync() API

Categories:


(Last Updated On: August 4, 2021)

About This Article

The purpose of this article is to provide a comprehensive overview of how to get your agent status via the getAgentStatusAsync() API.

Love coding and want to get your Agents status with an API? Well, you are in luck!

See the Javascript API Doc for .getAgentStatusAsync() here.

Here is how it works:

You can call this new API with an anonymous function as an argument. That anonymous function takes a boolean argument (online, in the example below) which will evaluate to the chat team’s online status (“offline” status may also be triggered by other settings such as being outside your defined Hours of Operation).

The check is asynchronous. After the getAgentStatusAsync() call, the rest of your code continues. When the result of .getAgentStatusAsync() is available, it will trigger the anonymous function (usually within a second).

The getAgentStatusAsync() call can be added to the advanced code after the line:
//Place your SnapEngage JS API Code below.

Note: If you have not added or update your code since 1/1/2013:
We highly recommend you update to the newer, better, faster, stronger version of the code by going to the “Get the code” tab in your Admin Dashboard and replacing your old code with the new one.

When using the old code, add the getAgentStatusAsync() after the addButton() or init() call has been done (after SnapEngage has been initialized).


Here is a simple example that will show an alert with the agent status:

// Inside the "Advanced" Code Snippet:
SnapABug.getAgentStatusAsync(function(online) {
    if (online) {
       alert('Agents are online');
    } else {
       alert('Nobody is available to chat');
    }
});

Did you find this article helpful?

Not HelpfulNeeds WorkSo-soHelpfulVery Helpful (4 votes, average: 3.00 out of 5)
Loading ... Loading ...

Published January 12, 2012