> 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/ai/overview.md).

# AI overview

DNotifier **AI** covers managed prompts, multi-turn **sessions**, **knowledge-base (RAG)**, and **semantic search** — all through official SDK methods like `sendAI` and `search`. AI calls are **request/response**: use **`transport: "http"`** (or `"http"` in Dart) so responses return directly from the async method.

{% hint style="info" %}
**Transport:** AI, RAG, and workflow APIs are designed for **HTTP transport**. WebSocket is for realtime 1:1 messaging — not for AI/RAG request/response flows.
{% endhint %}

## What you get

| Capability                 | SDK methods                                                                       | Purpose                                                                                            |
| -------------------------- | --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| **Simple prompts**         | `sendAI`                                                                          | One-shot questions and instructions                                                                |
| **Providers / models**     | `sendAI({ provider, model })`                                                     | Pick OpenAI, Anthropic, Gemini, etc. after you wire them in the portal                             |
| **Chat-style messages**    | `sendAI` with `messages[]`                                                        | System/user/assistant roles, optional RAG                                                          |
| **Sessions**               | `sendAI` + `sessionId`                                                            | Continue a conversation across turns                                                               |
| **AI history**             | `saveHistory` + `fetchAIHistory`, `deleteAIHistoryMessage`                        | Store and load AI turns for your product UI                                                        |
| **Session logging**        | `logs: true` on `DNotifier`                                                       | Dashboard Logs telemetry — see [Observability](/product-docs/observability/observability.md)       |
| **Workflow observability** | `observability: true` on `Workflow`                                               | Dashboard Workflows step graph                                                                     |
| **Knowledge base**         | `addDocument`, `updateDocument`, `getDocument`, `listDocuments`, `deleteDocument` | Index content for RAG                                                                              |
| **Semantic search**        | `search`                                                                          | Vector similarity over indexed documents                                                           |
| **Workflows**              | `defineAgent`, `Workflow`, `runWorkflow`                                          | Multi-step AI pipelines — see [Workflows overview](/product-docs/workflows-and-agents/overview.md) |

## Architecture

```
  Your app (HTTP transport)
         │
         │  connect() → auth token + plan limits
         │
         ├─ sendAI ──────────────► AI runtime → response JSON
         ├─ search ──────────────► vector index → ranked hits
         ├─ addDocument / … ─────► knowledge base
         └─ runWorkflow ─────────► agents + observability
```

Unlike realtime messaging, AI responses do **not** arrive on `onMessage`. Each method returns (or resolves) with the server payload.

## Prerequisites

1. **App credentials** — `appId` and `secret` from [app.dnotifier.com](https://app.dnotifier.com). See [Credentials](/product-docs/getting-started/credentials.md).
2. **AI enabled on plan** — after `connect()`, check `notifier.aiEnabled` and `getPlanLimits()`.
3. **HTTP transport** — see [Choose your transport](/product-docs/getting-started/choose-transport.md).

```js
const notifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_SECRET,
  transport: "http",
  userId: "user-123",
  onConnected: () => {},
  onMessage: () => {},
  onDisconnected: () => {},
});

await notifier.connect();

if (!notifier.aiEnabled) {
  throw new Error("AI is not enabled for this plan");
}
```

## Topic guides

| Topic                                                        | Hub page                                                                                                                         |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| Send a prompt                                                | [send-prompt/README.md](/product-docs/ai/send-prompt.md)                                                                         |
| Providers & models                                           | [multi-models/README.md](/product-docs/ai/multi-models.md)                                                                       |
| Chat-style messages                                          | [chat-style-messages/README.md](/product-docs/ai/chat-style-messages.md)                                                         |
| Sessions (`sessionId`)                                       | [sessions/README.md](/product-docs/ai/sessions.md)                                                                               |
| AI history                                                   | [ai-history/README.md](/product-docs/ai/ai-history.md)                                                                           |
| Session logging (`logs: true`)                               | [session-logging/README.md](/product-docs/ai/session-logging.md) · [Observability](/product-docs/observability/observability.md) |
| Observability hub (`logs` / `saveHistory` / `observability`) | [observability/README.md](/product-docs/observability/observability.md)                                                          |
| Knowledge base (RAG)                                         | [knowledge-base-overview.md](/product-docs/ai/knowledge-base-overview.md)                                                        |
| Manage documents                                             | [manage-documents/README.md](/product-docs/ai/manage-documents.md)                                                               |
| Semantic search                                              | [semantic-search/README.md](/product-docs/ai/semantic-search.md)                                                                 |
| Example: AI assistant                                        | [example-ai-assistant/README.md](/product-docs/ai/example-ai-assistant.md)                                                       |
| Example: RAG Q\&A bot                                        | [example-rag-bot/README.md](/product-docs/ai/example-rag-bot.md)                                                                 |

## Typical integration patterns

### Backend API route

A Node.js or Dart server connects with HTTP, calls `sendAI`, and returns JSON to your frontend. The frontend chat UI can use WebSocket separately for human-to-human messaging.

### RAG assistant

1. Index documents with `addDocument` (batch jobs or admin tools).
2. Answer questions with `sendAI({ message: { useKnowledgeBase: true, messages: [...] } })` or combine `search` + `sendAI` in a [workflow](/product-docs/workflows-and-agents/overview.md).

### Multi-turn support bot

1. First `sendAI` call creates a session id.
2. Pass `sessionId` on follow-up calls for the same ticket.
3. Enable `logs: true` in production for dashboard auditing.

## Plan limits

After `connect()`, call `getPlanLimits()`:

| Field                   | Meaning                     |
| ----------------------- | --------------------------- |
| `aiEnabled`             | Whether AI is available     |
| `maxAIRequestsPerMonth` | Monthly AI request cap      |
| `maxAIWordsPerMonth`    | Monthly word/token budget   |
| `knowledgeBaseMaxWords` | Total indexed content limit |

→ [Pricing & plans](/product-docs/platform-overview/pricing.md)

## Next steps

* [Send a prompt](/product-docs/ai/send-prompt.md)
* [Providers & models](/product-docs/ai/multi-models.md)
* [Tutorials](/product-docs/tutorials/tutorials.md)
* [Knowledge base overview](/product-docs/ai/knowledge-base-overview.md)
* [Workflows overview](/product-docs/workflows-and-agents/overview.md)
