Populate Pre-Chat Form Fields for Android

When customers start a messaging conversation, you sometimes already know basic information such as their name, email address, and what product they're looking at. You can set up a pre-chat form in the UI with visible fields such as name, email address, and product name. Then use the SDK to populate the pre-chat fields with this information so it appears when the user first opens the pre-chat form.

This feature requires version 1.5.0 or later of the Messaging for In-App SDK.

This article applies to the following implementations:

UI SDKCore SDK

Before you use the SDK, add the visible fields to the pre-chat form. See Customize Pre-Chat for Messaging for In-App and Web in Salesforce Help.

After you add the visible fields to the pre-chat form, you can populate these values by using uiClient.

  1. To populate known values in the pre-chat fields, implement preChatFieldValueProvider.

  2. Add your provider to the SDK by using the uiClient.preChatFieldValueProvider property.

    See the UIClient reference documentation.

  3. To make the pre-chat fields editable, set isEditable to true, or to make them non-editable, set it to false.

If the pre-populated fields are set as non-editable, make sure that the pre-chat form fields follow the validation rules. If a required field exceeds the character limit or is set to an invalid data type, the createConversation flow stops and the form isn't submitted. In such cases, the SDK logs error messages in the developer console.