Open new conversation

Opens a new conversation, or opens a new conversation with a message.

❗️

This method has been deprecated as of Android v2.9.7. See startNewConversation.

Open a new conversation

To open a new conversation when the customer sends the first message, use an optional lambda callback function to invoke after a conversation is created successfully and the code returns the KusResult<KusConversation> object in the lambda callback.

Kustomer.getInstance()
  .openNewConversation { result: KusResult<KusConversation> ->
            when (result) {
                is KusResult.Success -> //conversation created successfully.
                else -> //conversation create error
            }
        }

You can use the lambda callback function to call other APIs such as describeConversation on the newly created conversation.

Kustomer.getInstance()
  .openNewConversation { result: KusResult<KusConversation> ->
            when (result) {
                is KusResult.Success -> {

                    //conversation created successfully

                    Kustomer.getInstance().describeConversation(
                        result.data.id, mapOf("customKeyStr" to "custom value")
                    ) {
                        when (it) {
                            is KusResult.Success -> //describe success
                            else -> //describe error
                        }
                    }
                }
                else -> //conversation create error
            }
        }

Open a new conversation with an initial message

Use an optional Message parameter to set chat to open with a series of messages at the start of the conversation.

📘

Using a conversational assistant?

Kustomer Chat ignores the Message parameter if you use a conversational assistant.

Kustomer.getInstance().openNewConversation("Hi, how can I help you?"){}

Did this page help you?