> ## Documentation Index
> Fetch the complete documentation index at: https://docs.deflect.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Base

> Train your agent with your own documentation, files, and website content

The **Knowledge Base** is how your agent answers with **your** facts: uploaded files, structured docs, and pages from **websites** you allow. Answers can include **source attribution** so visitors see where information came from.

## Two steps: add content, then link to an agent

| Step               | Where                                                        | What you do                                                                                                                          |
| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| **1. Add content** | **Knowledge Base** in the dashboard sidebar                  | Upload **PDF** and **Markdown**, and/or add **website / web crawl** sources. Processing and status appear here—not inside the agent. |
| **2. Link**        | **Agent editor** → **Knowledge** (or **Add knowledge base**) | Pick the knowledge base(s) you already created so this agent can search them.                                                        |

You can link **multiple** knowledge bases to one agent. Removing a link from an agent does **not** delete the org’s knowledge base; it only stops this agent from using it.

## File uploads (PDF and Markdown)

1. Go to **Knowledge Base** in the sidebar (not the Agent editor). **Upload** PDF or Markdown there.
2. The system **extracts text**, splits it into searchable **chunks**, and indexes them for retrieval.
3. Wait until processing finishes before linking and testing—large PDFs can take longer.
4. Open the **Agent editor** → **Knowledge** and **link** this knowledge base to the agent(s) that should use it.

**Tips**

* Use clear headings in Markdown so chunks stay meaningful.
* For citations, add a **metadata** block to Markdown files (see [Source attribution](#source-attribution) below).

## Website and URL sources (web crawling)

Configure **web crawl** and URLs in the **Knowledge Base** section first, same as files. After the source is **ready**, link that knowledge base to your agent in the **Agent editor** so answers can use the crawled pages.

### What you can configure (typical options)

| Concept                    | What it means for you                                                                                                         |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **Single URL or sitemap**  | Start from one page or from a **sitemap.xml** to discover many URLs at once.                                                  |
| **Include / exclude**      | Limit crawling to paths that matter (e.g. `/docs/`) and skip `/blog/drafts/` or login pages.                                  |
| **Sync schedule**          | **Daily**, **weekly**, or **monthly** refresh so answers track site updates without manual re-uploads.                        |
| **JavaScript-heavy sites** | Dynamic pages can be crawled where supported—simple “fetch HTML only” scrapers often miss this content.                       |
| **Auto-discover on sync**  | When you refresh a source, related linked pages can be proposed or ingested so you spend less time pasting every URL by hand. |
| **Status and search**      | See which pages imported, which were **skipped**, and **search** the list of crawled URLs when debugging a missing page.      |

**Operational notes**

* Very large sites may be subject to **per-organization crawl limits** and **pagination** in the UI so you can browse long URL lists.
* After a successful sync, search engines may be notified of changes where that feature is enabled—useful when public URLs change often.

If you only need a **one-off** import, you can still add a single URL without turning on aggressive schedules.

## Source attribution

When the agent answers from your knowledge base, it can **cite** sources. That builds trust and helps visitors verify facts.

### Adding metadata to Markdown

At the end of your Markdown file, add a `## metadata:` heading followed by a JSON object (exact layout can depend on your Markdown tooling; the goal is `sourceURL` and `title` for citations):

```json theme={null}
{
  "sourceURL": "https://docs.yoursite.com/article-1",
  "title": "How to Configure Settings"
}
```

## How retrieval works (RAG)

We use **Retrieval-Augmented Generation (RAG)**:

1. **User asks** — e.g. “How do I reset my password?”
2. **Search** — The system searches your knowledge (files + web chunks) for the most relevant snippets.
3. **Augment** — Those snippets are added to the model prompt with guardrails.
4. **Generate** — The model answers using that context—reducing hallucinations relative to a blank model with no knowledge.

## Related guides

* **[Launch an agent on your website](/launch-on-your-website)** — Knowledge Base first, then link, before go-live.
* **[Create chat agent](/create-chat-agent)** — Linking knowledge bases from the agent editor.
* **[Widget installation](/widget-installation)** — The widget does not change when you add knowledge; retest answers after big KB updates.
