Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Start, End, and Clear Embedded Chat Sessions
embedded_svc.liveAgentAPI.startChat(attributes);
1embedded_svc.liveAgentAPI.startChat({
2 directToAgentRouting: {
3 buttonId: “573xx0000000000”,
4 // userId: “”,
5 fallback: true
6},
7extraPrechatInfo: [],
8extraPrechatFormDetails: []
9});To start a chat, the attributes object contains any of these Embedded Service parameters from the table.
| Name | Type | Description |
|---|---|---|
| directToAgentRouting | object |
Direct agent routing supported only in Start Chat.
|
| prepopulatedPrechatFields | object | See: Set Certain Pre-Chat Form Fields to Automatically
Populate |
| extraPrechatInfo | array | See: Pass Nonstandard Pre-Chat Details |
| extraPrechatFormDetails | array | See: Pass Nonstandard Pre-Chat Details |
| fallbackRouting | array | See: Set Routing Order |
| directToButtonRouting | function | See: Route Chats Based on Pre-Chat Responses |
- Start Chat maximizes the widget if it’s minimized. Calling the API when the end user is in an active chat request or session doesn’t initiate another chat request.
- Start Chat attributes are not supported for Offline Support and don’t pre-populate offline support forms or submit cases.
- To avoid opening the widget in No Agents Available dialog or Offline Support states, use the OnSettingsCallCompleted event to ensure that agents are available first.
embedded_svc.liveAgentAPI.endChat();
The End Chat API ends the current chat (if active) and close the chat widget. It ends active chat requests or ongoing chat sessions (as ended by the visitor) and clears embedded service data related to the ongoing chat session. No parameters are required.
embedded_svc.liveAgentAPI.clearSession();
The Clear Sessions API ends any chat connections (if active), close the chat widget, and delete session data pertaining to all client-side chat sessions. No parameters are required.