---
schema_version: "1"
id: cfa5eb5a1ca190632829ec62c83026eaf03c7a4be3ff1ba9536f647dbf1bac96
title: Populate Pre-Chat Form Fields for Android
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-in-app/guides/android-populate-pre-chat.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-in-app/guide/android-populate-pre-chat.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c62689d7ff3be85dec832a3e82196d04aa347a43791a1aa98dffdaa81a60ae04
products:
  - Enhanced In-App Chat
  - Service Cloud Developer Content
---
# 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.


**important:** This feature requires version 1.5.0 or later of the Enhanced In-App Chat SDK.


This article applies to the following implementations:

| UI SDK | Core SDK |
| :----: | :------: |
|   ✅   |          |


Before you use the SDK, add the visible fields to the pre-chat form. See [Customize Pre-Chat for Enhanced Chat](https://help.salesforce.com/s/articleView?id=service.miaw_custom_prechat_2.htm) 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`](https://salesforce-async-messaging.github.io/messaging-in-app-android/sdk/ui/com.salesforce.android.smi.ui/-u-i-client/index.html?query=interface%20UIClient) reference documentation.
  
3. To make the pre-chat fields editable, set `isEditable` to `true`, or to make them non-editable, set it to `false`.

**note:** 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.

```
UIClient.kt
/**
 * A provider to populate known values in the pre-chat fields.
 * It requires a user-defined lambda expression to modify the list of [PreChatField]s, before they're rendered in the pre-chat form.
 */
var preChatFieldValueProvider: ((List<PreChatField>) -> List<PreChatField>)?
```

```
MessagingProvider.kt

    uiClient.preChatFieldValueProvider = { list ->
        list.onEach { field ->
            settings.prePopulatedPreChatParamsMap.entries.find { it.key == field.name }?.let {
                field.userInput = it.value
                field.isEditable = settings.prePopulatedPreChatEditable
            }
        }
        list
    }
```
