# Conversations & History > Start, continue, list and page through conversations with the QwryAI Android SDK ## Starting and continuing conversations **1. Send a message** The first message starts a new conversation when you don't pass a `conversationId`. ```kotlin val response = client.send("Hello!") ``` **2. Keep the conversation ID** The response carries the conversation's ID: ```kotlin val conversationId = response.conversationId ``` **3. Continue the conversation** Pass the ID to later calls: ```kotlin val followUp = client.send( text = "Tell me more", conversationId = conversationId ) ``` > [!TIP] > > The client also remembers the conversation it last used. After your first `send`, later calls without a `conversationId` continue the same conversation: > > ```kotlin > client.send("First message") // starts a new conversation > client.send("Follow-up") // continues the same conversation > println(client.currentConversationId) // that conversation's ID > ``` ## newConversation `class QwryClient`, **Package:** `com.qwryai.sdk` ```kotlin fun newConversation() ``` Forgets the current conversation, so the next `send` starts a new one. ```kotlin client.newConversation() client.send("Brand new conversation!") ``` ## listConversations ```kotlin suspend fun listConversations( cursor: String? = null, limit: Int = 20 ): Page ``` Lists the user's conversations (this install's while anonymous), most recently active first. **cursor** `String?` The `cursor` from the previous page. Leave it out for the first page. **limit** `Int` Conversations per page, from 1 to 100. Defaults to 20. ```kotlin val page = client.listConversations(limit = 20) page.items.forEach { conversation -> println("${conversation.title ?: "New conversation"}: ${conversation.status}") } println("Total: ${page.total}") println("Has more: ${page.hasMore}") ``` ### Conversation `data class Conversation`, **Package:** `com.qwryai.sdk` ```kotlin data class Conversation( val id: String, val title: String?, val createdAt: Long, val updatedAt: Long, val userId: String?, val status: Status ) ``` **id** `String` *required* The conversation's ID. **title** `String?` A short summary QwryAI writes for the conversation, or `null` until there is one. **createdAt** `Long` *required* When the conversation started, in seconds since 1970. **updatedAt** `Long` *required* When it was last active, in seconds since 1970. **userId** `String?` The identified user it belongs to, or `null` for an anonymous (device) conversation. **status** `Conversation.Status` *required* `ONGOING`, `ENDED` or `TAKEN_OVER`. ## listMessages ```kotlin suspend fun listMessages( conversationId: String, cursor: String? = null, limit: Int = 20 ): Page ``` Loads a page of a conversation's messages. **conversationId** `String` *required* The conversation to read. **cursor** `String?` The `cursor` from the previous page, to reach further back. Leave it out for the newest messages. **limit** `Int` Messages per page, from 1 to 100. Defaults to 20. > [!NOTE] > > The first page holds the **most recent** messages, and each `cursor` reaches further back. Within a page, messages run oldest to newest, ready to show top to bottom. ```kotlin val page = client.listMessages(conversationId, limit = 50) page.items.forEach { message -> val who = if (message.role == Message.Role.USER) "You" else "Agent" println("$who: ${message.text}") } ``` ### Message `data class Message`, **Package:** `com.qwryai.sdk` ```kotlin data class Message( val id: String, val role: Role, val parts: List, val createdAt: Long? = null, val feedback: Feedback? = null, val score: Double? = null ) ``` **id** `String` *required* The message's ID. **role** `Message.Role` *required* `USER` or `ASSISTANT`. Replies from a person on your team also come back as `ASSISTANT`. **parts** `List` *required* The message's content: text, tool calls and tool results. **createdAt** `Long?` When it was sent, in seconds since 1970. **feedback** `Message.Feedback?` `POSITIVE`, `NEGATIVE` or `null`. **score** `Double?` The agent's confidence in this answer, when it reported one. **text** `String` All of the message's text parts joined together. ## Pagination `data class Page`, **Package:** `com.qwryai.sdk` Both list calls return a `Page`. ```kotlin data class Page( val items: List, val cursor: String?, val hasMore: Boolean, val total: Int ) ``` **items** `List` *required* The items on this page. **cursor** `String?` Pass it back to get the next page. `null` when there are no more. **hasMore** `Boolean` *required* Whether another page exists. **total** `Int` *required* How many items there are across all pages. ### Paging through all results ```kotlin var page = client.listConversations(limit = 20) while (true) { page.items.forEach { conversation -> println(conversation.title) } val next = page.cursor if (!page.hasMore || next == null) break page = client.listConversations(cursor = next, limit = 20) } ``` ### Ready-made state holders For screens, `ConversationListState` and `ConversationState` keep the pages for you as `StateFlow`s: ```kotlin val list = ConversationListState(client) list.load() // the most recently active conversations list.loadMore() // the next page, added to the end of list.conversations val chat = ConversationState(client, conversationId) chat.load() // the latest page of messages chat.loadEarlier() // the page before the oldest message shown, added to the top of chat.messages ``` `ConversationListState` exposes `conversations`, `hasMore` and `error`. `ConversationState` exposes `messages`, `isSending`, `hasEarlier` and `error`, and its `send` and `retry` stream the answer into `messages`. ## Related > [card] Streaming | /docs/android-sdk/streaming | Send messages and stream answers. > [card] User Identity | /docs/android-sdk/user-identity | Make conversations belong to a user.