# Preparation of a knowledge base

Knowledge Base is a collection of files containing information that a bot uses in its responses. The quality of the answer depends not on the number of documents, but on how easy it is to find an unambiguous fact in them.

## What can I add?

Suitable materials that help to advise the client:

- Company description and contacts;
- goods, services and characteristics;
- prices and payment terms;
- delivery, return and guarantee;
- instructions and answers to frequent questions;
- Recording or service rules.

Do not download passwords, tokens, internal secrets and personal data of customers. The bot can use the contents of the connected file in response to the user.

## The main rule: one file - one topic

Do not combine catalog, shipping, warranty and internal instructions into one huge document. Share the information, for example:

- `About the company`;
- `Product catalog`;
- `Delivery and pickup`;
- `Payment and returns`;
- `Warranty`.

So ChatRex is easier to choose the right source, and you – to update the information without accidentally changing another topic.

## How to prepare a text

1. Start with a clear title.
2. Divide the material into short semantic blocks.
3. Use lists for terms and conditions.
4. Sign each column in the tables.
5. Specify units of measure, currency, and terms of validity.
6. Remove repetitions and contradictions.

Example:

```md
# Delivery

## Courier delivery in London

- Price: $10.
- Free for orders over $200.
- Delivery time: 1–2 business days.

## Pickup

- Address: 10 Example Street, London.
- Opening hours: daily from 10:00 to 20:00.
- Orders are held for 3 days.
```

Bad Option: “Delivery is usually fast and sometimes free.” There is no exact cost, term and conditions of free delivery.

## File name and purpose

The title should immediately show the topic: **Delivery and pickup**, not **Document 1**.

In the **Appointment of the file** field, briefly list what is inside and for what questions it is needed.

Example:

> Delivery conditions: regions, terms, cost, free delivery, self-delivery and order shelf life.

Do not use the same purpose for all files. From this description, ChatRex determines which document fits the question.

## Tables

For a catalog or price list, use clear columns:

| Service | Price | Duration | Note |
|---|---:|---:|---|
| Consultation | $30 | 30 minutes | By appointment |
| Procedure A | $100 | 60 minutes | Consultation required |

If there are several tables or sheets in the file, explain their purpose at the beginning of the document.

## Rules for a system prompt

Explain to the bot when to access the files and what to do if there is no answer.

```md
## Working with the knowledge base

Use the knowledge base for questions about the company, services, payment,
delivery, returns, and warranty.

Answer only from the information you find. Do not invent prices,
dates, addresses, or conditions. If there is no exact answer, say so
and offer to hand the question over to a team member.
```

If prices or schedules need to come from integration, explicitly forbid taking them from files. The separation of sources is described in detail in the article [**Interaction of a prompt with a knowledge base**](<../prompts/prompt-and-knowledge-base.md>).

## Post-load check

Ask the bot at least five questions:

1. direct question, the answer to which is in the file;
2. question in other words;
3. a question for which two documents are suitable;
4. an issue with an outdated or missing fact;
5. off-topic question.

Check that the bot uses the correct source, does not mix the terms and honestly reports the lack of data.

## What to do next

Create a repository and add prepared documents according to the instructions [**Manage storage and files**](<./manage-storages-and-files.md>).

!!!tip
After changing the price, address, or rule, update the file and repeat the related test questions. An outdated document leads to an outdated answer.
!!!
