Bootstrap Embedded Chat
Start, End, and Clear Embedded Chat Sessions
Code Snippet Versions
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.
The legacy chat product is in maintenance-only mode, and we won’t continue to build new features. You can continue to use it, but we no longer recommend that you implement new chat channels. Instead, you can modernize your customer communication with Messaging for In-App and Web. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time.
Important
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.
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>