How to Hide and Show Salesforce Embedded Service Chat?

How to Hide and Show Salesforce Embedded Service Chat?

embedded_svc.settings.displayHelpButton should be set to true to display the Salesforce Embedded Service Chat.

embedded_svc.settings.displayHelpButton should be set to false to hide the Salesforce Embedded Service Chat.

In the following sample code, if checkBool value in the URL Parameter is passed as yes, then it will display the Chat. Else, it won’t display the Chat.

Sample Code:

const URLSearch = window.location.search;

console.log( ‘URLSearch is’, URLSearch );

const allURLParams = new URLSearchParams( URLSearch );

const checkBool = allURLParams.get( ‘checkBool’ );

console.log( ‘checkBool is’, checkBool );

if ( checkBool == ‘yes’ ) {

  console.log( ‘Showing the Chat’ );

  embedded_svc.settings.displayHelpButton = true;

} else {

  console.log( ‘Hiding the Chat’ );

  embedded_svc.settings.displayHelpButton = false;

}

Output:

Hiding the Chat:

Displaying the Chat:

Leave a Reply