Newer Version Available
Bootstrap Embedded Chat
embedded_svc.bootstrapEmbeddedService(attributes);
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.
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>