---
url: https://talkjs.com/docs/UI_Components/Android/ConversationList/
title: "ConversationList | Android | TalkJS Docs"
---

For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

# ConversationList

Display a list of conversations.

The `ConversationList` component represents a [conversation list UI](https://talkjs.com/docs/Features/Chat_UIs/#conversation-list), which displays a list of conversations that the current user is a participant of.

### ConversationList

fun ConversationList(appId, userId, selectedConversationId, token, baseTheme, themePath, themeCustom, customCssPath, onSelectConversation, modifier, key, controller)

#### Parameters

**appId**: String

Your app's unique TalkJS ID. You can find it on the Settings page of the [TalkJS dashboard.](https://talkjs.com/dashboard)

**userId**: String

The ID of the current user.

If the given user ID doesn't exist, a "Something went wrong" message will be displayed.

**selectedConversationId _(optional)_**: String?

The ID of the conversation currently selected in the list.

Changing the value of this parameter will cause the ConversationList UI to update.

Also update your local `selectedConversationId` state in `onSelectConversation` so that it stays in sync with the UI's internals.

Note that updating the selected conversation through this parameter will not trigger the `onSelectConversation` callback.

**token _(optional)_**: String?

A token to authenticate the session with.

See the [Authentication guide](https://talkjs.com/docs/Features/Security/Authentication/) and [Token reference](https://talkjs.com/docs/Features/Security/Advanced_Authentication/#token-reference) for details and examples.

Required when authentication is enabled, otherwise optional.

**baseTheme _(optional)_**: [BaseTheme](https://talkjs.com/docs/UI_Components/Android/Other_types/#BaseTheme)?

The base theme to start from.

Defaults to `DEFAULT`.

**themePath _(optional)_**: String?

Path to a custom theme file, relative to the app's `assets` folder.

**themeCustom _(optional)_**: JsonElement?

Arbitrary custom data passed down to the theme.

Whatever data you pass here will be made available for use in the theme module loaded via `themePath`.

**customCssPath _(optional)_**: String?

Path to a custom CSS file, relative to the app's `assets` folder.

**onSelectConversation _(optional)_**: ((event: [SelectConversationEvent](https://talkjs.com/docs/UI_Components/Android/Other_types/#SelectConversationEvent)) -> Unit)?

Callback that triggers when the user selects a conversation from the list.

`event` is the event object containing the selected conversation.

Note that updating the selected conversation through the `selectedConversationId` parameter will not trigger this callback.

Use this callback to have an adjacent chatbox show the correct conversation. See [Respond to a select conversation event.](https://talkjs.com/docs/UI_Components/React/ConversationList/#respond-to-a-select-conversation-event)

**modifier**: Modifier

**key _(optional)_**: String?

**controller**: [ConversationListController](https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationListController)

A reference to the [ConversationListController](https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationListController).

#### Returns

Unit

### rememberConversationListController

fun rememberConversationListController(): [ConversationListController](https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationListController)

#### Returns

[ConversationListController](https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationListController)

## class ConversationListController

A collection of actions available on the ConversationList UI.

### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationListController__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationListController__selectConversation" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">selectConversation</a></td><td><p>Selects a conversation with the given ID, or de-select a conversation by passing <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">null</code>.</p></td></tr></tbody></table>

### constructor

ConversationListController()

### selectConversation

suspend fun _conversationListController_.selectConversation(conversationId, focusedMessageId)

Selects a conversation with the given ID, or de-select a conversation by passing `null`.

This method is called from the theme's ConversationListItem component when the user clicks on the given conversation. You can also call it programmatically from elsewhere to simulate a user click.

This method will trigger the `onSelectConversation` callback of [ConversationList](https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationList). In most cases, if you want to change the selected conversation programmatically from outside the conversation list, it's better to pass a different value to the `selectedConversationId` parameter of [ConversationList](https://talkjs.com/docs/UI_Components/Android/ConversationList/#ConversationList) instead, as that lets you keep your local state in sync with the parameters passed to the conversation list.

You can also optionally pass a `focusedMessageId` to signify the intent of scrolling to a particular message within that conversation.

#### Parameters

**conversationId _(optional)_**: String?

**focusedMessageId _(optional)_**: String?

#### Returns

Unit

## Examples

The following examples show how to use the `ConversationList` component.

### Create a conversation list with an existing user

To create a conversation list and pass it an existing user, use the following:

```kotlin
ConversationList(
    appId = "<APP_ID>",
    userId = "sample_user_alice",
)
```

### Create a conversation list with a new user

The [Kotlin Data API](https://talkjs.com/docs/Data_APIs/Kotlin/), which lets you read, subscribe to, and update your chat data, is included with Android Components.

Import `getTalkSession` into the file where you want to use it:

```kotlin
import com.talkjs.core.getTalkSession
```

Then create the session and user:

```kotlin
class ChatViewModel : ViewModel() {
    val appId = "<APP_ID>"
    val userId = "sebastian"

    init {
        val session = getTalkSession(appId = appId, userId = userId)

        viewModelScope.launch {
            session.currentUser.createIfNotExists(name = "Sebastian")
        }
    }
}
```

Pass the new user to your conversation list:

```kotlin
val viewModel = viewModel<ChatViewModel>()

ConversationList(
    appId = viewModel.appId,
    userId = viewModel.userId,
)
```

### Respond to a select conversation event

Respond to a select conversation event by switching the [chatbox](https://talkjs.com/docs/UI_Components/Android/Chatbox/) to show the selected conversation.

When a user selects a conversation from the list, the component calls the `onSelectConversation` callback with the selected conversation’s details. You can handle this event to update a chatbox or perform another action.

```kotlin
var conversationId by remember { mutableStateOf<String?>("sample_conversation") }

Column {
    ConversationList(
        modifier = Modifier.weight(1f),
        appId = "<APP_ID>",
        userId = "sample_user_alice",
        selectedConversationId = conversationId,
        onSelectConversation = { event ->
            conversationId = event.conversation?.id
        },
    )

    Chatbox(
        modifier = Modifier.weight(1f),
        appId = "<APP_ID>",
        userId = "sample_user_alice",
        conversationId = conversationId,
    )
}
```
