createConversation

abstract suspend fun createConversation(conversationId: UUID, remoteConfiguration: RemoteConfiguration? = null, modality: Modality = Modality.Messaging): Result<Conversation>

Creates a new conversation with the messaging service.

Return

Result.Success containing the created Conversation, or Result.Error on failure.

Parameters

conversationId

A UUID representing the unique conversation identifier. Use the same ID passed to conversationClient to associate the client with this conversation.

remoteConfiguration

An optional RemoteConfiguration object for routing data. If null, the configuration is retrieved automatically via retrieveRemoteConfiguration.

modality

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

Samples

// Check for an existing conversation first, generate a new UUID only if none exist
val existing = coreClient.conversations(limit = 10, forceRefresh = true)
val conversationId = if (existing is Result.Success) {
    existing.data.firstOrNull()?.identifier ?: UUID.randomUUID()
} else {
    UUID.randomUUID()
}

val result = coreClient.createConversation(conversationId)
when (result) {
    is Result.Success -> {
        val conversation = result.data
        val client = coreClient.conversationClient(conversationId)
    }
    is Result.Error -> {
        // Handle error
    }
    else -> {}
}