> 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/example-rag-bot.md).

# Build a RAG Q\&A bot

A **retrieval-augmented** support bot: index help articles, then answer user questions grounded in that content.

## Pipeline

```
  1. Indexing (one-time / on publish)
     addDocument × N

  2. User question
     sendAI({ useKnowledgeBase: true, messages: [...] })
     — or —
     search → sendAI with injected context

  3. Optional: sessionId for follow-ups
```

{% hint style="info" %}
All steps use **`transport: "http"`**.
{% endhint %}

## Two retrieval strategies

| Strategy          | Code                                        |
| ----------------- | ------------------------------------------- |
| **Automatic RAG** | `useKnowledgeBase: true` in `sendAI`        |
| **Manual RAG**    | `search` then build system prompt with hits |

The automatic path is simpler. Manual search gives you control over which chunks appear in the prompt.

## Language guides

| Language                | Guide                                                                                 |
| ----------------------- | ------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](/product-docs/ai/example-rag-bot/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](/product-docs/ai/example-rag-bot/dart-flutter.md)                   |

## Related

* [**Knowledge base overview**](/product-docs/ai/knowledge-base-overview.md)
* [**Semantic search**](/product-docs/ai/semantic-search.md)
* [**Intent router workflow**](/product-docs/workflows-and-agents/example-intent-router.md) — Route doc questions vs general chat
