> 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/chat-style-messages.md).

# Chat-style AI messages

For richer prompts, pass a **`messages`** array with `role` and `content` fields — the same shape used by chat-completion APIs. Optionally set **`useKnowledgeBase: true`** to ground answers in your indexed documents.

## When to use chat-style vs simple text

| Approach    | Message shape                                 | Best for                                              |
| ----------- | --------------------------------------------- | ----------------------------------------------------- |
| Simple text | `{ text: "..." }`                             | Quick one-liners                                      |
| Chat-style  | `{ messages: [{ role, content }] }`           | System prompts, few-shot examples, multi-role context |
| Chat + RAG  | `{ useKnowledgeBase: true, messages: [...] }` | Support bots grounded in your knowledge base          |

## Message roles

| Role        | Typical use                                |
| ----------- | ------------------------------------------ |
| `system`    | Persona, rules, output format              |
| `user`      | End-user question or input                 |
| `assistant` | Prior model turns (for replay or few-shot) |

```js
message: {
  useKnowledgeBase: false,
  messages: [
    { role: "system", content: "You are a helpful support agent. Be concise." },
    { role: "user", content: "How do I reset my password?" },
  ],
}
```

## `useKnowledgeBase`

When `true`, DNotifier retrieves relevant knowledge-base chunks and injects them into the prompt before calling the model.

{% hint style="info" %}
Index content first with `addDocument`. Without documents, `useKnowledgeBase` still works but may return generic answers.
{% endhint %}

## `saveHistory`

Default is `true`. Set `false` for classification, routing, or workflow steps you do not want in user-visible history.

## Transport

Use **`transport: "http"`** for all `sendAI` calls.

## Language guides

| Language                | Guide                                                                                     |
| ----------------------- | ----------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](/product-docs/ai/chat-style-messages/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](/product-docs/ai/chat-style-messages/dart-flutter.md)                   |

## Next steps

* [**Knowledge base overview**](/product-docs/ai/knowledge-base-overview.md) — Index documents for RAG
* [**Sessions**](/product-docs/ai/sessions.md) — Continue the same conversation with `sessionId`
* [**Example: RAG bot**](/product-docs/ai/example-rag-bot.md) — Full Q\&A flow
