B4 · Domains of AI: Vision, Language, Speech and Robotics

Rule-Based Chatbots and AI Chatbots

A rule-based chatbot follows instructions written by people: if the message contains certain words, or the user presses a certain button, send a fixed reply. An AI chatbot uses a model that has learned language from data, so it can understand different wordings and write new replies.

8 min Beginner Jump to the activity

What you need: Nothing. This page starts from the beginning, with no programming and no formulas.

Definition

One chatbot says "Sorry, I didn't understand" to almost everything. Another chats about anything. What is different inside?

A rule-based chatbot follows instructions written by people: if the message contains certain words, or the user presses a certain button, send a fixed reply. An AI chatbot uses a model that has learned language from data, so it can understand different wordings and write new replies.

In simple words

A rule-based chatbot is a vending machine: press B4, get a packet of chips. Press something that is not on the panel and nothing happens. An AI chatbot is closer to a shop assistant who has listened to thousands of customers: you can ask in your own words, and they will usually work out what you mean, and sometimes get it wrong.

Why it matters

The two kinds have opposite strengths. Rule-based bots are predictable and limited. AI bots are flexible and can be wrong in surprising ways. Knowing which one you are talking to tells you how to phrase your message and how far to trust the reply.

Key terms

Rule-based chatbot
A chatbot that follows rules and replies written in advance by people.
Keyword
A word the chatbot looks for in order to choose a reply.
Decision tree
A branching set of questions in which each answer leads to the next question or a final reply.
Intent classifier
A learned model that works out which of a set of intents a message expresses.
Large language model
A very large model trained on text that can write new replies.
Guardrail
A limit placed on a chatbot so that it stays within safe and approved behaviour.

Explained in detail

Three generations

Chatbots have been built in three main ways, and all three are still in use. The first generation is purely rule-based. The designer draws a decision tree: if the user presses 1, show the balance; if the message contains "lost" and "card", start the card-blocking steps. Nothing is learned. The bot does exactly what was written, which makes it predictable and easy to check, and unable to cope with anything the designer did not foresee.

The second generation, common from the mid-2010s, adds machine learning for understanding only. Designers still write the list of intents and the replies. But instead of exact keywords, they supply twenty or thirty example sentences for each intent, and a model learns to recognise new sentences that mean the same thing. The input becomes flexible while the output stays fixed and approved. Most banking and customer-service bots work this way.

The third generation uses a large language model to write the reply itself. Nothing is scripted. The bot can answer questions nobody listed, in natural language, and hold a long conversation. It can also write something untrue, promise something the company does not offer, or be talked into behaving badly.

GenerationUnderstandingReplyMain risk
RulesButtons and keywordsWritten in advanceDead ends
Intent-basedLearned from example sentencesWritten in advanceWrong intent chosen
Language modelLearned from vast textWritten fresh each timeFluent, confident errors

Two cautionary tales

In 2022 a passenger asked an airline's website chatbot about its policy on fares after a death in the family. The chatbot described a refund that the airline did not in fact offer. When the airline refused to pay, the passenger took the matter to a tribunal in Canada. The airline argued that the chatbot was responsible for its own words. In 2024 the tribunal rejected that argument and ordered the airline to pay: a company is responsible for what its chatbot tells customers.

In 2023 a car dealership put a language-model chatbot on its website. A visitor instructed it to agree with anything the customer said and then asked for a new car for one dollar. The chatbot agreed and called it a binding offer. No car was sold, but the screenshots spread widely. A model that follows instructions in conversation can be given instructions by anyone.

Making language-model chatbots safer

  • Ground the answers: the chatbot first looks up the company's own documents and is told to answer only from them.
  • Add guardrails: limits on topics, on promises about money, and on harmful content.
  • Keep actions under rules: the model may understand the request, but blocking a card or issuing a refund follows fixed, checked steps.
  • Keep a person available, and test with people who try to break it.

How it works

Rule-based chatbotAI chatbot
How it is madePeople write every rule and replyA model learns from large amounts of text
InputButtons, menus or exact keywordsFree text in your own words
RepliesFixed, written in advanceWritten fresh each time
Unexpected question"Sorry, I didn't understand"Attempts an answer, which may be wrong
Predictable?Yes, the same input gives the same replyLess so
Best forFixed tasks: balance, booking, order statusOpen questions, explanations, drafting
Main riskFrustrating dead endsConfident wrong answers

The first famous chatbot

In 1966 Joseph Weizenbaum at MIT built ELIZA, a rule-based program that imitated a counsellor. It looked for keywords and turned the user's sentence into a question. If you typed "I am sad about my exams", it might reply, "Why are you sad about your exams?" It understood nothing, yet many people felt it understood them. Weizenbaum was surprised and worried by how quickly people trusted it.

Many real chatbots are a mix

A bank's assistant may use an AI model to understand your wording ("my card is gone", "I lost my ATM card", "card kho gaya") and then follow strict rules for what happens next, because blocking a card must work the same way every time. Understanding is flexible; action is controlled.

Try it yourself

The same question, two chatbots

A customer writes: "My parcel is still not here and I am leaving town on Friday."

Rule-based or AI?

Which kind of chatbot behaves like this?

  • It explains photosynthesis in three different ways when asked

  • It replies "I didn't understand" to any sentence outside its list

  • It gives exactly the same reply every time you type 'hours'

  • It confidently names a book that does not exist

  • It understands "card kho gaya", "lost my card" and "my card is missing" as the same request

  • It shows a menu: 1 Balance, 2 Statement, 3 Talk to an agent

Common mistakes

  • Thinking rule-based chatbots are useless. For fixed tasks they are reliable and safe.
  • Thinking an AI chatbot that sounds fluent must be correct.
  • Writing long, chatty messages to a rule-based bot. Use its keywords or buttons.

Check yourself

Question 1

1. How does a rule-based chatbot choose its reply?

Question 2

2. What was ELIZA?

Question 3

3. What is the main risk of an AI chatbot?

Summary

  • Rule-based chatbots follow written rules: predictable and limited.
  • AI chatbots learn language from data: flexible and sometimes wrong.
  • Many real assistants combine AI for understanding with rules for action.

Finished reading?

Sources: Elements of AI (University of Helsinki) · AI4K12: Five Big Ideas in AI