ChatKindlySDK

open class ChatKindlySDK(application: Application, botKey: String, languageCode: String = "en", behaviorType: BehaviorType = BehaviorType.NATIVE, authTokenCallback: AuthTokenCallback? = null) : EntryPoint

Main implementation of the Kindly Chat SDK. Use the companion object methods (e.g., KindlySDK.start(), KindlySDK.launchChat()) to interact with the SDK.

Parameters

application

The application context.

botKey

The bot key for the Kindly Chat API.

languageCode

The language code to use (default is "en").

behaviorType

The behavior type for the SDK. Currently only BehaviorType.NATIVE is supported.

Constructors

Link copied to clipboard
constructor(application: Application, botKey: String, languageCode: String = "en", behaviorType: BehaviorType = BehaviorType.NATIVE, authTokenCallback: AuthTokenCallback? = null)

Types

Link copied to clipboard

Properties

Link copied to clipboard
open lateinit override var config: KindlySDKConfig

The SDK configuration for permissions and theme settings.

Link copied to clipboard
open override var enableCrashReporting: Boolean

Whether the SDK should send crash reports via Sentry. Defaults to true.

Link copied to clipboard
open override val events: Flow<KindlyEvent>

Unified event flow for all Kindly events (matches web API pattern) Subscribe to this to receive all events: load, message, buttonClick, ui, globalIcon, state

Link copied to clipboard
Link copied to clipboard

Flow that emits input field visibility changes Subscribe to this to get real-time updates when input field should be hidden or shown

Link copied to clipboard
open override var interface: KindlySDKInteraction?

Optional delegate for receiving button press and link interception callbacks.

Link copied to clipboard
var onKindlyInterfaceSet: (kindlyInterface: KindlySDKInteraction?) -> Unit?
Link copied to clipboard
open override val state: Flow<KindlyEventState>

Unified state flow that emits state change events Subscribe to this to get real-time updates of: isChatDisplayed, isConnected, isStarted, isSocketConnected

Link copied to clipboard
open override var verboseLogging: Boolean

Whether verbose logging is enabled. Defaults to false.

Functions

Link copied to clipboard
open override fun callHandover(handoverListener: CallbackHandover)

Handovers the call from the chatBot.

Link copied to clipboard
open override fun clearCustomTheme()

Clears any custom theme that has been set and reverts to the default theme.

Link copied to clipboard
open override fun clearNewContext()

Clears the current context of the chat.

Link copied to clipboard
open override fun clearTriggerDialog()

Clears any pending trigger dialogue request.

Link copied to clipboard
open override fun close()

Closes the chat.

Link copied to clipboard
open override fun displayChat(context: Context)

Displays the chat UI. This should only be called after the connection is established.

Link copied to clipboard
open override fun endChat()

Ends the chat session and disconnects from the server. This acts as a disconnect - the SDK remains initialized and can be reconnected by calling launchChat() again without needing to call start(). Use kill() if you want to completely terminate the SDK.

Link copied to clipboard
open override fun handleNotification(remoteMessage: RemoteMessage)

Handles an incoming Firebase push notification. Call this from your FirebaseMessagingService.

Link copied to clipboard
open override fun handleUrl(context: Context, uri: Uri): Boolean

Handles a Kindly URL scheme deep link. Supported format: kindly://chat/dialogue/{id}

Link copied to clipboard

Gets the current input field visibility state.

Link copied to clipboard
open override fun isKindlyNotification(remoteMessage: RemoteMessage): Boolean

Checks if a notification is from Kindly.

Link copied to clipboard
open override fun kill()

Completely kills the SDK and clears all state. After calling this method, start() must be called again before using any other SDK functions. This is more destructive than endChat() which only disconnects the chat session.

Link copied to clipboard
open override fun launchChat(context: Context, triggerDialogueId: String? = null)

Opens the chat bot after connecting to the Kindly service.

Link copied to clipboard
open override fun saveNotificationToken(token: String)

Saves the Firebase Cloud Messaging token for push notifications.

Link copied to clipboard
open override fun sendMessage(message: String, newContext: Map<String, String>? = null): Deferred<MessageChat>

Send a message on behalf of the user, programmatically.

Link copied to clipboard
open override fun setCustomTheme(theme: KindlyThemeColors)

Sets a custom theme for the chat UI.

open override fun setCustomTheme(background: Color? = null, botMessageBackground: Color? = null, botMessageText: Color? = null, buttonBackground: Color? = null, buttonOutline: Color? = null, buttonText: Color? = null, chatLogElements: Color? = null, headerBackground: Color? = null, headerText: Color? = null, inputBackground: Color? = null, inputText: Color? = null, userMessageBackground: Color? = null, userMessageText: Color? = null, maintenanceHeaderBackground: Color? = null)

Sets a custom theme using individual color parameters. Only specified colors (non-null) will override the default theme.

Link copied to clipboard

Manually controls input field visibility. This will override any automatic visibility settings from messages or global settings.

Link copied to clipboard
open override fun setLanguage(languageCode: String)

Updates the language for the current SDK session. This will be used for all subsequent chat connections and UI elements.

Link copied to clipboard
open override fun setNewContext(context: Map<String, String>)

Sets a new context for the chat.

Link copied to clipboard
Link copied to clipboard
open override fun start(application: Application, botKey: String, languageCode: String = "en", authTokenCallback: AuthTokenCallback? = null)

Initializes the Kindly Chat SDK. This is the first method that should be called before using any other SDK functions. The SDK will automatically use NATIVE behavior for optimal performance and compliance.

Link copied to clipboard
open override fun triggerDialogue(id: String)

Triggers a dialog for the provided id.