Check Agent Availability

Before starting a session, you can check the availability of your chat agents and then provide your users with more accurate expectations. For instance, when no agents are available, you can hide or disable the button to contact an agent

The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service interruptions to your customers, migrate to Messaging for In-App and Web before that date. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.

Important

To check whether agents are available, create an AgentAvailabilityClient object and asynchronously check the AvailabilityState status.

In Java:

1// Build a configuration object
2ChatConfiguration chatConfiguration = 
3  new ChatConfiguration.Builder(ORG_ID, BUTTON_ID, 
4                                DEPLOYMENT_ID, LIVE_AGENT_POD)
5  .build();
6
7// Create an agent availability client
8Boolean requestEstimatedWaitTime = false; // Don’t request if we don’t plan to use it
9AgentAvailabilityClient client = ChatCore.configureAgentAvailability(chatConfiguration, requestEstimatedWaitTime);
10
11// Check agent availability
12client.check().onResult(new Async.ResultHandler<AvailabilityState>() {
13  @Override
14  public void handleResult (Async<?> async, @NonNull AvailabilityState state) {
15
16    switch (state.getStatus()) {
17      case AgentsAvailable: {
18        // TO DO: Handle the case where agents are available
19
20        // Optionally, use the estimatedWaitTime to
21        // show an estimated wait time until an agent
22        // is available. This value is only valid
23        // if you request it from the
24        // configureAgentAvailability call above.
25        // Estimate is returned in seconds.
26        Integer ewt = state.getEstimatedWaitTime();
27
28        break;
29      }
30      case NoAgentsAvailable: {
31        // TO DO: Handle the case where no agents are available
32        break;
33      }
34      case Unknown: {
35        break;
36      }
37    }
38});

In Kotlin:

1// Build a configuration object
2val chatConfiguration = ChatConfiguration.Builder(ORG_ID, BUTTON_ID,
3     DEPLOYMENT_ID, LIVE_AGENT_POD).build()
4
5// Create an agent availability client
6val requestEstimatedWaitTime = false // Don’t request if we don’t plan to use it
7val client = ChatCore.configureAgentAvailability(chatConfiguration, requestEstimatedWaitTime)
8
9// Check agent availability
10client.check().onResult(object: Async.ResultHandler<AvailabilityState> {
11  override fun handleResult(operation: Async<*>?, result: AvailabilityState) {
12    when (result.getStatus()) {
13      AvailabilityState.Status.AgentsAvailable -> {
14        // TO DO: Handle the case where agents are available
15
16        // Optionally, use the estimatedWaitTime to
17        // show an estimated wait time until an agent
18        // is available. This value is only valid
19        // if you request it from the
20        // configureAgentAvailability call above.
21        // Estimate is returned in seconds.
22        val ewt = result.getEstimatedWaitTime()
23      }
24      AvailabilityState.Status.NoAgentsAvailable -> {
25        // TO DO: Handle the case where no agents are available
26      }
27    }
28  }
29})

To understand the algorithm used for the estimated wait time, see the estimated wait time documentation in the Chat REST API Developer Guide.

You can also use this API to get an updated Chat server before starting a session to determine whether a server has changed for your pod. Call the getLiveAgentPod method from the AvailabilityState object you get back from the AgentAvailabilityClient. If the server has changed, update this configuration value in the future to prevent an unnecessary round-trip request.