Show Pre-Chat Fields to User
Before a chat session begins, you can request that the user enter pre-chat fields that are sent to the agent at the start of the session.
The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service interruptions to your customers, migrate to Messaging for In-App and Web before that date. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
To create pre-chat fields in your app, instantiate ChatUserData objects during session configuration and then pass the pre-chat info to your ChatConfiguration builder.
-
Create a -derived object for each pre-chat field. Use the subclass
PreChatTextInputFieldfor string fields, the subclassPreChatPickListFieldfor picklists, and you can directly useChatUserDatafor fields that don’t require any user input at all. For fields that require user interaction, specify the display label and the label that the agent sees. You can also specify other characteristics, such as whether the field is required and what type of text field it is. When building the input field object, the first string is what the user sees on the device and the second string is what the agent sees in the transcript.In Java:
In Kotlin:
-
(Optional) Create a list of
ChatEntityobjects to associate pre-chat fields with fields from a record in your org.Pre-chat fields are always sent to the agent at the start of the session. But if you want to fill in fields of a particular record, instantiate a
ChatEntityfor each Salesforce object (for example,CaseorContact) and add aChatEntityFieldfor each field association within that Salesforce object (for example,SubjectorLastName). After you’ve built yourChatEntityobjects, pass them to yourChatConfigurationbuilder using thechatEntitiesmethod.To learn more, see Create or Update Salesforce Records from a Chat Session.
-
Pass the pre-chat info to your
ChatConfigurationbuilder using thechatUserDatamethod.In Java:
In Kotlin:
From here, you can start the chat session normally.
In Java:
In Kotlin:
With this code, the user sees the following pre-chat UI in their mobile app.

And the agent sees the following UI from the console.
