Conversations in the Android SDK
List a customer's past conversations, load their messages and resume a thread with the Android SDK, including cursor pagination.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
A conversation is a thread between one customer and one agent. The SDK lets you list a customer's earlier threads, open one and continue it. Use this to build a history screen or to restore a chat after the app restarts.
Who can see which conversations
The SDK returns conversations for the current user only. Without an identity, that is the anonymous visitor on this device. After you call identify with a UserIdentity, the same customer sees their conversations on every device.
List conversations
val page = octo.conversations(limit = 20, cursor = null)
page.data.forEach { c ->
println("${c.id} ${c.status} ${c.messageCount} messages")
}
conversations returns a Page: a data list and a nextCursor. When nextCursor is not null, pass it back to get the next page.
var cursor: String? = null
val all = mutableListOf<Conversation>()
do {
val page = octo.conversations(limit = 50, cursor = cursor)
all += page.data
cursor = page.nextCursor
} while (cursor != null)
limit accepts 1 to 100 and defaults to 20, like the REST API. See Pagination.
Load one conversation and its messages
val conversation = octo.conversation("conv_8f2a")
val messages = octo.messages(conversationId = conversation.id, limit = 50)
Messages come back oldest first. Use messages.data to fill a list adapter or a LazyColumn.
Resume a conversation
Pass the conversation id to chat or streamChat.
val reply = octo.chat(
text = "Any update on my refund?",
conversationId = conversation.id,
)
Conversation status
| Status | Meaning |
|---|---|
open |
The agent is handling the conversation. |
resolved |
The conversation is finished. A new message reopens it. |
handoff |
The agent passed the conversation to your team in the Helpdesk. |
Use handoff to show a line such as "A teammate will reply here" above the input field.
Next steps
See the full field list in Conversation models, and handle failed loads with Error handling.