AI systems and agents

How does an AI chatbot work? Models, data and rules

What happens between a question, a generated answer and a business action

Layered violet interface panels connected across a dark technical surface, representing an AI chatbot system.

An AI chatbot is not just the model writing the answer. It is an application: an interface receives the question; rules and instructions determine how to handle it; optional retrieval supplies authorised external information; a model generates text from the available context; and separate tools may perform business actions through explicit permissions and controls. Not every chatbot includes every layer.

How an AI chatbot works, in one answer

Suppose a customer asks: “Can I return a product I bought twenty days ago?”

A useful response may pass through five different layers:

  1. Interface and session receive the message, language, channel and any authenticated identity.
  2. Rules, instructions and orchestration define the chatbot’s purpose, limits, response format and handoff conditions.
  3. Retrieval and data access, when present, look for the current returns policy or—after the necessary checks—a specific order.
  4. Model inference and generation produce an answer from the question, instructions and supplied context.
  5. Business actions and controls, when present, start an actual return only after authentication, authorisation, eligibility checks and confirmation.

This five-layer model is a M4TIC synthesis of common architecture patterns, not a universal standard. A system may merge, repeat or omit layers. A rules-based chatbot may use no generative model. An informational chatbot may have no persistent memory or operational tools.

Chatbot, AI chatbot and AI customer assistant are different things

A chatbot primarily describes a conversational interaction format or application category. It can be built entirely from menus, matching rules and prewritten responses. Such a system does not necessarily use generative AI at all.

An AI chatbot adds model-based interpretation or generation. It may handle varied wording, classify a request, summarise content or compose an answer. That does not mean it automatically knows the latest company policy, can see internal systems or has permission to change a record.

An AI customer assistant is a broader service system: conversation plus maintained business knowledge, context collection, controlled next actions and reliable human handoff. It may use a chatbot as its interface, but the visible chat alone is not the assistant. M4TIC’s AI Customer Assistant page describes the complete operating pattern.

Nor is ChatGPT the category name. It is a specific product. Calling something a chatbot tells you nothing by itself about its model, sources, memory, permissions or contractual data handling.

One customer question through five chatbot layers

1. Interface and session

The interface accepts text, voice, files or other input and presents the response. The session may carry language, channel, conversation state and, where appropriate, authenticated identity.

In the returns example, “twenty days ago” may not be enough. The system may need to ask where the purchase was made, which product is involved or whether the customer has signed in. If the session is associated with the wrong person or conversation, every later component starts from the wrong premise.

2. Rules, instructions and orchestration

This layer decides which components to use and in what sequence. It may apply system instructions, policies, routing, filters, output formats and fallback conditions.

For a return request, the rules might prohibit unsupported promises, separate general policy from an individual decision and require human review for exceptions. Instructions can conflict, become stale or be challenged by malicious input. Guardrails can reduce and manage risk; they do not guarantee correctness or prevent every form of prompt injection.

3. Retrieval and data access — optional

In a retrieval-augmented system, a component searches for relevant external information and adds it to the model’s context. It might retrieve the current returns policy, category exclusions or a passage from the company knowledge base.

Looking up a specific order is different. It requires identity, authorisation and access to an operational record. Document retrieval and an authorised query to a business system should not be treated as the same action.

RAG does not retrain the model. It supplies information at request time. It can improve relevance and make knowledge easier to update, but it does not make an answer automatically true. Retrieval can select stale, incomplete or irrelevant material; the model can still misread it or omit an important condition.

4. Model inference and response generation

The model receives instructions, the user’s message and whatever context the application supplies. It generates the response sequentially from patterns learned during training and the current inputs. It is not querying its training data as a row-by-row database on every turn.

For the returns question, a good answer should distinguish the general policy from the customer’s specific eligibility, state what information is missing and point to supporting material where possible. A fluent answer may still contain an omission, an unsupported citation or an overconfident conclusion.

5. Business tools, actions and controls — optional

If the customer asks to start the return, generated text is not enough. Separate application code must verify identity, order, product, eligibility and current state; request confirmation where needed; execute with limited permissions; log the result; and provide recovery or human handoff if something fails.

The model may produce structured arguments or suggest a tool call. It should not gain implicit authority to execute any available action. The more a chatbot can do, the more least privilege, validation, confirmation, logging and stop conditions matter.

The example is illustrative. It is not a client case or evidence of performance.

Four chatbot architectures that should not be confused

Scroll horizontally to compare all architectures

Four chatbot architectures that should not be confused
ArchitectureHow it respondsWhen it may be enoughLimit to make visible
Rules-based / decision-treeUses menus, matching logic and prewritten responses.A small, stable question set with controlled outcomes.It handles unplanned paths poorly and is not necessarily AI.
Generative without business retrievalGenerates from the prompt and supplied context.Writing, transformation or conversation where proprietary knowledge is not decisive.It does not automatically know current policies or internal systems.
RAG chatbotRetrieves content at runtime and supplies it to the model.Answers grounded in identifiable, maintainable documents.Retrieval and generation can both fail; a citation still needs checking.
Action-enabled chatbotCalls tools or APIs through the surrounding application.Work where value requires operating a process, not merely explaining it.Consequences and security exposure increase, requiring controls and recovery.

