addButtonEventHandler

Use the addButtonEventHandler method to define a chat button’s behavior when certain events occur. Available in API versions 28.0 and later

Usage 

Defines the behavior for a chat button when the following events occur:

  • An agent is available to chat.
  • No agents are available to chat.

The event “no agents are available to chat” occurs whenever a chat can’t reach an agent using the configured chat button. The event occurs when:

  • No agents are online.
  • No agents assigned to the skills associated with the button are online.
  • Online agents have the status Away.
  • Online agents are at capacity (set with Chat Configurations, or Presence Configurations with Omni-Channel).
  • Online agents are using Omni-Channel and are only available for other service channels.

Syntax 

void addButtonEventHandler(String buttonId, Function callback)

Parameters 

NameTypeDescriptionAvailable Versions
buttonIdStringThe ID of the chat button for which to define the behavior when certain events occur.Available in API versions 28.0 and later
callbackfunctionThe function to call when a particular event occurs. You must specify the button’s behavior for each of the required event types.Available in API versions 28.0 and later

Event Types 

Incorporate the following event types into your callback function to customize the behavior of your button when certain events occur. You must specify the button’s behavior for each of the following event types.

FunctionEvent TypeSyntaxDescription
callbackBUTTON_AVAILABLEliveagent.BUTTON_EVENT.BUTTON_AVAILABLESpecifies the behavior of the button when the criteria are met for customers to be able to chat with an agent, such as when an agent with the correct skills is available to chat.
 BUTTON_UNAVAILABLEliveagent.BUTTON_EVENT.BUTTON_UNAVAILABLESpecifies the behavior of the button when no agents are available to chat.