Chat Classes

All classes are current as of version 4.7.0.

Message hierarchy

A message is described by two intersecting hierarchies: by content type (UsedeskMessage) and by sender (UsedeskMessageOwner). A concrete message class implements one interface from each.

sealed interface UsedeskMessage {
    val id: String
    val createdAt: Calendar

    sealed interface Text : UsedeskMessage {
        val text: String
        val convertedText: String
    }

    sealed interface File : UsedeskMessage {
        val file: UsedeskFile
    }
}

sealed interface UsedeskMessageOwner {
    sealed interface Agent : UsedeskMessageOwner {
        val name: String
        val avatar: String
    }

    sealed interface Client : UsedeskMessageOwner {
        val status: Status
        val localId: String

        enum class Status {
            SENDING,
            SUCCESSFULLY_SENT,
            SEND_FAILED
        }
    }
}


Chat configuration class — UsedeskChatConfiguration : Parcelable
Name Type Description
urlChat String Chat server address
urlChatApi String Chat API address
companyId String Company identifier
channelId String Channel identifier
messagesPageSize Int Number of messages in a single loading page
clientId String Client identifier
clientToken String? Client token
clientEmail String? Client email
clientName String? Client name
clientNote String? Note about the client
clientPhoneNumber Long? Client phone number
clientAdditionalId String? Additional client identifier
clientInitMessage String? First message sent on chat initialization
clientAvatar String? Client avatar
cacheMessagesWithFile Boolean Whether to cache unsent messages with files
additionalFields Map<Long, String> Additional fields
additionalNestedFields List<Map<Long, String>> Additional nested fields


Agent text message class — UsedeskMessageAgentText : UsedeskMessage.Text, UsedeskMessageOwner.Agent
Name Type Description
id String Message identifier
createdAt Calendar Creation time
text String Original message text
convertedText String Text prepared for display
name String Agent name
avatar String Agent avatar link
buttons List<Button> Buttons in the message
fieldsInfo List<FieldInfo> Form fields in the message
rating UsedeskRating? Message rating. null if the message cannot be rated


UsedeskMessageAgentText.Button
Name Type Description
name String Button label
url String Link
type String Button type


UsedeskMessageAgentText.FieldInfo
Name Type Description
id String Field identifier
name String Field name
required Boolean Whether the field is required


Rating class — UsedeskRating

Added in version 4.7.0

Comes from the server together with the agent message and is not constructed on the client. The identifier of the selected option is passed to the sendRating method.

Name Type Description
appearance Appearance Rating appearance
options List<Option> Rating options in display order
selectedId String? Identifier of the rating already given. null — the message has not been rated yet


UsedeskRating.Option
Name Type Description
id String Option identifier. This is what is passed to sendRating
label String Option label
data String Value sent to the server. Equals id by default
reaction Reaction? LIKE or DISLIKE for reactions, null for other options


UsedeskRating.Appearance
Value Description
REACTIONS Rating with two reactions: like and dislike
STARS Rating with stars — one per option in options


UsedeskRating.Option.Reaction
Value Description
LIKE Positive reaction
DISLIKE Negative reaction


Agent messages with a file

The classes UsedeskMessageAgentFile, UsedeskMessageAgentImage, UsedeskMessageAgentVideo and UsedeskMessageAgentAudio implement UsedeskMessage.File, UsedeskMessageOwner.Agent and share the same set of fields.

Name Type Description
id String Message identifier
createdAt Calendar Creation time
file UsedeskFile File
name String Agent name
avatar String Agent avatar link


Client text message class — UsedeskMessageClientText : UsedeskMessage.Text, UsedeskMessageOwner.Client
Name Type Description
id String Message identifier
createdAt Calendar Creation time
text String Original message text
convertedText String Text prepared for display
status UsedeskMessageOwner.Client.Status Sending status
localId String Local message identifier


Client messages with a file

The classes UsedeskMessageClientFile, UsedeskMessageClientImage, UsedeskMessageClientVideo and UsedeskMessageClientAudio implement UsedeskMessage.File, UsedeskMessageOwner.Client and share the same set of fields.

Name Type Description
id String Message identifier
createdAt Calendar Creation time
file UsedeskFile File
status UsedeskMessageOwner.Client.Status Sending status
localId String Local message identifier


UsedeskMessageOwner.Client.Status
Value Description
SENDING The message is being sent
SUCCESSFULLY_SENT The message was sent successfully
SEND_FAILED The message could not be sent


On-device file info class — UsedeskFileInfo
Name Type Description
uri Uri File address on the device
type String File MIME type
name String File name


Server file info class — UsedeskFile : Parcelable
Name Type Description
content String File link
type String File MIME type
size String File size
name String File name


Message draft class — UsedeskMessageDraft
Name Type Description
text String Draft text
files List<UsedeskFileInfo> Attached files


Offline form class — UsedeskOfflineForm
Name Type Description
clientName String Client name
clientEmail String Client email
topic String Request topic
fields List<Field> Filled additional fields
message String Request text


UsedeskOfflineForm.Field
Name Type Description
key String Field key
title String Field name
value String Field value


Offline form settings class — UsedeskOfflineFormSettings
Name Type Description
noOperators Boolean No operators online
workType WorkType Form work mode
callbackTitle String Form title
callbackGreeting String Form greeting text
fields List<CustomField> Additional fields
topics List<String> List of request topics
topicsTitle String Topics list title
topicsRequired Boolean Whether choosing a topic is required


UsedeskOfflineFormSettings.CustomField
Name Type Description
key String Field key
required Boolean Whether the field is required
checked Boolean Whether the field is enabled
placeholder String Field placeholder


UsedeskOfflineFormSettings.WorkType
Value Description
NEVER The form is never shown
CHECK_WORKING_TIMES The form is shown outside working hours
ALWAYS_ENABLED_CALLBACK_WITHOUT_CHAT The form is always shown, without the chat
ALWAYS_ENABLED_CALLBACK_WITH_CHAT The form is always shown, together with the chat


Connection state class — UsedeskConnectionState
Value Description
NONE No connection has been established
CONNECTING Connecting
RECONNECTING Reconnecting
CONNECTED Connected
DISCONNECTED Disconnected


Event listener interface — UsedeskActionListener
fun onModel(
    model: UsedeskChat.Model,
    newMessages: List<UsedeskMessage>,
    updatedMessages: List<UsedeskMessage>,
    removedMessages: List<UsedeskMessage>
)

fun onModelUpdated(
    oldModel: UsedeskChat.Model?,
    newModel: UsedeskChat.Model
)

fun onException(usedeskException: Exception)

All methods have a default implementation — override only the ones you need.