Starting and Continuing Conversations
1
Send a message
Send a message with no
conversationId to start a new conversation. The server creates one.2
Keep the conversation ID
client.currentConversationId.3
Continue the conversation
Pass the ID to the next call:
newConversation
currentConversationId. Use it if you track the current conversation through the client rather than your own state.
listConversations
String?
A cursor from an earlier page. Leave it out to start at the beginning. Prefer
loadMore() over passing cursors yourself.Int?
How many per page, from 1 to 100. The server uses 20 if you leave it out.
Only conversations created through the mobile SDKs are listed. Widget, API, and integration conversations are left out. Which ones you get depends on identity: the signed-in user’s conversations if there is one, otherwise the device’s. See User Identity.
Conversation for the full type.
listMessages
String
required
The conversation to load messages from.
String?
A cursor from an earlier page. Leave it out to start with the newest messages.
Int?
How many per page, from 1 to 100. The server uses 20 if you leave it out.
Pages go backwards in time. The first page holds the newest messages, and each
loadMore() gets older ones. Inside a page, messages run oldest to newest, so you can add a page to a chat view as it is. When you load an older page, add it to the top.Message has both a plain text value (all the text joined together) and a parts list, so you can show tool activity inline with the conversation:
Messages with no parts are skipped, so a page can hold fewer items than
limit even when hasMore is true. Base your “load more” button on hasMore, never on data.count.Message for the full type.
PaginatedResponse
[T]
required
The items on this page.
Bool
required
Whether there are more pages.
Int
required
How many items there are in total.
loadMore
nil when hasMore is false. The page keeps its own cursor, so you have nothing to pass along.
limit you passed the first time is reused for every later page, so page sizes stay the same.
Infinite scroll in SwiftUI
Conversation Status
A conversation that has ended, or that a person has taken over, cannot take new messages. Sending to one fails with403 CHAT_CONVERSATION_NOT_ONGOING. Check before showing a text field:
Related
Conversation & Pagination
The full type reference
SwiftUI
Ready-made state for lists and history
Streaming
Send messages and stream replies
User Identity
Tie conversations to users
