> 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/platform-overview/use-cases/combined.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Combined use cases

Production apps rarely use a single capability in isolation. This page describes patterns that **combine AI**, **chat**, and **realtime 1:1 messaging** — plus **workflows** where multi-step logic matters.

{% hint style="success" %}
Each capability stays distinct in the SDK: **realtime communication** delivers messages; **chat** adds conversation history; **AI** powers intelligence; **workflows** orchestrate agents. Combined use cases show how they connect in architecture — not a separate product module.
{% endhint %}

***

## Reference architecture

```
┌──────────────┐     send / onMessage      ┌──────────────┐
│   Client UI  │ ◄────────────────────────► │   DNotifier  │
│  chat + live │                            │   realtime   │
└──────┬───────┘                            └──────▲───────┘
       │ sendAI / workflows                           │
       ▼                                              │ HTTP send
┌──────────────┐                            ┌────────┴───────┐
│  AI + RAG    │                            │ Your backend   │
│  sessions    │                            │ jobs, webhooks │
└──────────────┘                            └────────────────┘
```

***

## Customer support bot with live handoff

The most common combined pattern: **AI first line**, **human takeover**, **realtime chat** throughout.

### Components

| Layer             | Capability      | Role                                               |
| ----------------- | --------------- | -------------------------------------------------- |
| **Widget UI**     | Chat + realtime | User types messages; sees bot and agent replies    |
| **Bot user ID**   | Chat            | `bot-support` receives and sends via `send`        |
| **AI**            | `sendAI` + RAG  | Answers from knowledge base when confidence high   |
| **Workflow**      | Agents          | Classify intent, detect escalation phrases         |
| **Agent console** | Chat            | Human connects as `agent-{id}`; messages route 1:1 |
| **Live signals**  | Realtime        | `{ type: "agent-joined" }`, typing, queue position |

### Flow

1. User opens support widget → client connects; sends message to `bot-support`.
2. Workflow runs intent + RAG agent; bot sends answer via `send` to user's ID.
3. User says "talk to a person" → workflow sets state; system message via realtime to user.
4. Backend assigns agent; messages flow user ID ↔ agent ID (chat history preserved).
5. Agent sees prior AI turns from `fetchChatHistory`.

{% hint style="info" %}
Use **one thread** (same pair of IDs) for bot and human phases so history stays continuous. Switch `receiverId` routing in your backend when handoff occurs.
{% endhint %}

