(Last Updated On: June 30, 2014)

Check whether or not you have agents online and your live chat is available.

*Note: .getAgentStatusAsync() is cached for 2 minutes, calling it more often than every 2 minutes will have no effect. This caching occurs regardless of whether you have changed active widget Ids.


function (online)
Anonymous Function | (Required)
This callback function takes the required parameter online which is a Boolean.Inside the function, you can check the value of online which will evaluate to:
true : if agents are online and chat is available
false : if no agents are online and/or chat is not available.

Other reasons for chat being unavailable include: your configured “Hours of Operation,” and all agents being set to the “Paused” status.

Example Usage

Please note you must use the following snippets inside the Advanced Code Snippet.

Hide a button if chat is unavailable
SnapEngage.getAgentStatusAsync(function (online) {
	if (!online) {
		document.getElementById('myButtonId').style.display = "none";
		// Or, with jQuery:
		// $('#myButtonId').hide();

Check agent status every three minutes

As you may have guessed, you can call .getAgentStatusAsync() asynchronously.

var tid = setTimeout(checkChatStatus,3*60*1000); // Three minutes.

function checkChatStatus() {
	SnapEngage.getAgentStatusAsync(function (online) {
		if (online) {
		} else {
	// Recursive call.
	tid = setTimeout(checkChatStatus, 3*60*1000); // Set another three minute time out.

Link to another page when all agents are offline
        SnapEngage.getAgentStatusAsync(function(online) {
          var btn = document.getElementById('myButtonId');
          if (btn) {
            if (online) {
              btn.onclick = SnapEngage.startLink;
            } else {
              btn.onclick = function() {
                window.location = "http://snapengage.com/";