Rate this page:

KitChat

Class that represents basic functions of the mobile channel, such as connecting to Voximplant Kit, sending, and receiving messages. It also notifies an application if any changes to the connection state occur, delivers customer data, and informs if there is an active conversation.

Constructors

KitChat

Copy URL
fun KitChat(accountRegion: 

String

,
channelUuid:

String

,
token:

String

,
clientId:

String

):

Parameters

  • accountRegion:

    String

    Account region for a mobile channel.

  • channelUuid:

    String

    Mobile channel UUID.

  • token:

    String

    Mobile channel token.

  • clientId:

    String

    Customer unique identifier.

Props

MAX_FILE_ATTACHMENTS

Copy URL
val MAX_FILE_ATTACHMENTS: 

Int

Maximum number of attachments that can be sent in a message.

Returns

  • type:

    Int

MAX_FILE_SIZE

Copy URL
val MAX_FILE_SIZE: 

Long

Maximum file attachment size in bytes that can be sent in a message.

Returns

  • type:

    Long

MAX_TEXT_LENGTH

Copy URL
val MAX_TEXT_LENGTH: 

Int

Maximum text length in characters that can be sent in a message.

Returns

  • type:

    Int

SUPPORTED_DOCUMENT_MIME_TYPES

Copy URL
val SUPPORTED_DOCUMENT_MIME_TYPES: 

List<String>

List of supported document MIME types.

Returns

  • type:

    List<String>

SUPPORTED_FILE_MIME_TYPES

Copy URL
val SUPPORTED_FILE_MIME_TYPES: 

List<String>

List of supported file MIME types - unified list of SUPPORTED_IMAGE_MIME_TYPES and SUPPORTED_DOCUMENT_MIME_TYPES.

Returns

  • type:

    List<String>

SUPPORTED_IMAGE_MIME_TYPES

Copy URL
val SUPPORTED_IMAGE_MIME_TYPES: 

List<String>

List of supported image MIME types.

Returns

  • type:

    List<String>

clientData

Copy URL
val clientData: 

StateFlow<ClientData?>

Flow of ClientData that emits new instances of the ClientData once the customer information is updated.

The customer information can be updated as a result of:

Returns

connectionState

Copy URL
val connectionState: 

Flow<ConnectionState>

Flow of ConnectionState that emits new instances of ConnectionState once the state of the connection to Voximplant Kit is changed.

The connection state can be changed as a result of:

  • KitChat.openConnection API call.
  • KitChat.closeConnection API call.
  • internet connection loss on a device.
  • network change on a device.
  • Android OS drops the connection due to battery restriction while the application is in the background.

Returns

hasActiveConversation

Copy URL
val hasActiveConversation: 

StateFlow<Boolean>

Flow of the Boolean that represents the current status of the conversation.

The conversation is not active if it is closed by an agent, timeout, or other channel settings.

Returns

  • type:

    StateFlow<Boolean>

messagesFlow

Copy URL
val messagesFlow: 

Flow<Message>

Flow of Message that emits new instances of Message representing conversation inbound messages.

Returns

Methods

closeConnection

Copy URL
fun closeConnection(): 

Unit

Closes a previously opened connection to Voximplant Kit.

Returns

  • type:

    Unit

getMessages

Copy URL
fun getMessages(messageUuid: 

String?

,
size:

Int

,
direction:

MessageHistoryDirection

):

Result<GetMessagesResult>

Requests previous or next messages from a message UUID.

If the message UUID parameter is null, the request is performed from the last message in the conversation even if the last message has not been received by the customer.

The maximum number of messages to be requested is 20. Requesting more than 20 messages causes IllegalArgumentException.

If the connectionState is not ConnectionState.Connected, KitConnectionRequiredException is returned as the Result.failure.

Returns a Result with the result of the operation. If the request is successfully completed, provides a GetMessagesResult instance with additional data, such as a list of messages and a boolean indicator whether there are more messages in the requested direction.

If the operation fails, provides an exception with details:

Parameters

Returns

openConnection

Copy URL
fun openConnection(): 

Boolean

Opens a connection to Voximplant Kit.

The API makes KitChat.connectionState to emit new instances of ConnectionState representing the connection state changes.

If the connection to Voximplant Kit is successful, the following data can be updated:

If the current state is not ConnectionState.Disconnected, returns false.

Returns the Boolean that represents whether the connection is successfully established.

Returns

  • type:

    Boolean

registerPushToken

Copy URL
fun registerPushToken(token: 

String

):

Result<Unit>

Registers a token to receive push notifications for new inbound messages on the current device.

To receive push notifications, it is also required to upload a Firebase certificate.

Returns a Result with the result of the operation. If the operation fails, provides an exception with details:

Parameters

  • token:

    String

    FCM registration token to register.

Returns

  • type:

    Result<Unit>

sendMessage

Copy URL
fun sendMessage(message: 

Message

):

Result<Message>

Sends a message.

The message may be:

If the connectionState is not ConnectionState.Connected, KitConnectionRequiredException is returned as the Result.failure.

Returns a Result with the result of the operation. If the message is sent successfully, provides a Message instance with additional data, such as the message UUID and attachments' URLs.

If the operation fails, provides an exception with details:

Parameters

Returns

setClientData

Copy URL
fun setClientData(client: 

ClientData

):

Result<Unit>

Sets customer information to the agent's workspace.

Returns a Result with the result of the operation.

If the operation fails, provides an exception with details:

Parameters

Returns

  • type:

    Result<Unit>

unregisterPushToken

Copy URL
fun unregisterPushToken(token: 

String

):

Result<Unit>

Unregisters a token to stop receiving push notifications on the current device.

Returns a Result with the result of the operation.

If the operation fails, provides an exception with details:

Parameters

  • token:

    String

    FCM registration token to unregister.

Returns

  • type:

    Result<Unit>