# Knowledge Base

Train your chatbot with prompts, Q&A pairs, files and web pages

The knowledge base is what makes your chatbot smart. It contains the system prompt, Q&A pairs, and documents the bot uses to answer questions.

## Knowledge types

| Type | Description | Best for |
|------|-------------|----------|
| **Prompt** | The agent's system prompt: instructions and information about your business that are part of every reply | Describing what the bot does, how it should work and what it must always know |
| **Q&A** | Question and answer pairs | Common customer questions with specific answers |
| **File** | An uploaded PDF, DOCX, TXT or Markdown file (up to 10 MB) | Price lists, policies, manuals |
| **Web page** | One public HTTPS page; links on it are not followed | Product, FAQ or pricing pages on your site |

Q&A, files and web pages depend on your plan; if your plan doesn't include them, the panels show an upgrade prompt.

## How the agent uses its knowledge

The **system prompt** is always part of the agent's instructions: it applies to every message, in full.

Everything else in the knowledge base — Q&A pairs, files and web pages — is split into short passages and indexed by meaning. For each customer message, the agent receives the three passages that match it best, and can search the knowledge base again with a more focused question when those aren't enough. It answers facts only from these passages; if nothing matches, it says it will check rather than invent an answer.

This means the agent reads the parts of your Q&A, files and web pages that relate to the question, not all of them every time. Two things follow:

- **Instructions that must always apply belong in the system prompt** or in **Behavioral Rules** on the Persona tab (see [Persona and Behaviour](/en/chatbots/persona-and-behaviour)), not in a Q&A pair or document. Both are followed on every message, as are the agent's **Role Name** and **Description**.
- **Write each passage so it stands on its own.** A Q&A pair or a section of a document that names its subject ("Shipping to Bali takes 3–5 days") is found more reliably than one that relies on what came before it.

## Managing the knowledge base

Everything lives in the **Knowledge** tab. Go to **AI Agents → [Your Bot] → Knowledge**. The header of the agent's page shows how many knowledge items and Q&A pairs it has.

### Editing the system prompt

Each agent has one system prompt.

1. In the **System Prompts** panel, write the bot's instructions in the editor
2. Click **Save Prompt**

To have it drafted for you, click **Generate with AI**, describe the role, tone and constraints in **Generate system prompt** (at least a sentence), and click **Generate**. The draft replaces the current prompt after a few seconds; review it and edit as needed.

### Adding Q&A pairs

1. In the **Q&A Knowledge** panel, click **Add Q&A**
2. Enter a **Title**, the answer in **Content**, and the **Question** it answers
3. Leave **Enabled** on, then click **Create Knowledge**

Or click **Generate with AI** in the dialog, describe the topic, and let the AI draft a pair; while it is being written the row shows **Generating**. Click **Switch to manual** to go back to typing it yourself.

Each row shows whether the pair is **Enabled** or **Disabled**. Use the edit and delete buttons on a row to change or remove it. A disabled pair is kept but the agent doesn't use it.

### Adding files and web pages

1. In the **Files and web pages** panel, click **Upload file** or **Add web page**
2. Choose the file (drag it in, or **Choose file**), or enter the **Page address**
3. Optionally give it a **Title (optional)** — it defaults to the file name or the page title — then click **Upload** or **Add page**

Files must be PDF, DOCX, TXT or Markdown, not empty, and at most 10 MB. A page address must be public and start with `https://`; if you leave out the scheme, `https://` is added for you. An `http://` address is refused.

The text is read in the background. Each source shows its status:

| Status | Meaning |
|--------|---------|
| **Queued** | Waiting to be read |
| **Reading** | The text is being extracted and indexed |
| **Ready** | The agent can use it. The row shows how many characters were read |
| **Failed** | It couldn't be read — the reason is shown under the title |

### Viewing, refreshing and deleting sources

Each source row has three actions:

- **Open** — see the source, its status, its length and the **Extracted text**. Here you can rename it or turn **Enabled** off so the agent stops using it, then click **Update Knowledge**. The extracted text can't be edited in Qwetty — change the file or page, then refresh.
- **Refresh** — read the file or page again, for example after you updated the page on your website.
- **Delete** — remove the source. The agent stops using it straight away.

### When a source fails

| Message | What to do |
|---------|------------|
| No text found in the file | A scanned PDF has only images. Upload a version with selectable text |
| The file couldn't be opened | It may be damaged or password-protected. Save an unprotected copy and upload it |
| The text is longer than 300,000 characters | Split it into smaller files |
| The uploaded file is gone | Delete the entry and upload the file again |
| That address isn't a public web page | Use an address that anyone can open without signing in |
| The page couldn't be reached / answered with an HTTP error | Check the address, then refresh |
| The page redirects too many times, or is too large to read | Point to a simpler page, or save its content as a file |
| That address isn't a web page | It is a document such as a PDF. Download it and upload it as a file |
| No readable text found on the page | The page may build its content with scripts. Save the content as a file instead |
| The text was read but couldn't be indexed | Refresh to try again |

## Best practices

- **Be specific** — The more precise your Q&A pairs, the better the bot responds
- **Keep prompts and Q&A up to date** — Outdated information leads to wrong answers; refresh web pages after you change them
- **Cover common questions first** — Start with your most frequently asked questions, then work through **Top Unanswered Questions** in [Analytics](/en/chatbots/testing-and-analytics)
- **Test regularly** — Use the **Testing** playground; its **Debug** view shows which passages the agent used

## Next steps

- [Persona and Behaviour](/en/chatbots/persona-and-behaviour) — Rules the agent always follows
- [Testing and Analytics](/en/chatbots/testing-and-analytics) — Check what the agent retrieves
- [Assigning to Channels](/en/chatbots/assigning-to-channels) — Deploy the bot
