Conversations in the iOS SDK
List a customer's past conversations, load their messages and resume a thread with the iOS 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
let page = try await octo.conversations(limit: 20, cursor: nil)
for c in page.data {
print("\(c.id) \(c.status) \(c.messageCount) messages")
}
conversations returns a Page: a data array and a nextCursor. When nextCursor is not nil, pass it back to get the next page.
var cursor: String? = nil
var all: [Conversation] = []
repeat {
let page = try await octo.conversations(limit: 50, cursor: cursor)
all += page.data
cursor = page.nextCursor
} while cursor != nil
limit accepts 1 to 100 and defaults to 20, like the REST API. See Pagination.
Load one conversation and its messages
let conversation = try await octo.conversation(id: "conv_8f2a")
let messages = try await octo.messages(conversationId: conversation.id, limit: 50, cursor: nil)
Messages come back oldest first. Use messages.data as the data source of a List or ForEach.
Resume a conversation
Pass the conversation id to chat or streamChat.
let reply = try await 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.