customer-android-kotlin

//core/com.kustomer.core.providers/KusChatProvider/createConversation

createConversation

[androidJvm]
abstract suspend fun createConversation(title: String? = null, messages: List<String>?, attachments: List<KusUploadAttachment>?, messageAction: KusMessageAction? = null, lastDeflectionData: KusKbLastDeflectionData? = null, attributes: Map<String, Any>? = null, initialAgentMessages: List<String>? = null, assistantId: String? = null): KusResult<Pair<KusConversation, List<KusChatMessage>>>

Creates a new conversation. Adds messages to the created conversation if passed in the parameter. Currently this API only supports adding text messages for a newly created conversation. Use KusChatProvider.sendMessageWithAttachments to send more messages and/or attachments in the conversation.

This API will create new conversation irrespective of whether there are any other ongoing open conversations or not. If you only want to show 1 active conversation at a time, then check if there are any other open conversation via KusChatProvider.fetchConversations.

Note: This is a suspend function and should be called from Kotlin Coroutines

Return

Pair of created KusConversation and List of added KusChatMessage objects. List of KusChatMessage will be empty if no message was passed in the function parameter

See also

androidJvm

   
com.kustomer.core.models.chat.KusKbLastDeflectionData  

Parameters

androidJvm

   
title Optional title for the conversation. If no title is provided, the text of the first message will be used as the title. Conversation titles are limited to 256 characters and will be truncated if they exceed that limit
messages Optional list of string messages to be added for the created conversation. The first message will be automatically set as the conversation title.
attachments Optional list of KusUploadAttachment to send as messages when the conversation is created
messageAction Optional KusMessageAction object when the first message was KusMessageTemplateType.QUICK_REPLY
lastDeflectionData contains the KusKbLastDeflectionData which is referred when sending back details about the kb deflect articles sent via chat assistant
attributes Key Value pairs that can be optionally included to describe the newly created conversation
initialAgentMessages A list of messages that appear to the end user as if they were sent at the beginning of a conversation by an agent or bot. Ignored if a Chat Assistant is set.
assistantId Optional assistant id to create the conversation in assistant mode. If not provided, simply uses the active assistant in KusChatSetting.assistantId