<t-conversation-list>
Displays a list of conversations that the current user is a participant of.
Your app's unique TalkJS ID. You can find it on the Settings page of the TalkJS dashboard.
The ID of the current user.
Optional. The ID of the conversation currently selected in the list. Updating this property changes the selected conversation without firing a select-conversation
event.
Optional. The name of the theme to apply to the conversation list. By default TalkJS uses a preset theme. You can customize the conversation list's look and behavior by using a custom theme. See Customize your theme.
A token to authenticate the session with. See the Authentication guide and Token reference for details and examples.
Required when authentication is enabled, optional otherwise.
The following examples show how to use the <t-conversation-list>
component.
To create a conversation list and pass it an existing user, use the following:
1<t-conversation-list app-id="<APP_ID>" user-id="sample_user_alice" />
Install the @talkjs/core
package, which lets you read, subscribe to, and update your chat data:
1npm install @talkjs/core
Import it into the component where you want to use it:
1import { getTalkSession } from '@talkjs/core';
Then create the session and user:
1appId = '<APP_ID>';2userId = 'sebastian';3session: TalkSession | null = null;45ngOnInit() {6 this.session = getTalkSession({7 appId: this.appId,8 userId: this.userId,9 });10 this.session.currentUser.createIfNotExists({ name: 'Sebastian' });11}
Pass the new user to your conversation list:
1<t-conversation-list [app-id]="appId" [user-id]="userId" />
If you're using TalkJS web components without a package manager, see the Create new users and conversations guide.
Respond to a select conversation event by switching the chatbox to show the selected conversation.
When a user selects a conversation from the list, the component emits a select-conversation
event with the selected conversation’s details. You can handle this event to update a chatbox or perform another action.
1// chat.component.html2<t-conversation-list3 app-id="<APP_ID>"4 user-id="sample_user_alice"5 [selected-conversation-id]="conversationId()"6 (selectConversation)="onSelectConversation($event)"7></t-conversation-list>89<t-chatbox10 app-id="<APP_ID>"11 user-id="sample_user_alice"12 [conversation-id]="conversationId()"13></t-chatbox>1415// chat.component.ts16conversationId = signal("sample_conversation");1718onSelectConversation(event: SelectConversationEvent): void {19 this.conversationId.set(event.conversation.id);20}