Start new conversation

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

Start a new conversation

By default, starting a new conversation will navigate the user to a new conversation screen. The conversation can optionally be started with an initial message that appears either as an initial agent message or as an initial user message.

If the initial message is a user message, a conversation will also be created on the Kustomer backend.

If an initial message is not provided, or if the initial message is an agent message, a conversation will not be created until the user sends their first message.

// Navigating to a new empty conversation
Kustomer.getInstance().startNewConversation()

// Navigating to a new conversation with an initial user message and optional parameters

Kustomer.getInstance()
                    .startNewConversation(
                        title = "Refund Inquiry",
                        describeAttributes = KusDescribeAttributes(
                            hashMapOf(
                                Pair(
                                    "orderNumberStr",
                                    "33-44-55"
                                )
                            )
                        ),
                        initialMessage = KusInitialMessage(
                            "I need help with my return.",
                            KusChatMessageDirection.CUSTOMER
                        )
                    ) {
                        when (it) {
                            is KusResult.Success -> {
                                // handle success
                            }
                            is KusResult.Error -> {
                                // handle error
                            }
                        }
                    }

📘

Using a conversational assistant?

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

PropertyTypeDescription
titleStringOptional

The name of the conversation.
describeAttributesObjectOptional

An object containing the custom attributes of the conversation.
initialMessageStringOptional

This message will be passed into the conversation when it starts. It will appear either as an agent message or a user message.