In some implementations, there is a requirement for the Salesforce Embedded Service Chat component to show only when a service agent is online and to hide automatically when all agents are offline. However, Salesforce Embedded Service Chat is not designed with a built-in API to check agent availability in real time for the purpose of showing or hiding the chat widget. This article explains the current limitation and describes possible alternative approaches using JavaScript.
There is currently no supported API in Salesforce Embedded Service Chat that checks whether a service agent is online or offline in real time. This is a key difference from the legacy Salesforce Live Agent (Classic Chat) implementation.
In the legacy Salesforce Live Agent (Classic Chat) implementation, you can wrap online and offline button elements in a div HTML element and pass the div ID to the showWhenOnline JavaScript method. This method controls the visibility of the div based on the real-time availability of agents. However, no equivalent method exists in the Salesforce Embedded Service Chat API for detecting agent status programmatically.
One possible approach is to use the embedded_svc.settings.displayHelpButton setting to control the visibility of the Embedded Service Chat button. When this setting is true, the chat button is displayed. When it is false, the button is hidden. A custom JavaScript implementation could theoretically toggle this value based on external logic, but there is no native Salesforce API to provide real-time agent availability data to drive this logic.
For additional styling and behavioral customization of the Embedded Service Chat button, refer to the Customizable Parameters documentation linked in Additional Resources below.
embedded_svc.settings.displayHelpButton = true; //Or false
The workarounds described in this article are possible approaches only and require additional review, custom development, and testing before they can be considered functional implementations. Salesforce Support is not able to provide or support a fully working custom solution based on these suggestions. These are directions for exploration, not supported configurations.
000383348

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.