utilAPI

This object contains utility-related APIs.

This method hides the chat button.

By default, the chat button is always shown if no business hours are specified. If business hours are specified, the chat button is shown during business hours and hidden outside of business hours. To learn how to configure business hours, see Set Business Hours in Enhanced Chat.

This command can override the default behavior.

You can’t hide the chat button if the chat window is already showing. Also, this method doesn’t have session continuity. For example, after a refresh, the button returns to its initial state. If business hours are specified, this call overrides the current visibility only until the next business hours interval.

None.

This method shows the chat button.

By default, the chat button is always shown if no business hours are specified. If business hours are specified, the chat button is shown during business hours and hidden outside of business hours. To learn how to configure business hours, see Set Business Hours in Enhanced Chat.

This command can override the default behavior.

This method doesn’t have session continuity. For example, after a refresh, the button returns to its initial state. Also, if business hours are specified, this call overrides the current visibility only until the next business hours interval.

None.

This API launches the web chat client with the messaging conversation window maximized. See Launch Chat.

ParameterTypeDescription
shouldStartNewConversationBooleanOptional. Available only in Enhanced Web Chat v2 deployments. If set to true and the current conversation is in the ended state, calling launchChat starts a new conversation. If the current conversation is still open, this parameter is ignored. The default value is false.

Use the event handlers of this method to perform actions after the chat client launches.

Event HandlerDescription
thenRuns actions if the web chat client launches successfully.
catchRuns actions when the web chat client launch fails.
finallyRuns actions after the chat client launches successfully or not.

This method returns a Promise object.

This method removes all Enhanced Web Chat components from a page on your website. Call the clearSession method first to completely clean up both authenticated and unauthenticated conversations.

None.

The setSessionContext method is only available through Enhanced Web Chat v2 deployments. For more information, see Enhanced Chat in Salesforce Help.

This method enables you to pass information like the current page or a recent search to the agent, as well as custom context variables defined in Agentforce Builder.

ParameterTypeDescription
contextVariablesContext[]An array of context variables. See the Context object schema.
optionsOptionsOptional. Controls how the context variables are delivered. See the Options object schema.

The top-level object defines a single context variable. Read more about creating context variable fields in agent conversations.

Field NameTypeDescription
nameStringThe name of the context variable. Use _AgentContext for the reserved page and search variable, or the Agent Builder API name of a custom context variable.
valueValueAn object containing the value and its data type. See the Value (Parent) object schema for details.

This object acts as a wrapper, defining the type and containing the payload of the context variable. The key that holds the payload depends on the valueType.

Field NameTypeDescription
valueTypeStringThe data type of the payload. Supported values: StructuredValue, TextValue, BooleanValue, IntegerValue, DoubleValue, DateValue, DateTimeValue, ListValue. See Custom Context Variable Types for the mapping to Agentforce Builder types.
valueObjectPayload for StructuredValue. A complex JSON object. See the Value (Child) object schema.
textValueStringPayload for TextValue. Also used for Currency values, in the format "<CurrencyCode> <Amount>" (for example, "USD 1499.99").
booleanValueBooleanPayload for BooleanValue.
integerValueNumberPayload for IntegerValue. Whole numbers only.
doubleValueNumberPayload for DoubleValue. Decimal numbers.
dateValueStringPayload for DateValue. YYYY-MM-DD format.
dateTimeValueStringPayload for DateTimeValue. ISO-8601 format.
listValueArray of ValuesPayload for ListValue. Each item is itself a Value (Parent) object; all items must share the same valueType.

This nested object contains the specific, structured data for the reserved _AgentContext variable. value must be an object, but there are no required fields.

Field NameTypeDescription
currentPageStringOptional. The web page URL of the page the chat user is currently viewing.
searchSearch[]Optional. An object containing details about a search the user performed. See the Search object schema.
Field NameTypeDescription
sendWithNewConversationBooleanOptional. Defaults to false. When true, the context variables are sent as part of creating a new conversation instead of being deferred to the next end-user message turn.

This object provides details about a user’s search activity. All fields are optional and can be populated if the information is available.

Field NameTypeDescription
resultStringThe specific search item the user is currently on.
filtersArray of StringsA list of product or category filters applied to the search.
facetsArray of StringsThe categories or facets the user was browsing or searching within.