prechatAPI
This object contains all the APIs associated with pre-chat.
If your Enhanced Web Chat deployment is on an Experience Cloud site, follow the instructions on how to add JavaScript code to the head markup section of your site. See Configure an Enhanced Web Chat Deployment in an Experience Builder Site.
Sends hidden pre-chat fields to Salesforce. To learn about and set up hidden pre-chat, see Customize Pre-Chat for Enhanced Chat in Salesforce Help. This method must be called after the onEmbeddedMessagingReady
event is dispatched and before the conversation begins. See Hidden Pre-Chat.
{fields}
: Required. A JSON object containing a list of key-value pairs of the hidden pre-chat field names and their values.
Removes hidden pre-chat fields from Salesforce. This method must be called after the onEmbeddedMessagingReady
event is dispatched and before the conversation begins. See Hidden Pre-Chat.
{fields}
: Required. An array of strings. Each string is a pre-chat field. When this method is called, the hidden pre-chat field is removed from the conversation.
Populates visible pre-chat fields with data in the pre-chat form. The pre-chat field must already be in the pre-chat form. See Customize Pre-Chat for Enhanced Chat in Salesforce Help. Call this method after the onEmbeddedMessagingReady
event is dispatched and before the conversation begins. See Populate Pre-Chat Form Fields.
{fields}
: Required. A JSON object containing nested {field}
objects. The key of each nested object is the channel variable name of a custom or standard pre-chat field.
From Setup, in the Quick Find box, enter Messaging Settings
, and then select Messaging Settings. Click the name of your messaging channel. The channel variable names are listed in the Parameter Mappings section.
Standard pre-chat fields start with an underscore. They are _firstName
, _lastName
, _email
, and _subject
.
For more information on editing pre-chat fields, see Customize Pre-Chat for Enhanced Chat in Salesforce Help.
Parameter | Type | Description | Required or Optional |
---|---|---|---|
value | String | Required. The value to populate the field with. | |
isEditableByEndUser | Boolean | Indicates whether a user can edit this pre-chat field (true ) or not (false ). The default value is true . | Optional |
Pass each pre-chat field with its value and whether it's editable in the pre-chat form.
Removes the values from visible pre-chat fields that you populated by using setVisiblePrechatFields
. Call this method after the onEmbeddedMessagingReady
event is dispatched and before the conversation begins. See Populate Pre-Chat Form Fields in Salesforce Help.
{fields}
: Required. An array of strings. Each string is a pre-chat field name. When this method is called, the value of each pre-chat field is removed. Use the channel variable name of your custom or standard pre-chat fields for the pre-chat field names.
From Setup, in the Quick Find box, enter Messaging Settings
, and then select Messaging Settings. Click the name of your messaging channel. The channel variable names are listed in the Parameter Mappings section.
Standard pre-chat fields start with an underscore. They are _firstName
, _lastName
, _email
, and _subject
.
For more information on editing pre-chat fields, see Customize Pre-Chat for Enhanced Chat in Salesforce Help.