Android
Native Kotlin chat SDK with a full Jetpack Compose UI: AI chatbot, live-agent handoff, attachments, typing indicators and unread counts.
Installlink
mavenCentral() must be present in dependencyResolutionManagement; consumer R8/ProGuard rules ship in the AAR. minSdk 24, JDK 17.
implementation("cloud.newinstance:liveandaichat:0.1.1")Quick startlink
val chat = LiveAndAiChat.Builder(context)
.config(LiveAndAiChatConfig(apiKey = "sk_live_abc123"))
.user(ChatUser(customerName = "Ada", customerEmail = "ada@example.com", customerId = "usr_123"))
.build()
chat.openChat()openChat() starts the bundled chat activity internally; Compose hosts can embed ChatScreen(sdk, onClose, onPickFile = {}, modifier) directly. ChatUser requires a non-blank customerName (it throws otherwise); changing customerEmail or customerId in setUser clears the saved conversation and starts fresh.
Configurationlink
| Field | Default | Notes |
|---|---|---|
apiKey | required | Publishable widget key ID. A keyId:secret value is stripped to the ID with a warning |
baseUrl | https://service.newinstance.cloud | Release builds throw on any override (debug-only escape hatch) |
gqlPath / ssePath / wsPath | /service / /graphql/stream / /graphql/ws | Transport paths |
transport | inherited | sse or ws override |
initialMessage | - | Message sent automatically when the conversation opens |
API surfacelink
initialize, openChat, closeChat, sendMessage, retryMessage, attachFile(bytes, name, mimeType, previewUri), removeAttachment, clearAttachments, requestHandoff(reason), connectToAgent(reason), sendTypingStart / sendTypingStop, setUser, addListener / removeListener, destroy.
Observe state via StateFlows: lifecycle, connectionState, messages, conversation, assignment, agentTyping, unreadCount, orgConfig, agentsOnline, attachments, flowState, widgetOpen; or a listener with onMessageReceived, onMessageSent, onTyping, onConnectionChange, onUnreadCountChange, onError. Errors carry type (NETWORK, VALIDATION, AUTH, SYSTEM) and recoverable.
Platform noteslink
- The SDK manifest already declares INTERNET, ACCESS_NETWORK_STATE and legacy WRITE_EXTERNAL_STORAGE (maxSdkVersion 28) and merges the chat activity; add READ_MEDIA_IMAGES only if your own picker needs it.
- Theming comes from the org configuration (the dashboard can force dark or light; otherwise the system theme applies); there is no local theme parameter.
- All UI strings are Android string resources, so hosts can localise with
values-xxoverrides. - No push notifications: unread is in-app only via
unreadCount. destroy()cancels the SDK scope; any later call throws IllegalStateException, so build a new instance to start again.