→ [Chat use cases](https://dnotifier.gitbook.io/product-docs/platform-overview/use-cases/chat.md) · [AI use cases](https://dnotifier.gitbook.io/product-docs/platform-overview/use-cases/ai.md) · [Combined handoff patterns](https://dnotifier.gitbook.io/product-docs/chat/ui-patterns.md)

***

## In-app copilot with live suggestions

Productivity apps embed an AI panel that also **pushes** suggestions when the backend completes analysis.

### Components

| Layer        | Role                                                                   |
| ------------ | ---------------------------------------------------------------------- |
| **AI panel** | `sendAI` for Q\&A about document content                               |
| **RAG**      | Documents indexed per workspace                                        |
| **Realtime** | Server pushes `{ type: "suggestion", items }` when batch job completes |
| **Workflow** | Long analysis split into steps with progress                           |

### Flow

1. User asks copilot about spreadsheet → `sendAI` with session.
2. User clicks "Analyze column" → backend workflow runs.
3. Worker sends progress via realtime to user ID.
4. On complete, worker sends structured suggestions; UI merges with chat panel.

→ [Live progress tracking](https://dnotifier.gitbook.io/product-docs/platform-overview/use-cases/realtime-communication.md#live-progress-tracking)

***

## Social app with AI moderation assist

Messaging with optional AI for spam detection, reply suggestions, or safety — without replacing user-to-user chat.

### Components

| Layer                  | Role                                                                             |
| ---------------------- | -------------------------------------------------------------------------------- |
| **DM chat**            | User A ↔ User B via `send`                                                       |
| **Moderation service** | Connected as `svc-moderation`; receives copy via your backend or multi-send      |
| **AI workflow**        | Classify toxicity; return allow / flag / block                                   |
| **Realtime**           | Notify sender if message blocked; alert ops via directed message to ops user IDs |

Human messages stay in **chat**. AI runs in **workflows** on the side — not as a public broadcast layer.

***

## Marketplace: buyer–seller chat + AI listing helper

Buyers message sellers; AI helps draft listings or answers product questions from catalog RAG.

| Phase                | Capability                                                      |
| -------------------- | --------------------------------------------------------------- |
| **Listing creation** | AI + RAG over seller inventory documents                        |
| **Negotiation**      | Chat between buyer and seller IDs                               |
| **Alerts**           | Realtime notify seller of new message `{ type: "new-message" }` |
| **Smart replies**    | Optional `sendAI` suggestions seller approves before `send`     |

***

## Field service: technician chat + workflow dispatch

Dispatch AI parses job notes; technicians get realtime job updates; supervisor chat for escalation.

1. **Workflow** extracts priority and skills from job text.
2. **Realtime** sends assignment to technician's `userId`.
3. **Chat** between technician and supervisor for edge cases.
4. **AI** summarizes completed job notes into CRM via `sendAI`.

***

## Design principles for combined apps

### 1. Separate IDs and transports deliberately

| Need               | Transport      | Typical API                 |
| ------------------ | -------------- | --------------------------- |
| AI prompt/response | HTTP           | `sendAI`                    |
| Live chat          | WebSocket      | `send`, `onMessage`         |
| Server push        | HTTP RPC or WS | Server send to `receiverId` |

Same user can use one `userId` for both connections — or split browser tabs across WS (chat) and HTTP (AI-only panels).

→ [Choose your transport](https://dnotifier.gitbook.io/product-docs/getting-started/choose-transport.md)

### 2. Use workflows at boundaries

Put **classification, RAG, and escalation** in workflows — keep UI thin. Observability helps debug handoff bugs in production.

→ [Workflow observability](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)

### 3. Directed messaging for live events

Queue position, agent joined, export ready — send to **specific user IDs**, not shared broadcast channels.

→ [Realtime communication use cases](https://dnotifier.gitbook.io/product-docs/platform-overview/use-cases/realtime-communication.md)

### 4. Respect plan limits

Combined apps consume **messages**, **AI requests**, and **knowledge base words**. Surface limits from `getPlanLimits()`.

→ [Pricing & plans](https://dnotifier.gitbook.io/product-docs/platform-overview/pricing.md)

***

## Implementation roadmap

| Stage | Build                                             |
| ----- | ------------------------------------------------- |
| **1** | Realtime connect + `send` between user and bot ID |
| **2** | `sendAI` + knowledge base for bot replies         |
| **3** | `fetchChatHistory` for thread persistence         |
| **4** | Workflow for intent and escalation                |
| **5** | Agent handoff routing + live status messages      |
| **6** | Session logging and workflow observability        |

→ [Developer integration guide](https://dnotifier.gitbook.io/product-docs/platform-overview/developer-integration-guide.md)

***

## Related examples

| Example                                                                                            | Description     |
| -------------------------------------------------------------------------------------------------- | --------------- |
| [1:1 chat](https://dnotifier.gitbook.io/product-docs/examples/one-to-one-chat.md)                  | Chat foundation |
| [AI Q\&A](https://dnotifier.gitbook.io/product-docs/examples/ai-qa.md)                             | AI foundation   |
| [RAG assistant](https://dnotifier.gitbook.io/product-docs/examples/rag-assistant.md)               | RAG + AI        |
| [Multi-agent workflow](https://dnotifier.gitbook.io/product-docs/examples/multi-agent-workflow.md) | Orchestration   |
