submitRemoteConfiguration

abstract suspend fun submitRemoteConfiguration(remoteConfiguration: RemoteConfiguration, createConversationOnSubmit: Boolean = true, modality: Modality = Modality.Messaging): Result<Conversation>

Submits a remote configuration with pre-chat fields and routing data.

This method must be called before sendMessage when the Salesforce deployment has Pre-Chat configured with "Every Session" display frequency. Failing to do so results in an HTTP 417 error when attempting to send the first message.

When createConversationOnSubmit is true (default), this method creates the conversation immediately. When false, the configuration is stored locally and submitted automatically when the first message is sent via sendMessage.

Return

Result.Success with the Conversation, or Result.Empty if createConversationOnSubmit is false.

Parameters

remoteConfiguration

The RemoteConfiguration object containing routing data and pre-chat fields.

createConversationOnSubmit

When true, creates the conversation immediately. When false, stores the data and sends it with the first user message. Default is true.

modality

The Modality for the conversation. Defaults to Modality.Messaging.

See also

Samples

// Fetch the remote configuration to get pre-chat fields
val configResult = coreClient.retrieveRemoteConfiguration()
if (configResult !is Result.Success) return

val remoteConfiguration = configResult.data

// Modify hidden pre-chat field values for routing
remoteConfiguration.forms.forEach { form ->
    form.hiddenFormFields.forEach { field ->
        when (field.name) {
            "CustomerId" -> field.userInput = "customer-123"
            "Priority" -> field.userInput = "high"
        }
    }
}

// Submit the configuration to create the conversation
val result = conversationClient.submitRemoteConfiguration(remoteConfiguration)
when (result) {
    is Result.Success -> {
        // Conversation created, ready to send messages
        conversationClient.sendMessage("Hello!")
    }
    is Result.Error -> { /* Show error — pre-chat submission failed */ }
    Result.Empty -> { /* createConversationOnSubmit was false */ }
    Result.Loading -> { /* should not occur */ }
}