sendMessage

abstract fun sendMessage(message: String, newContext: Map<String, String>? = null): Deferred<MessageChat>

Send a message on behalf of the user, programmatically.

Lets the host app drive the conversation as if the user typed and tapped send. The SDK renders the bubble locally with a temporary id and reconciles it with the server-assigned id when the POST response returns — do not also display the message yourself, and do not add it to any external chat log you maintain.

Behaviour:

  • Trims whitespace; an empty/whitespace-only message completes exceptionally with KindlySDKError.InvalidData.

  • Completes exceptionally with KindlySDKError.ChatNotConnected if called before the chat is connected. Observe KindlySDK.state for isConnected first.

  • Per-call newContext overrides any context previously staged via setNewContext.

Return

A Deferred that completes with the reconciled MessageChat (carrying the server-assigned id and timestamp), or completes exceptionally on failure.

Parameters

message

The message text to send. Whitespace is trimmed.

newContext

Optional per-call context attached to this message only.