Newer Version Available

This content describes an older version of this product. View Latest

Set Certain Pre-Chat Form Fields to Automatically Populate when Customers are Logged In

When your customers are logged in, you already know basic information like their name and email address. Use this array in your 4.0 code snippet to populate relevant pre-chat fields for them. You can mix and match fields for different record types. This information is for snap-ins that are placed outside of Salesforce with Lightning Out (beta). If you use your snap-in inside Communities, you can enable the contact fields to fill in automatically in the Snap-ins Chat component settings.

The parameter you can use to set the fields that you want to pre-populate is included with your version 4.0 code snippet as a code comment.

embedded_svc.settings.prepopulatedPrechatFields = {...}

If you use snap-ins outside of Salesforce (with Lightning Out), you can set any pre-chat field to populate automatically using the fields’ API names. Find the field API names on the object pages for the objects you use with pre-chat. Then you can set the value of embedded_svc.settings.prepopulatedPrechatFields with a JavaScript object that contains the customer’s information.

The following sample code for embedded_svc.settings.prepopulatedPrechatFields populates the First Name, Last Name, Email, and Subject fields in the pre-chat form.
1embedded_svc.settings.prepopulatedPrechatFields = {
2    FirstName:John”,
3    LastName:Doe”,
4    Email:john.doe@salesforce.com”,
5    Subject:Hello
6};