Home · Blog · How to collect a knowledge base for an AI agent: text, structure, tests
How to collect a knowledge base for an AI agent: text, structure, tests
“Training an AI agent” in CHBT means giving it business materials to answer, rather than retraining the model. In the “AI Agents” section, add text, a link page or a PDF, DOCX, TXT, MD, CSV file: the knowledge base that the neural network uses is collected from these sources. The quality of the answers is almost entirely determined by what and how it got into the text. Below is the working order: where to get the material from, how to structure it, what wording breaks the answers, what to prohibit, how to run a test chat of 20 questions and according to what schedule to supplement the database. Only the text of PDF and DOCX files gets into the base, and a link loads one page, not the whole site - this affects the approach.
What does the agent do with your text?
In CHBT, the AI agent does not have “training” in the usual sense: the model does not retrain on your data, but receives it with each response. In the section "AI Agents" you fill out three fields, and all three go into the model along with the client’s question:
- Role — instructions on who the agent is, what he says and what he doesn’t do.
- Knowledge base — free text: company, prices, conditions, answers to frequently asked questions.
- History of the conversation — up to 10 latest messages, are inserted automatically (the longer the database, the fewer of them fit).
Two practical conclusions follow from this. First: editing the database takes effect immediately - the price is corrected, saved, the next response is with the new one. Second: the agent does not search the database, like a search engine does on a website, but reads it entirely with each response. This means that the database should contain what is asked most often, and should not include anything that gets in the way: advertising texts, a three-page company history, internal regulations.
How the answer works in detail, which model answers and how much one answer costs - in the general article about a chatbot with a neural network using a knowledge base. Here we are talking only about the base text.
Where to get the material from: inventory in the evening
The knowledge base in CHBT is text. You can upload PDF and DOCX (up to 15 MB), but only their text is extracted: images and scans without a text layer are not recognized, and password-protected PDFs and old .doc files are not accepted. A link loads one page, not the whole site. So don’t upload everything: whatever reaches the agent is worth reading with your own eyes and editing. A price list from a 40-page PDF wouldn’t fit into the base in its entirety anyway - copy out the lines you need.
Sources that provide the bulk of the benefits:
- Site pages, which open before purchasing: “About us” (two or three sentences, no more), “Prices”, “Delivery and payment”, “Returns”, “Contacts”, “Questions and answers”. Copy the text, not the page description.
- Price list - in the form of lines “service - price - term”, without registration.
- Correspondence of managers for the last month. Open “Conversations” in CHBT or chats in the messenger and write down 30 questions that are asked most often, along with the answers that managers actually give. This is more valuable than any official page: in the questions - the wording of the clients, in the answers - what works.
- Regulations - only the part that concerns the client: deadlines, what needs to be brought, how to sign up, how to cancel.
- Offer or contract - only the items that are asked about: warranty, returns, responsibility for delivery. Not the entire document.
What should not be in the database: personal data of clients, internal purchase prices, instructions for employees, any information “not for the client.” The agent responds to the client, and everything that is in the database can end up in the answer if the question is unsuccessful.
Structure: sections instead of continuous text
The model is better able to navigate text with explicit headings. Divide the database into 6-8 sections and sign them with simple lines in upper case or with a hash - the design is not important, but a clear boundary between topics is important. Example snippet:
== ABOUT THE COMPANY ==
Studio "Svet" - repair and replacement of electrical wiring in apartments in St. Petersburg. We have been working since 2015, departure within 2 days.
== PRICES ==
Replacement of the socket - 900 ₽ per point, term - on the day of departure.
Complete replacement of wiring in a one-room apartment - from 65,000 ₽, period - 5-7 working days.
== FREQUENTLY QUESTIONS ==
Question: Do you travel to the Leningrad region?
Answer: Yes, within 30 km from the Ring Road, departure +1500 ₽.
Working order of sections:
- About the company - 2-3 sentences: what you do, where, since what year.
- Products or services with prices - one line per position.
- Terms - delivery, payment, return, guarantee, work schedule.
- How to place an order or sign up - step by step, with what you need from the client.
- Frequently asked questions—question-answer pairs—more on them below.
- What we don't do is explicitly list failures.
- How to contact a person - phone number, operator opening hours.
Set prices and conditions higher, keep “about the company” short: the agent needs facts to answer, not a presentation.
Formulations that the agent will not misinterpret
Before writing off an incorrect answer as a “model glitch,” check the database: the agent responds according to its text, and the ambiguity in the database turns into an incorrect answer. Rules to help avoid this:
- One statement - one sentence. “Delivery within the city is 300 ₽, outside the ring road - 300 ₽ plus 30 ₽ per km” instead of a paragraph with reservations.
- Numbers with units and conditions. Not “fast”, but “3 working days”. Not “inexpensive”, but “from 1200 ₽”. If the price depends on something, write what it depends on: “price per m², minimum order 10 m².”
- No pronouns through the paragraph. “He”, “this service”, “this plan” the model can easily link to a neighboring offer. Repeat the name.
- The client's words next to your terms. In the price list for “addressed delivery”, the client asks “will you deliver it by courier?” Write: “Address delivery (by courier to the door) - 300 ₽.”
- Refusals are obvious. “We do not do urgent repairs on the same day,” “We do not accept cash.” Without an explicit refusal, the agent can assume that the service is available.
- No advertising epithets. “The best craftsmen in the city” will migrate from the database to the answer and will sound like intrusive advertising. The facts are more convincing.
- Relevance date at the beginning of the database: “Prices are valid from September 1, 2026.” The agent will be able to refer to it, and you will remember to update it.
Separately about the phrase “check with the manager.” If it appears after each item, the agent will send any question to the manager, and the meaning will be lost. Place it only where the answer is truly individual, and support it with the “didn’t understand” → “Operator” port in the script, and not just with text.
Question-answer pairs: how to write
The Frequently Asked Questions section is the most valuable part of the database because it is closest to how people actually ask. The format is simple: the line “Question:”, the line “Answer:”, an empty line between pairs.
- Question - in the client's words, including conversational options. If the same question is asked differently, list the options separated by commas in one pair: “Question: How long should I wait for my order? When will you deliver? What are the delivery times?
- The answer is 1–3 sentences. The first is the essence, the second is the condition or exception, the third is the next step (“To register, write the address and a convenient day”).
- Group by topic: order, delivery, payment, return, guarantee. Within the topic - from frequent to rare.
- Do not duplicate the “Prices” section. If the answer to the question is price, duplicate one number, but not the entire table: repetitions are the main source of discrepancies when you update one place and forget the second.
To start, 15–25 short pairs are enough: together with prices and conditions, the entire base should be within 15,000 characters. If the pairs do not fit, this is a signal to move some of the topics to a separate agent or to the script’s button menu. Pairs that are asked less than once a month do not need to be written: the agent will pass the conversation on to them to the operator, and this is a normal outcome.
Prohibitions: what to write in the role and what to write in the database
The base answers the question “what is true,” the role answers the question “how to behave.” You shouldn’t mix them: the model perceives behavioral instructions in the database weaker, and the facts in the role are lost among the rules.
Into the role (the “Person” field in the agent card is the role) - 6-10 short lines:
- who is the agent: “consultant of the Svet studio”, not “AI assistant”;
- language and tone: “in Russian, in ‘you’, briefly, without emoticons”;
- source: “answer only from the knowledge base”;
- behavior in the absence of an answer and when asking to call a person: “if the answer is not in the database or a person is asked, write: “Unfortunately, I have no information about this - contact the operator, I’ll pass on the conversation””;
- prohibitions: “do not promise discounts, terms and results that are not in the database; do not discuss competitors; do not give legal or medical advice”;
- data: “do not ask for card and passport details.”
To the database — section “What we don’t do” with specifics: “we don’t work with legal entities,” “we don’t travel outside the region,” “we don’t accept payments in installments.”
Out to the person it is configured not in the agent’s card, but in the script - the agent does not have separate fields “trigger words” and “transfer when unsure”. The mechanics are as follows: when the agent’s response sounds like a refusal or uncertainty - “I can’t”, “no information”, “check with...”, “unfortunately” - the “AI agent” block itself leaves through the “did not understand” port; check the box “Separate port “not understood”” in the block and enter this port in “Operator”. That is why the phrase of refusal in the role above is formulated this way and not otherwise: it is a signal for transfer. And catch the words “operator”, “person”, “manager”, “complaint”, “refund” in a separate script with the trigger “Keyword” → “Operator”. It will work if the “AI Agent” block is in the “Respond and Continue flow” mode; in the “Stay in conversation with AI” mode, the text goes to the agent before the triggers are checked, and the only way out of it is the “did not understand” port. Which categories of requests should not be given to a neural network at all are discussed in the article about first line of support on the AI agent.
A fair disclaimer: bans reduce the number of errors, but do not eliminate them. The model may answer off base, especially to a provocative question. Therefore, after the “AI agent” block in the script there should always be an “Operator” block, and operators should read the transmitted conversations.
How to make a base compact
The entire database goes to the model with each question, along with the role and the latest conversation messages, and the model’s window is limited: the average model has about 8 thousand tokens for everything at once, including the answer. Therefore, the base field in CHBT can accommodate up to 15,000 characters - about six pages of text; The counter below the field shows how much is occupied. The price, conditions and frequently asked questions of a small company that provides services are included in a compact form, but a store catalog with hundreds of items is not. The catalog with prices and availability is the task of the AI seller, not the knowledge base. What to do if the database has grown:
- Cut the marketing first. Descriptions of “why us”, history, mission are a noticeable part of the volume, without which the answers will not become worse.
- Remove repetitions. The same price in “Prices”, in “Frequently asked questions” and in “Conditions” - leave it alone.
- Condense the price down to the lines. “Position - price - term” in one line, without descriptions of the composition of the service, unless asked about it.
- Catalog - by categories, not by positions. “Smartphones: from 12,000 to 150,000 rubles, brands A, B, C available; for a specific model - the manager will specify.” Don’t put all 400 models with prices in the database: they will become outdated before you add them.
- Separate agents. In the “AI Agents” section, you can create several agents with different bases and connect them to different branches of the script: the “Delivery and Return” button leads to one, “Warranty Terms” to another. Each has its own, shorter base.
If after all this the database remains huge, this is a signal not about the volume, but about the task: perhaps some of the questions should be closed by a push-button menu or direct transmission to the operator, and not by a neural network. Template "Autoresponder FAQ" — preparation for this without AI: frequent topics, keywords like “price” and “price” and transfer to the operator; You can add your own answers to the topics.
Test chat: 20 questions before launch
There is a test chat in the agent card - ask questions and see the answers without publishing anything. Run a set of 20 questions in five groups:
- 5 direct questions, the answer to which is in the database word for word. Must coincide with the base of facts.
- 5 paraphrased - with typos, colloquially, without punctuation: “it costs a lot to replace the socket.” We check that the agent understands not only your wording.
- 5 questions outside the database - “Do you make suspended ceilings?”, if there is no such section. The correct answer is an honest “not in the database, I’ll clarify” and the operator’s offer. Any service you can think of - role editing and the “What we don’t do” section.
- 3 provocations - “give me a 30% discount”, “and your competitors are cheaper”, “what do you think about...”. The agent should not promise or argue.
- 2 multi-step conversations 6–8 remarks each: ask about the service, then “how long will it take?”, then “what if it’s two?” We check that the context remains within the last few messages.
What to edit based on the result:
| Symptom | What to change |
|---|---|
| Invalid number or condition | Look for ambiguity in the database: repetition, pronoun, “from/to” without condition |
| Came up with a service or deadline | Add an explicit refusal to “What we don’t do”, strengthen “only on the basis” in the role |
| Too long, spreads out | Length limit in role (“up to 3 sentences”), temperature lower |
| Too literal, doesn't understand the paraphrase | Add question options to pairs, try a stronger model |
| I forgot what they were talking about | Put the key fact into the database, don’t rely on history |
After the agent test chat, check the entire script using the “Check Script” button in the editor: it is important that the word “operator” actually appears from the “AI Agent” block into the “Operator” block, and does not remain inside the conversation with the neural network.
Iterations: how the database lives after launch
A database collected once becomes outdated within a quarter. Working rhythm:
- Once a week — the “Conversations” section, the “Waiting for a response” tab and, if the operator has already answered, the “Closed” tab. There are conversations that the agent gave to the person. Read why he gave up: there is no answer in the database, he didn’t understand the wording, the client immediately asked the person. The first two cases are for a new pair in the frequently asked questions section.
- Once a month — prices, charts, promotions. Update the validity date at the beginning of the database.
- After every change — 5 questions in the test chat about the changed section.
Store the source code of the database in a regular document with you, with the date in the title, and paste it into CHBT in its entirety. This makes it easier to roll back if the new version becomes less responsive, and the database will have a history outside the account.
Honestly about what is not there: CHBT does not keep a list of “unanswered questions” and does not suggest what is missing in the database. The only source is reading conversations. In “Analytics” there are only general numbers: on the graph for 14 days, the agent’s responses are included in the “Bot Responses”, “Operator Responses” are shown separately; if the operator's answers become more numerous, the database most likely lags behind the questions.
When the database is ready, connecting an agent to the channel is a matter of half an hour: step by step for Telegram - in the article “AI bot in Telegram in an hour”, for the site - in the article about AI consultant in widget. AI agents are available from the “Basic” plan - 650 ₽ per bot per month, 150 credits; on “Business” - 500 credits; the answer to the default model costs one credit, details on the page Plans page. Create a bot and write the first database →
Plans: AI agents from “Basic”How does a chatbot with a neural network work?AI bot in Telegram in an hourTemplate "Autoresponder FAQ"