# Hidden Pre-Chat for Android

Use hidden pre-chat fields to capture valuable information without asking the customer directly for it.

:::important
This feature requires version 1.2.0 or later of the Enhanced In-App Chat SDK.
:::

This article applies to the following implementations:

| UI SDK | Core SDK |
| :----: | :------: |
|    ✅   |     ✅    |

After you [set up pre-chat in Salesforce](https://help.salesforce.com/s/articleView?id=service.miaw_custom_prechat\_2.htm), the UI SDK automatically presents the pre-chat form to the user and passes this information to Salesforce. If you're not using the UI SDK, the [Core SDK documentation](/docs/service/messaging-in-app/guide/android-core-sdk.md) describes how to perform this process programmatically. To use hidden pre-chat fields, use the Core SDK. If you want to use this feature with the UI SDK, use the Core SDK with your UI SDK.

This article describes the steps that you must take from your app to send any user data *not* visible in the pre-chat form. This data is also described as hidden pre-chat fields. To learn about and set up pre-chat, see [Customize Pre-Chat for Enhanced Chat](https://help.salesforce.com/s/articleView?id=service.miaw_custom_prechat\_2.htm).

After you set up hidden pre-chat fields in Salesforce, you can populate these values using the SDK.

1. Implement the [`PreChatValuesProvider`](https://salesforce-async-messaging.github.io/messaging-in-app-android/sdk/core/com.salesforce.android.smi.core/-pre-chat-values-provider/index.html) interface. This provider contains the `setValues` method, which the SDK calls when it needs pre-chat values.
2. Add your provider to the SDK using the `CoreClient.registerHiddenPreChatValuesProvider` property. See the [`CoreClient`](https://salesforce-async-messaging.github.io/messaging-in-app-android/sdk/core/com.salesforce.android.smi.core/-core-client/index.html) reference documentation.

:::note
This sample code requires the configuration object that you created when setting up the UI SDK or the Core SDK. See [Build a UI SDK App](/docs/service/messaging-in-app/guide/android-ui-sdk.md) or [Build a Core SDK App](/docs/service/messaging-in-app/guide/android-core-sdk.md) for more information.
:::

```sfdocs-code {"lang":"kotlin", "title": "Implement hidden pre-chat provider", "src": "" }
// Create a core client from a config
val coreClient = CoreClient.Factory.create(myContext, config)

// Register a provider
coreClient.registerHiddenPreChatValuesProvider( object : PreChatValuesProvider {

  // Implement the setValues method
  override suspend fun setValues(input: List<PreChatField>): List<PreChatField> {

    // Iterate through all the pre-chat fields
    input.forEach {

      // Specify the value for each field mapping
      if (it.name == PRECHAT_FIELD_NAME) {
        it.userInput = "My hidden pre-chat value"
      }
    }

    // Return the same list, but with updated values set
    return input
  }
})
```

After you register your provider, the SDK automatically calls your `setValues` method before a conversation begins.
