ConversationClient
Client for interacting with a specific conversation.
A ConversationClient is scoped to a single conversation identified by conversationId. It provides methods for sending messages, observing conversation state, managing the session lifecycle, and handling structured content interactions.
Obtain an instance from CoreClient.conversationClient:
val conversationId = UUID.randomUUID()
val conversationClient = coreClient.conversationClient(conversationId)Conversation ID Management
The conversationId must be a randomly generated UUID. Never use customer IDs, user IDs, business identifiers, or any other deterministic value as the conversation ID. Using non-random IDs causes authentication failures (HTTP 403) when the app is reinstalled or tokens expire, because the server associates the ID with the previous access token.
The recommended approach is to check for existing conversations first, and only generate a new UUID if none exist:
See also
Samples
val result = coreClient.conversations(limit = 10, forceRefresh = true)
val conversationId = if (result is Result.Success) {
result.data.firstOrNull()?.identifier ?: UUID.randomUUID()
} else {
UUID.randomUUID()
}
val conversationClient = coreClient.conversationClient(conversationId)scope.launch {
conversationClient.events.collect { event ->
when (event) {
is ConversationEvent.Entry -> { /* Display the new entry in the chat feed */ }
is ConversationEvent.ProgressIndicator -> { /* Show typing indicator */ }
is ConversationEvent.QueuePosition -> { /* Update queue position UI */ }
else -> {}
}
}
}Properties
An observable stream of the current Conversation state.
The unique identifier of the conversation this client operates on.
A stream of real-time ConversationEvents for this conversation.
Functions
Changes the modality of the conversation between Modality.Messaging and Modality.Voice.
Permanently closes the conversation.
Gets the ConversationEntrys scoped to this conversation.
Gets the ConversationEntry objects related to this conversation.
Returns a paginated stream of ConversationEntry objects for this conversation.
Gets a single ConversationEntry given its unique entry ID.
Gets a Flow of a single ConversationEntry given its unique entry ID.
Explicitly creates a conversation on the server without sending a message.
Gets the current Conversation for the ConversationClient.
Ends the current messaging session without closing the conversation.
Marks a ConversationEntry as read by the local participant.
Retrieves a transcript of the entire conversation as a downloadable stream.
Retries sending a previously failed conversation entry.
Retries sending a previously failed conversation entry with a remote configuration.
Sends a cancel action for an in-progress structured content interaction.
Sends a completed form back to the agent.
Sends a text message in this conversation.
Sends a reply to a structured content message (e.g., quick replies or displayable options).
Sends a typing indicator to notify the agent that the user is composing a message.
Sets context data to be attached to the next outbound message.
Submits a remote configuration with pre-chat fields and routing data.