> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# Incrustar el Channel List Element

> Muestra las conversaciones de mensajes directos de un usuario junto al chat element y abre la que seleccione.

El DMs list element muestra una lista navegable de las conversaciones de mensajes directos del usuario. Usa el mismo [tema](https://docs.whop.com/es/developer/guides/chat/theming-and-styles.md) que el resto de tus elementos de chat. Para ver todas las opciones que acepta en la web, consulta la [referencia de `DmsListElement`](https://docs.whop.com/es/sdk/elements/dms-list-element).

### Uso básico

Monta la lista de MD y escucha los eventos de selección de canal para llevar a los usuarios a una conversación.

> [tab] React
>
> ```tsx theme={null}
> "use client";
>
> import { useCallback, useMemo, useState } from "react";
> import {
> 	ChatSession,
> 	DmsListElement,
> 	Elements,
> } from "@whop/embedded-components-react-js";
> import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
> import type {
> 	DmsListElementEvent,
> 	DmsListElementOptions,
> } from "@whop/embedded-components-vanilla-js/types";
>
> const elements = loadWhopElements();
>
> async function getToken() {
> 	const response = await fetch("/api/token");
> 	const data = await response.json();
> 	return data.token;
> }
>
> export function MessagesPage() {
> 	const [channelId, setChannelId] = useState<string>();
>
> 	const handleDmsEvent = useCallback((event: DmsListElementEvent) => {
> 		switch (event.type) {
> 			case "channelSelected":
> 				setChannelId(event.detail.id);
> 				break;
> 		}
> 	}, []);
>
> 	const dmsOptions: DmsListElementOptions = useMemo(() => {
> 		return {
> 			selectedChannel: channelId,
> 			onEvent: handleDmsEvent,
> 		};
> 	}, [channelId, handleDmsEvent]);
>
> 	return (
> 		<Elements elements={elements}>
> 			<ChatSession token={getToken}>
> 				<DmsListElement options={dmsOptions} />
> 			</ChatSession>
> 		</Elements>
> 	);
> }
> ```

> [tab] Vanilla JS
>
> ```typescript theme={null}
> import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
>
> async function getToken() {
> 	const response = await fetch("/api/token");
> 	const data = await response.json();
> 	return data.token;
> }
>
> const whopElements = await loadWhopElements();
>
> const session = whopElements.createChatSession({
> 	token: getToken,
> });
>
> const dmsListElement = session.createElement("dms-list-element", {});
>
> dmsListElement.on("channelSelected", (ev) => {
> 	console.log("Channel selected:", ev.detail.id);
> });
>
> dmsListElement.mount("#dms-list-container");
> ```

> [tab] Swift
>
> ```swift theme={null}
> struct MessagesView: View {
>     @State private var selectedChannel: DMChannel?
>
>     var body: some View {
>         WhopDMsListView(
>             onEvent: { event in
>                 switch event {
>                 case let .channelSelected(channel):
>                     selectedChannel = channel
>                 }
>             }
>         )
>         .navigationDestination(item: $selectedChannel) { channel in
>             WhopChatView(
>                 channelId: channel.id,
>                 style: .imessage
>             )
>             .navigationBarTitleDisplayMode(.inline)
>             .navigationTitle(channel.name)
>         }
>     }
> }
> ```

### Alcance por cuenta

Filtra la lista de MD para mostrar solo las conversaciones que pertenecen a una cuenta concreta pasando un `companyId`. Para crear un MD desde tu servidor, llama a [Create Channel](https://docs.whop.com/es/api-reference/channels/create-channel.md) con `kind` establecido en `private`. Pasa el mismo ID de cuenta como `account_id` para que el MD aparezca en la lista filtrada.

> [tab] React
>
> ```tsx theme={null}
> const dmsOptions: DmsListElementOptions = useMemo(() => {
> 	return {
> 		companyId: "biz_xxxx",
> 		selectedChannel: channelId,
> 		onEvent: handleDmsEvent,
> 	};
> }, [channelId, handleDmsEvent]);
>
> return (
> 	<Elements elements={elements}>
> 		<ChatSession token={getToken}>
> 			<DmsListElement options={dmsOptions} />
> 		</ChatSession>
> 	</Elements>
> );
> ```

> [tab] Vanilla JS
>
> ```typescript theme={null}
> const dmsListElement = session.createElement("dms-list-element", {
> 	companyId: "biz_xxxx",
> });
>
> dmsListElement.mount("#dms-list-container");
> ```

> [tab] Swift
>
> ```swift theme={null}
> WhopDMsListView(
>     companyId: "biz_xxxx",
>     onEvent: { event in
>         switch event {
>         case let .channelSelected(channel):
>             selectedChannel = channel
>         }
>     }
> )
> ```

### Gestión de eventos

Escucha la selección de canal para abrir la vista de chat correspondiente.

> [tab] React
>
> | Evento | Detalle | Descripción |
> | - | - | - |
> | `channelSelected` | `{ id: string }` | Se emite cuando el usuario selecciona un canal |
>
> ```tsx theme={null}
> const handleDmsEvent = useCallback((event: DmsListElementEvent) => {
> 	switch (event.type) {
> 		case "channelSelected":
> 			setChannelId(event.detail.id);
> 			break;
> 	}
> }, []);
> ```

> [tab] Vanilla JS
>
> | Evento | Detalle | Descripción |
> | - | - | - |
> | `channelSelected` | `{ id: string }` | Se emite cuando el usuario selecciona un canal |
>
> ```typescript theme={null}
> dmsListElement.on("channelSelected", (ev) => {
> 	console.log("Channel selected:", ev.detail.id);
> });
> ```

> [tab] Swift
>
> | Evento | Detalle | Descripción |
> | - | - | - |
> | `.channelSelected` | `channel: DMChannel` | Se emite cuando el usuario toca un canal |
>
> ```swift theme={null}
> WhopDMsListView(
>     onEvent: { event in
>         switch event {
>         case let .channelSelected(channel):
>             selectedChannel = channel
>         }
>     }
> )
> .navigationDestination(item: $selectedChannel) { channel in
>     WhopChatView(
>         channelId: channel.id,
>         style: .imessage
>     )
>     .navigationBarTitleDisplayMode(.inline)
>     .navigationTitle(channel.name)
> }
> ```


## Related topics

- [ChannelListElement](https://docs.whop.com/es/elements/latest/chat/channelList.md)
- [DmsListElement (heredado)](https://docs.whop.com/es/sdk/elements/dms-list-element.md)
- [ListElement](https://docs.whop.com/es/elements/latest/wallet/balances-list.md)
