> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/chat/overview.md).

# Chat overview

**Chat** is a **use case** built on DNotifier's **realtime 1:1 messaging** layer. You send messages between user IDs, optionally persist history, and build conversation UIs — for support, social, team collaboration, and in-app messaging.

{% hint style="info" %}
Chat is **not** a separate transport. It uses `send()` for delivery and chat-specific APIs for history. For raw live updates without conversation semantics, see [Realtime communication overview](/product-docs/realtime-communication/overview.md).
{% endhint %}

***

## Chat vs realtime communication

| Aspect           | Realtime communication               | Chat                                    |
| ---------------- | ------------------------------------ | --------------------------------------- |
| **Purpose**      | Deliver payloads to IDs              | Human (or bot) conversations            |
| **History**      | Optional per message (`saveHistory`) | Fetch thread via `fetchChatHistory`     |
| **UX**           | Events, metrics, notifications       | Threads, bubbles, read state (your UI)  |
| **Participants** | Any sender/receiver IDs              | Typically paired user IDs or user ↔ bot |

Both use the same **`senderId` / `receiverId`** addressing model over WebSocket.

***

## Core building blocks

```
  connect (ws)
       │
       ├── fetchChatHistory on thread open
       │
       ├── send({ data, saveHistory: true })  → live delivery + persistence
       │
       ├── onMessage  → append incoming messages to UI
       │
       └── deleteChatHistoryMessage  → moderation / user delete
```

| API                          | Role                                                        |
| ---------------------------- | ----------------------------------------------------------- |
| `send()`                     | Deliver message to peer; persist when `saveHistory` is true |
| `fetchChatHistory()`         | Load past messages for a thread                             |
| `deleteChatHistoryMessage()` | Remove a stored message                                     |
| `onMessage`                  | Receive live messages and history responses                 |

***

## Topics in this section

| Topic                                                                   | Description                    |
| ----------------------------------------------------------------------- | ------------------------------ |
| [Building 1:1 chat](/product-docs/chat/building-one-to-one-chat.md)     | Connect, send, receive pattern |
| [Chat history](/product-docs/chat/chat-history.md)                      | `fetchChatHistory`             |
| [Delete chat messages](/product-docs/chat/delete-messages.md)           | `deleteChatHistoryMessage`     |
| [Save history flag](/product-docs/chat/save-history.md)                 | Per-message persistence        |
| [Chat UI patterns](/product-docs/chat/ui-patterns.md)                   | Threads, bubbles, typing       |
| [Example: Minimal chat app](/product-docs/chat/example-minimal-chat.md) | Full walkthrough               |

***

## Prerequisites

* [Your first connection](/product-docs/getting-started/first-connection.md) with `transport: "ws"`
* [Your first message](/product-docs/getting-started/first-message.md)
* [Understanding messages](/product-docs/getting-started/understanding-messages.md)

***

## Use cases

For product-oriented chat scenarios (support, social, team tools), see [Chat use cases](/product-docs/platform-overview/use-cases/chat.md).

***

## Chat vs AI chat

| Type                       | API                  | Purpose             |
| -------------------------- | -------------------- | ------------------- |
| **User ↔ user (or agent)** | `send`, chat history | Human conversations |
| **User ↔ AI assistant**    | `sendAI`, AI history | LLM sessions, RAG   |

You can embed both in one app with separate tabs and history backends.

→ [AI overview](/product-docs/ai/overview.md)
