Newer Version Available

This content describes an older version of this product. View Latest

Bootstrap Embedded Chat

This API provides developers with a quick Chat setup that skips the static help button stage, loading all the necessary dependencies, bootstraps, and opens the chat application on your website with one call. You can then quickly add a custom chat button, for example, by replacing the default button with more code changes.

embedded_svc.bootstrapEmbeddedService(attributes);

Use the Embedded Service code snippet version 5.0 and later. The API can only be used on a page that includes the snippet. This API isn’t available for Experience sites with Lightning Locker enabled.

Note

This function loads scripts and dependencies and creates the Embedded Chat application. It returns a Promise object that resolves after the Embedded Chat application is created. The Promise rejects on any error thrown during the bootstrapping.

Use the optional attributes JSON object parameter to pass information to the Embedded Chat Bootstrap API to launch the chat window.

Your attributes parameter should include the attributes from the table.

Name Type Description
baseCoreURL string The URL of an organization’s instance.
communityEndpointURL string The URL representing a community endpoint.

The attributes parameter is optional. If you don’t provide this parameter, the function uses what is stored in embedded_svc.settings.

The result of using this API is the same for a customer clicking the standard "Chat With an Expert" button. If you have pre-chat enabled, it surfaces the pre-chat form. If you’ve disabled pre-chat, it sends a chat request and surface the waiting state.

See Start, End, and Clear Embedded Chat Sessions for an API related to this topic.

Note

Add a Custom Chat Button

Here’s an example of how to apply this API. Hide the default Salesforce chat button and replace it with a button that matches your company’s brand.

To hide the standard button, include this line in your embedded code snippet: embedded_svc.settings.displayHelpButton = false;.

On click of your company’s branded button, invoke embedded_svc.bootstrapEmbeddedService(); to surface the chat experience for your end user.

To show a basic button that invokes the bootstrapEmbeddedService() function:

1<script type='text/javascript'>
2	function bootstrapChat() {
3		embedded_svc.bootstrapEmbeddedService();
4	}
5</script>
6<button onclick="bootstrapChat()">
7	Click me to show the Embedded Chat experience.
8</button>