Chatbots: script bot and smart bot
Ask the school bot about the Eid holiday and it tells you about winter vacation — confidently. Why?
- Tell a script bot from a smart bot
- Run and extend a script bot in Python
- Find the questions that break it
Chatbots: script bot and smart bot
Ask the school bot about the Eid holiday and it tells you about winter vacation — confidently. Why?
- Tell a script bot from a smart bot
- Run and extend a script bot in Python
- Find the questions that break it
Story
Learn it
A chatbot is a program that holds a conversation, by text or voice, and it is one of NLP's commonest uses. There are two kinds. A script bot looks for keywords and gives the answer someone wrote for them: cheap, predictable, and unable to learn. A smart bot learns from huge amounts of data and handles far wider language, and can be wrong in fluent, confident sentences. The Eid question broke Rahat's bot because a script bot matches words, not meaning.
Words to know
a program that holds a conversation by text or voice: help desks, shop websites, government services.
follows a script: looks for keywords and gives written answers. Needs little data and computing, and never learns.
learns from large amounts of data, handles wider language and context, and improves with use. Needs huge data and computing.
a word the bot looks for in your question, like "bus".
(Python) — pairs of keys and values: {"bus": "The bus leaves at 3:30."}.
a script bot from 1966 that pretended to be a counsellor by turning your words back into questions.
Step by step: a three-line script bot
answers = {"bus": "The bus leaves at 3:30.", "fees": "Fees are due on the 10th."}
question = input("You: ").lower()
for keyword in answers:
if keyword in question:
print("Bot:", answers[keyword])
.lower()turns "When does the BUS leave?" into lowercase, so"bus"can be found.- The loop checks each keyword in turn: is
"bus"in the question? Yes → print its answer. - No keyword? Ask "Is the canteen open?" and nothing prints: it has no answer outside its script.
- Wrong meaning: "Can I pay the bus fees?" contains both keywords and gets two answers, neither quite right.
- Order matters: put a specific keyword (
"eid") before a general one ("holiday") so it is checked first.
Careful: a script bot does not learn from its mistakes. If it answers wrongly, it will
answer wrongly forever, until a person changes its keywords. And forget .lower() and "When
does the BUS leave?" never matches "bus".
Your missions
programs/school_bot.pyRun it
7 minin pairs- 1
Open
school_bot.pyin Thonny. Read the dictionaryanswers: five keywords, five answers. - 2
Predict: what will it say if you type "when does the bus leave?" — and "is the canteen open?" Write both.
Only you can see this - 3
Run it and ask both. Type
byeto stop.
Break it
8 min- 4
Take turns asking it real questions a student or parent might ask. Write every question it gets wrong in a list, and next to each, why:
- no keyword it knows
- a keyword, but the wrong meaning (the Eid question)
- two keywords at once
- a spelling it doesn't expect
Extend it
8 min- 5
Add two new entries to
answersfor questions your list showed people really ask. - 6
Fix one problem from Part 2 — for example, put a more specific keyword like
"eid"before"holiday"so it is checked first. Predict, then test.
Make the bot understand "timings" and "time" as well as "timing". How
many spellings would you need to cover everything people type?
No laptop today?
One student is the bot, holding a card with the five keywords and answers. They may only read out an answer when they hear a keyword — no thinking allowed. The class asks questions and keeps the list of failures. Then write two new cards.
Debate it
The school office could use a smart bot instead — one of the big AI chatbots.
- What would it do better? What might it say that the school never approved?
- Parents would type their children's names, classes and problems into it. Where would those go? (Unit 1: the ethics review.)
Check yourself · practice, not a test
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.A bot that answers only when it finds a keyword it was given is a:
- ASmart bot
- BScript bot
- CNeural network
- DSearch engine
2.A script bot gets better on its own the more people use it.
TrueFalse3.In school_bot.py, the keywords and answers are stored in a Python ______.
4.Match each to its kind of bot:
- Needs little data; follows a written script
- Learns from huge data; handles wider language
- Smart bot
- Script bot
5.Put these lines in order so the bot answers one keyword (lines inside the loop are indented):
- 1for keyword in answers:
- 2print("Bot:", answers[keyword])
- 3if keyword in question:
- 4question = input("You: ").lower()
A script bot matches words. Understanding needs meaning.
Typing practice
Skill: a Python dictionary (5 min)
-
On typing.com: the symbols lessons.
-
Type three times, eyes on the screen:
answers = {"bus": "The village bus leaves at 3:40."} -
Curly brackets, a colon between key and answer. Goal this term: 38–44 WPM at 95%.
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.