These architectures can be combined. A system might use rules for consent and authentication, RAG for knowledge, generation for wording and a tool for one approved action. More components do not automatically produce a better chatbot. They also create more dependencies to configure, test and maintain.

Training data, runtime context, retrieval and memory are not interchangeable

“The chatbot uses our data” is too vague to support a buying decision. It may refer to four different mechanisms:

Scroll horizontally to compare every data mechanism

Four different meanings of chatbot data
Data typeWhere it entersWhat it does not automatically mean
Training or fine-tuning dataDuring model development or adaptation, changing model parameters.It is not a knowledge base queried line by line for every answer.
Runtime prompt and contextDuring one inference: instructions, messages, examples and supplied facts.It does not automatically change the model’s weights.
Retrieved dataAt runtime, when selected documents or records are added to context.It is not retraining and may be incomplete or irrelevant.
Stored history or application-managed memoryWhen the product persists messages, summaries, preferences or state.It is not a uniform property of the model; duration and access depend on implementation.

You cannot infer from a chat window whether conversations are retained, used for training, visible to administrators or transferred elsewhere. Those are product-, plan-, setting- and contract-specific questions. Review documentation, configuration and agreements. For deployment and data-control decisions, see Private AI for business.

Where errors enter an AI chatbot

The model is only one failure point:

  • interface and session: ambiguous input, wrong identity or conversation, unsupported attachment;
  • orchestration: conflicting instructions, bad routing, stale policy or prompt injection;
  • retrieval: missing, outdated, irrelevant or incorrectly authorised source material;
  • generation: misinterpretation, omission, variability or unsupported citation;
  • action: excessive permission, wrong record, duplicate operation, weak logging or absent handoff.

That is why “we added RAG” or “we installed guardrails” is not a quality conclusion. The whole path must be tested, including ambiguous requests, missing sources, API failures and human escalation. M4TIC’s articles on why AI makes mistakes and AI hallucinations cover verification and failure modes without repeating the chatbot architecture here.

What to ask a chatbot vendor or builder

Before judging a polished demo, ask:

  1. What problem must the chatbot solve, and which requests must it refuse or hand over?
  2. Which model and version generate the answer? How are changes managed?
  3. Which instructions take precedence, and how are they tested after an update?
  4. Which sources can it retrieve? Who maintains them and how are permissions enforced?
  5. Can it distinguish missing evidence from an answer? Do citations support the actual claim?
  6. What is logged: prompts, retrieved sources, outputs, tool calls, results and handoffs?
  7. Which actions can it only propose, and which can it execute? With what credentials and confirmations?
  8. What happens when retrieval, authentication, the model or an API fails?
  9. When does a person take over, and what context do they receive?
  10. How are normal, ambiguous, malicious and high-consequence cases evaluated?

A smooth demo proves that the ideal path worked once. It does not prove that sources, permissions, fallbacks and maintenance are fit for real operations.

When a simpler chatbot is the better system

For a small, stable domain, a menu or decision tree may be more controllable than open-ended generation. If the job is to find a well-indexed page or policy, search may be enough. Generation becomes useful when language varies and the system needs to compose, summarise or explain. RAG helps when the answer must rely on identifiable, maintained business knowledge. Tools are justified when taking action creates enough value to support permissions, testing, confirmation and recovery.

The useful question is not “how much AI can we add?” It is “which architecture solves the problem at a level of variability and consequence we can govern?”

Where a chatbot becomes more agentic

A chatbot organises interaction as conversation. A system becomes more agentic when it can choose and sequence tools or steps towards an objective with greater autonomy. The boundary is not the appearance of the chat window; it is the operational authority and decisions delegated to the system.

Not every chatbot with one tool call is an autonomous agent. For the complete distinction and when the architecture is useful, read What are AI agents, and when should a business use them?. The authority and permission ladder belongs to planned INS-0014 and is intentionally not recreated here.

Sources and further reading

Primary guidance behind this article.

  1. Retrieval-Augmented Generation — NIST GlossaryNIST

    Authoritative definition of retrieval supplying relevant information to a model in context.

  2. Artificial Intelligence Risk Management Framework: Generative AI ProfileNIST

    Reference for confabulation, context, evaluation and governance of generative systems.

  3. Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksLewis et al., NeurIPS 2020

    Original paper distinguishing model parameters from external retrieval.

  4. Attention Is All You NeedVaswani et al., NeurIPS 2017

    Original Transformer paper; supports only the article’s high-level model explanation.

  5. Deploy and operate generative AI applicationsGoogle Cloud Architecture Center

    Maintained documentation on prompts, context, versioning, RAG, model chains and APIs; not a universal standard.

  6. What is retrieval-augmented generation?Google Cloud

    Supports the retrieval-quality caveat and the risk of answers grounded in irrelevant content.

  7. Prompt InjectionOWASP GenAI Security Project

    Maintained guidance on conflict between trusted instructions and malicious input.

  8. LLM06:2025 Excessive AgencyOWASP GenAI Security Project

    Guidance on excessive functionality, permissions and autonomy in tool-using systems.