data

Domain models and data types for the Messaging for In-App SDK. This module defines the type hierarchy for conversations, entries, messages, participants, pre-chat fields, and errors. These types appear throughout the core and ui module APIs as return values and callback parameters.

Conversation

Conversation represents an ongoing or completed messaging session between an end user and one or more agents or bots.

Key properties:

  • identifier -- unique conversation ID

  • status -- derived ConversationStatus: Open, Closed, or Unknown

  • participants / activeParticipants -- all or currently active Participant list

  • activeModalities -- communication channels in use (messaging, voice, video)

  • lastActivity -- the most recent ConversationEntry

  • unreadMessageCount -- messages not yet read by the local participant

Conversation Entries

ConversationEntry is a single item in the conversation timeline -- a message, typing indicator, routing event, or participant change. Each entry has a sender, a delivery status, and a typed payload.

ConversationEntry
+-- sender: Participant
+-- status: ConversationEntryStatus
+-- payload: EntryPayload (sealed interface)

ConversationEntryStatus tracks delivery progress: Sending ->Sent ->Delivered ->Read, or Error on failure.

EntryPayload is a sealed interface with subtypes for each event kind:

  • MessagePayload -- a participant message (see Messages below)

  • TypingIndicatorPayload / TypingStartedIndicatorPayload / TypingStoppedIndicatorPayload

  • ParticipantChangedPayload -- join/leave/role-change events

  • RoutingResultPayload -- agent assignment or routing failure

  • QueuePositionPayload -- end user position in agent queue

  • CloseConversationPayload -- conversation ended

  • SessionStatusChangedPayload -- session lifecycle transitions

  • ModalityConnectionPayload -- voice/video connection state changes

  • StreamingTokenPayload -- incremental tokens from a streamed response

  • UnknownEntryPayload -- fallback for unrecognized entry types

when (val payload = entry.payload) {
is EntryPayload.MessagePayload -> renderMessage(payload)
is EntryPayload.ParticipantChangedPayload -> showJoinLeave(payload.entries)
is EntryPayload.RoutingResultPayload -> showRoutingStatus(payload)
else -> { /* handle or ignore */ }
}

Messages

EntryPayload.MessagePayload implements the Message interface. A message's structure is determined by its messageType enum and its content: MessageFormat.

Message
+-- messageType: ConversationEntryMessageType
+-- content: MessageFormat (sealed interface)

MessageFormat subtypes:

FormatDescription
StaticContentFormat.TextFormatPlain or markdown text
StaticContentFormat.AttachmentsFormatFile attachments with optional text
StaticContentFormat.RichLinkFormatLink preview with image
StaticContentFormat.WebViewFormatEmbedded web view (surveys)
ChoicesFormat.QuickRepliesFormatPill-shaped reply suggestions
ChoicesFormat.DisplayableOptionsFormatStacked buttons
ChoicesFormat.CarouselFormatScrollable rich cards
FormFormat.InputsFormatStructured input form with titled sections
FormFormat.ExperienceTypeFormatExperience-type form with inputs and optional confirmation
when (val format = message.content) {
is StaticContentFormat.TextFormat -> showText(format.text)
is StaticContentFormat.AttachmentsFormat -> showAttachments(format.attachments)
is ChoicesFormat.QuickRepliesFormat -> showQuickReplies(format.optionItems)
is ChoicesFormat.CarouselFormat -> showCarousel(format.items)
else -> showFallback()
}

Participants

Participant identifies a conversation member. The roleType property indicates their role:

ParticipantRoleTypeDescription
EndUserThe customer on the device
AgentA human support agent
ChatbotAn automated bot
SystemSystem-generated events
SupervisorA monitoring supervisor
RouterThe routing engine

Use participant.isLocal to distinguish the current device user from remote participants.

val agentName = conversation.activeParticipants
.firstOrNull { it.roleType == ParticipantRoleType.Agent }
?.displayName

Pre-Chat Fields

PreChatField defines a form field the end user completes before starting a conversation. Access the list from conversation.preChatFields.

To populate fields for submission, set userInput on each field and call validate():

preChatFields?.forEach { field ->
field.userInput = collectedValues[field.name] ?: ""
val error = field.validate()
if (error != PreChatErrorType.None) showError(field, error)
}

Key properties: name, type, required, maxLength, isHidden, isEditable, labels.

Error Handling

NetworkError is a sealed class hierarchy representing errors on failed conversation entries. Access via conversationEntry.error when status == ConversationEntryStatus.Error.

SubclassHTTP CodeMeaningConsumer Action
PreconditionFailedError412The server rejected the request because a precondition was not met, typically an unsupported media type.Display an error indicating the file type is not supported and allow the user to retry with a different file.
UnsupportedFileTypeError415The attached file type is not accepted by the server.Show the list of supported file types from the deployment's attachment configuration and prompt the user to choose a compatible file.
FileSizeLimitError413The attached file exceeds the server's maximum size limit. Use fileSizeLimit to get the maximum allowed size in MB.Display the maximum file size to the user (e.g., "File exceeds 5 MB limit") and ask them to attach a smaller file.
ExpectationFailedError417Additional information is required to complete the request.Prompt the user to provide the missing information before retrying.
GeneralError--An unrecognized or default error that does not match a specific category.Display a generic delivery failure message and offer a retry option.
when (val error = entry.error) {
is NetworkError.FileSizeLimitError -> showSizeLimit(error.fileSizeLimit)
is NetworkError.UnsupportedFileTypeError -> showFileTypeError()
is NetworkError -> showGenericError(error.message)
null -> { /* no error */ }
}

Packages