Set Pre-Chat Form Fields to Automatically Populate when Customers Log In

When your customers log in, agents 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 embedded chat windows that are placed outside of Salesforce with Lightning Out (beta). If you use your embedded window in Experience sites, you can enable the contact fields to fill in automatically in the Embedded Chat component settings.

The legacy chat product is in maintenance-only mode, and we won't continue to build new features. You can continue to use it, but we no longer recommend that you implement new chat channels. Instead, you can modernize your customer communication with Messaging for In-App and Web. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time.

Important

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 Embedded Chat 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.
embedded_svc.settings.prepopulatedPrechatFields = {
    FirstName: “John”,
    LastName: “Doe”,
    Email: “john.doe@salesforce.com”,
    Subject: “Hello”
};