> ## 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.

# Chat Öğesi

> @whop/elements paketindeki chat öğesiyle sitenizde bir kanal, DM veya destek sohbeti için gerçek zamanlı bir sohbet görüntüleyin.

Chat öğesi, belirli bir kanala bağlı gerçek zamanlı bir sohbet arayüzü görüntüler. Renkleri ve mesaj düzeni, ayarladığınız [tema ve sohbet stilini](https://docs.whop.com/tr/developer/guides/chat/theming-and-styles.md) takip eder. Web'de aldığı tüm seçenekler için [`ChatElement` referansına](https://docs.whop.com/tr/sdk/elements/chat-element) bakın.

### Temel kullanım

Belirli bir kanala, DM'ye veya destek sohbetine bağlanmak için bir `channelId` iletin.

> [tab] React
>
> ```tsx theme={null}
> "use client";
>
> import { useMemo } from "react";
> import {
> 	ChatElement,
> 	ChatSession,
> 	Elements,
> } from "@whop/embedded-components-react-js";
> import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
> import type { ChatElementOptions } 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 ChatPage() {
> 	const chatOptions: ChatElementOptions = useMemo(() => {
> 		return {
> 			channelId: "chat_feed_XXXXXXXXXXXXXX",
> 		};
> 	}, []);
>
> 	return (
> 		<Elements elements={elements}>
> 			<ChatSession token={getToken}>
> 				<ChatElement
> 					options={chatOptions}
> 					style={{ height: "100dvh", width: "100%" }}
> 				/>
> 			</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 chatElement = session.createElement("chat-element", {
> 	channelId: "chat_feed_XXXXXXXXXXXXXX",
> });
>
> chatElement.mount("#chat-container");
> ```

> [tab] Swift
>
> ```swift theme={null}
> import SwiftUI
> import WhopElements
>
> struct ChatView: View {
>     var body: some View {
>         WhopChatView(
>             channelId: "chat_feed_XXXXXXXXXXXXXX",
>             style: .imessage
>         )
>     }
> }
> ```

### Mesajlara derin bağlantı

Belirli bir mesaja kaydırmak ve onu vurgulamak için `deeplinkToPostId` iletin. Görünüm otomatik olarak o mesaja gider.

> [tab] React
>
> ```tsx theme={null}
> const chatOptions: ChatElementOptions = useMemo(() => {
> 	return {
> 		channelId: "chat_feed_XXXXXXXXXXXXXX",
> 		deeplinkToPostId: "post_XXXXXXXXXXXXXX",
> 	};
> }, []);
>
> <ChatElement options={chatOptions} />;
> ```

> [tab] Vanilla JS
>
> ```typescript theme={null}
> const chatElement = session.createElement("chat-element", {
> 	channelId: "chat_feed_XXXXXXXXXXXXXX",
> 	deeplinkToPostId: "post_XXXXXXXXXXXXXX",
> });
>
> chatElement.mount("#chat-container");
> ```

> [tab] Swift
>
> ```swift theme={null}
> struct ChatView: View {
>     @State private var targetPostId: String? = nil
>
>     var body: some View {
>         WhopChatView(
>             channelId: "chat_feed_XXXXXXXXXXXXXX",
>             deeplinkToPostId: targetPostId,
>             style: .imessage
>         )
>     }
> }
> ```

### Olay işleme

Profil seçimlerini, bağlantı seçimlerini ve gönderilen mesajları dinlemek için platformunuzun olay geri çağırma fonksiyonunu kullanın.

> [tab] React
>
> | Olay | Ayrıntı | Açıklama |
> | - | - | - |
> | `profileClick` | `{ id: string }` | Kullanıcı bir profil seçtiğinde tetiklenir |
> | `linkClick` | `{ url: string }` | Kullanıcı bir bağlantı seçtiğinde tetiklenir |
> | `messageSent` | `{ id: string, content: string, channelId: string }` | Kullanıcı bir mesaj gönderdiğinde tetiklenir |
> | `experienceClick` | `{ id: string }` | Kullanıcı bir deneyim bahsini seçtiğinde tetiklenir |
>
> ```tsx theme={null}
> import { useCallback, useMemo } from "react";
> import type {
> 	ChatElementEvent,
> 	ChatElementOptions,
> } from "@whop/embedded-components-vanilla-js/types";
>
> const handleChatEvent = useCallback((event: ChatElementEvent) => {
> 	switch (event.type) {
> 		case "profileClick":
> 			console.log("Profile clicked:", event.detail.id);
> 			break;
>
> 		case "linkClick":
> 			console.log("Link clicked:", event.detail.url);
> 			break;
>
> 		case "messageSent":
> 			console.log("Message sent:", event.detail.id, event.detail.content, event.detail.channelId);
> 			break;
>
> 		case "experienceClick":
> 			console.log("Experience clicked:", event.detail.id);
> 			break;
> 	}
> }, []);
>
> const chatOptions: ChatElementOptions = useMemo(() => {
> 	return {
> 		channelId: "chat_feed_XXXXXXXXXXXXXX",
> 		onEvent: handleChatEvent,
> 	};
> }, [handleChatEvent]);
>
> <ChatElement options={chatOptions} />;
> ```

> [tab] Vanilla JS
>
> | Olay | Ayrıntı | Açıklama |
> | - | - | - |
> | `profileClick` | `{ id: string }` | Kullanıcı bir profil seçtiğinde tetiklenir |
> | `linkClick` | `{ url: string }` | Kullanıcı bir bağlantı seçtiğinde tetiklenir |
> | `messageSent` | `{ id: string, content: string, channelId: string }` | Kullanıcı bir mesaj gönderdiğinde tetiklenir |
> | `experienceClick` | `{ id: string }` | Kullanıcı bir deneyim bahsini seçtiğinde tetiklenir |
>
> ```typescript theme={null}
> const chatElement = session.createElement("chat-element", {
> 	channelId: "chat_feed_XXXXXXXXXXXXXX",
> });
>
> chatElement.on("profileClick", (ev) => {
> 	console.log("Profile clicked:", ev.detail.id);
> });
>
> chatElement.on("linkClick", (ev) => {
> 	console.log("Link clicked:", ev.detail.url);
> });
>
> chatElement.on("messageSent", (ev) => {
> 	console.log("Message sent:", ev.detail.id, ev.detail.content, ev.detail.channelId);
> });
>
> chatElement.on("experienceClick", (ev) => {
> 	console.log("Experience clicked:", ev.detail.id);
> });
>
> chatElement.mount("#chat-container");
> ```

> [tab] Swift
>
> | Olay | Ayrıntı | Açıklama |
> | - | - | - |
> | `.profileTap` | `username: String` | Kullanıcı bir profile dokunduğunda tetiklenir |
> | `.urlTap` | `url: String` | Kullanıcı bir bağlantıya dokunduğunda tetiklenir |
> | `.messageSent` | `content: String, messageId: String` | Kullanıcı bir mesaj gönderdiğinde tetiklenir |
>
> ```swift theme={null}
> WhopChatView(
>     channelId: "chat_feed_XXXXXXXXXXXXXX",
>     style: .imessage,
>     onEvent: { event in
>         switch event {
>         case let .profileTap(username):
>             print("Profile tapped: \(username)")
>         case let .urlTap(url):
>             print("URL tapped: \(url)")
>         case let .messageSent(content, messageId):
>             print("Message sent: \(messageId) - \(content)")
>         }
>     }
> )
> ```


## Related topics

- [Destek Sohbetleri](https://docs.whop.com/tr/developer/guides/chat/support-chats.md)
- [Gömülü Sohbet Kanalları](https://docs.whop.com/tr/developer/guides/chat/channels.md)
- [Sohbet Hızlı Başlangıcı](https://docs.whop.com/tr/developer/guides/chat/quickstart.md)
