Empowering Kids Through AI & Education Pakistan Sessions Every Weekend
AI Superheroes · Session 6
✨ AI Superheroes Workshop – Session 6  |  May 23, 2026

🤖 Design Your Chatbot & Code It with Python!

Assalamu Alaikum, AI Superheroes! 👋 We're back after two months — and today is extra special. We'll do a quick, fun revision of everything we've learned, then design and build a real Islamic chatbot together using Python. No internet needed. Just your brain, your keyboard, and your creativity!

Ages 9–14 90 minutes Revision + Build Live Chatbot Islamic Values
🌙 Welcome Back!

Assalamu Alaikum — We Missed You! 🤗

It's been two months since our last session. That's okay — great things take time! Today we start fresh, remember what we've learned, and build something amazing together.

📅 Today's Session at a Glance

  • ⏱️ 0–15 min: Quick revision — what did we learn in Sessions 1–5?
  • ⏱️ 15–30 min: What is Python? Story-based intro for beginners
  • ⏱️ 30–50 min: Design your chatbot — sketch it on paper first!
  • ⏱️ 50–80 min: Live coding — build the chatbot step by step
  • ⏱️ 80–90 min: Run your bot 🎉 + mini recap + homework

🎯 By the End of Today, You Will:

  • Remember the key ideas from all 5 previous sessions
  • Understand what Python is and why we use it for AI
  • Design your own chatbot personality on paper
  • Build a working text-based Islamic chatbot in Python
  • Run your chatbot and see it answer questions — live!

🗺️ Our 90-Minute Adventure Map

🧠
0–15 min
Quick
Revision
🐍
15–30 min
Python
Story
✏️
30–50 min
Design
Chatbot
💻
50–80 min
Live
Coding
🎉
80–90 min
Run Your
Bot!
🔁 Quick Revision

🧠 Remember What We Learned? Let's Find Out!

Before we build something new, let's warm up our brains. Here's a lightning-fast tour of Sessions 1–5. Raise your hand if you remember each one!

📌 Session 1 — Discovering AI Power

We learned that AI is not magic — it's a machine that finds patterns. We spotted patterns in pictures, words, and numbers. We also learned how to write kind, clear prompts to talk to AI tools.

Key idea: AI learns from examples, just like you learn from practice!

📌 Session 2 — Building Noor Chatbot

We designed Noor — a friendly Islamic chatbot. We gave Noor a personality, safety rules, and a list of Islamic Q&A. We learned that a good chatbot is safe, kind, and honest.

Key idea: A chatbot is only as good as the rules and knowledge we give it!

📌 Session 3 — Python Programming Begins

We wrote our first Python code! We learned variables (labeled boxes), if/else (making decisions), and lists (storing many things). We built a simple chatbot using these tools.

Key idea: Python is a language that lets you talk to computers!

📌 Session 4 — Leveling Up Noor

We gave Noor a memory using Python dictionaries. We also learned how to test our code like professional engineers — writing test cases to find bugs before users do.

Key idea: Dictionaries store information in key-value pairs, like a contact card!

📌 Session 5 — Python Fundamentals Unlocked

We went deep into Python: all 6 data types (int, float, str, bool, list, dict), input/output, for loops, and the professional problem-solving framework. We solved real challenges!

Key idea: Loops let you repeat code without writing it 100 times!

🏆 Our AI Superheroes Learning Pyramid

🤖
Build AI Chatbot Session 6 — Today!
🔁
Loops, Functions & Problem Solving Session 5 — Python Fundamentals
🧠
Memory, Dictionaries & Testing Session 4 — Leveling Up Noor
🐍
Variables, If/Else & Lists Session 3 — Python Begins
💡
AI Concepts, Patterns & Chatbot Design Sessions 1 & 2 — Foundation
👩‍🏫 Instructor Tip — Quick Quiz!

Ask a volunteer: "What is a variable?" Then ask another: "What does if/else do?" Then ask the group: "What is a loop?" Give a small sticker or emoji stamp to anyone who answers. Keep it fun and fast — 3 minutes max!

🐍 Python — The Story

🐍 What is Python? (A Story for Kids)

📖 The Story of the Friendly Snake

Once upon a time, a programmer named Guido was tired of writing complicated code. He wanted a language that was simple, readable, and fun — like reading a story in English.

So in 1991, he created Python. He named it after his favourite comedy show, not the snake! 🐍😄

Today, Python is used by NASA, Google, Netflix, and millions of kids like you to build amazing things — including AI chatbots!

Why Python for AI? 🤔

Easy to Read

Python code looks almost like English sentences. print("Hello") — that's it!

Super Powerful

The same language that powers Instagram, YouTube recommendations, and AI assistants.

Works Offline

Our chatbot runs on your computer — no internet needed. Safe and private!

Huge Community

Millions of people use Python. If you get stuck, someone has already solved it!

Python vs. Everyday Language 🗣️

Think of Python like giving instructions to a very obedient robot. The robot does exactly what you say — no more, no less!

🧠 Analogy: Python is Like a Recipe

When you bake a cake, you follow a recipe step by step. Python code is the same — a list of instructions the computer follows in order, one line at a time.

  • Step 1: Get the ingredients (variables)
  • Step 2: Mix them (operations)
  • Step 3: Check if it's ready (if/else)
  • Step 4: Repeat until done (loops)
  • Step 5: Serve! (print / output)
🗣️ How You Say It
👋"Hey, what's your name?"
📦"Remember my age is 12"
🔀"If it's raining, take an umbrella"
🔁"Say Bismillah before every meal"
📢"Tell me the answer"
VS
🐍 How Python Says It
💻input("What is your name? ")
💻age = 12
💻if raining: take_umbrella()
💻for meal in meals: say_bismillah()
💻print(answer)
👩‍🏫 Instructor Tip — Participation Moment!

Ask: "Who has heard of Python before?" Then: "Who has written Python code?" Celebrate every hand that goes up. Then say: "Today, ALL of you will write Python code that actually works. Ready?"

✏️ Design Time

✏️ Design Your Chatbot — On Paper First!

Before we write a single line of code, we design. Real engineers always plan before they build. Today, you'll sketch your chatbot idea — just like the kids did in Session 2!

🎨 Your Chatbot Design Challenge (5 minutes)

Grab a piece of paper and answer these questions about your chatbot:

  • 🤖 Name: What is your chatbot called? (e.g., Noor, Huda, Bilal)
  • 😊 Personality: Is it friendly? Funny? Calm? Wise?
  • 📚 Topic: What does it know about? (Islamic facts, duas, stories)
  • 💬 3 Questions it can answer: Write them down!
  • 🚫 What it should NOT say: What topics should it avoid?

How a Chatbot Thinks 🧠

A chatbot is like a very smart flashcard game. You ask a question → the chatbot looks for a matching answer → it replies. Simple!

🏗️ How Your Chatbot Works — Inside the Machine

👦
You Type a Question

"How many times do we pray?"

🔡
Python Makes It Lowercase

message.lower().strip() — so "Hello" and "hello" both work

🧠
Search the Knowledge Dictionary

Loop through every keyword — does any keyword appear in the question?

Match Found → Return Answer

"Muslims pray 5 times a day: Fajr, Dhuhr, Asr, Maghrib, Isha. 🕌"

🤲
No Match → Safe Default Reply

"I'm not sure. Please ask a parent, teacher, or imam!"

👩‍🏫 Instructor Tip — Share Designs!

After 5 minutes, ask 2–3 volunteers to share their chatbot name and one question it can answer. Write them on the whiteboard. This builds excitement before coding begins!

🐍 Python Concepts

🐍 The Python Tools We'll Use Today

We only need 4 Python tools to build our chatbot. You've seen all of these before — let's do a super-fast refresher!

1
📦
Variables

Labeled boxes that store information. name = "Noor" — give it a name, put something inside!

2
💬
Input & Output

Talk to users! input() asks a question. print() shows the answer on screen.

3
🔀
If / Else

Make decisions! if this is true → do this. else → do something different.

4
🗝️
Dictionaries

The chatbot's brain! Stores Q&A pairs. {"question": "answer"} — like digital flashcards.

Tool 1: Variables — The Labeled Boxes 📦

A variable stores information. Give it a name, and put something inside.

Python
chatbot_name = "Noor"       # A string (text)
age_limit = 14              # An integer (whole number)
is_running = True           # A boolean (yes/no)

Tool 2: Input & Output — Talking to Users 💬

input() asks the user a question. print() shows a message on screen.

Python
question = input("You: ")          # Ask the user
print("Noor: Assalamu Alaikum!")   # Show a reply

Tool 3: If/Else — Making Decisions 🔀

If the user says X, reply with Y. Otherwise, say something else.

Python
if question == "hello":
    print("Noor: Wa Alaikum Assalam! 😊")
else:
    print("Noor: I'm not sure about that!")

Tool 4: Dictionaries — The Q&A Brain 🗝️

A dictionary stores pairs: a question (key) and an answer (value). This is the chatbot's knowledge!

Python
knowledge = {
    "how many prayers": "We pray 5 times a day! 🕌",
    "what is zakat":    "Zakat is giving 2.5% of savings to those in need. 💛",
    "who is allah":     "Allah is the One God, Creator of everything. 🌟"
}

💡 Think of it Like Flashcards!

Imagine you have a stack of flashcards. On one side is a question, on the other side is the answer. A Python dictionary is exactly that — a digital stack of flashcards your chatbot can flip through instantly!

🔨 Live Build

🔨 Let's Build the Chatbot — Step by Step!

Now the exciting part! We'll build the chatbot together, one step at a time. Type along with the instructor. Don't worry about mistakes — that's how we learn!

Step 1: Set Up the Chatbot's Identity 🤖

First, we give our chatbot a name and a welcome message.

Python — Step 1
# ============================================
# My Islamic Chatbot - Built by AI Superheroes!
# ============================================

chatbot_name = "Noor"   # Change this to YOUR chatbot's name!

print("=" * 45)
print(f"  Assalamu Alaikum! I am {chatbot_name} 🤖")
print("  Your friendly Islamic learning buddy!")
print("  Type 'quit' anytime to say goodbye.")
print("=" * 45)
print()
============================================= Assalamu Alaikum! I am Noor 🤖 Your friendly Islamic learning buddy! Type 'quit' anytime to say goodbye. =============================================
👩‍🏫 Instructor Tip

Ask kids to change chatbot_name to their own chatbot's name from the design activity. This makes it personal and exciting!

Step 2: Build the Knowledge Base 📚

Now we add the chatbot's brain — a dictionary of Islamic Q&A pairs.

Python — Step 2
# The chatbot's knowledge - Q&A pairs
# Key = question keywords, Value = answer
knowledge = {
    "hello":              "Wa Alaikum Assalam! How can I help you today? 😊",
    "assalamu alaikum":   "Wa Alaikum Assalam wa Rahmatullahi wa Barakatuh! 🌙",
    "how many prayers":   "Muslims pray 5 times a day: Fajr, Dhuhr, Asr, Maghrib, Isha. 🕌",
    "what is zakat":      "Zakat means giving 2.5% of your savings to help people in need. It's one of the 5 pillars of Islam! 💛",
    "who is allah":       "Allah is the One God, the Creator of everything in the universe. 🌟",
    "what is quran":      "The Quran is the holy book of Islam, revealed to Prophet Muhammad ﷺ. It has 114 surahs! 📖",
    "what is ramadan":    "Ramadan is the blessed month of fasting. Muslims don't eat or drink from sunrise to sunset. 🌙",
    "what is eid":        "Eid is a joyful celebration! Eid ul-Fitr comes after Ramadan, and Eid ul-Adha celebrates sacrifice. 🎉",
    "what is dua":        "Dua means supplication — talking to Allah and asking for His help and blessings. 🤲",
    "what is hadith":     "A Hadith is a saying or action of Prophet Muhammad ﷺ, recorded by his companions. 📜",
    "what is sunnah":     "Sunnah means following the example of Prophet Muhammad ﷺ in our daily life. ✨",
    "how to make wudu":   "Wudu is the Islamic way of washing before prayer: hands, mouth, nose, face, arms, head, ears, feet. 💧",
    "what is sadaqah":    "Sadaqah is voluntary charity — giving to others with a kind heart, any amount! 💚",
    "thank you":          "You're welcome! JazakAllahu Khayran — may Allah reward you with goodness! 🌸",
    "bye":                "Wa Alaikum Assalam! May Allah bless you and your family. See you next time! 🌙",
    "quit":               "Wa Alaikum Assalam! May Allah bless you and your family. See you next time! 🌙",
}

🎨 Make It Yours!

This is YOUR chatbot's brain. You can add more Q&A pairs! Just follow the pattern:

"your question keywords": "your answer here",

Try adding your favourite dua, a fact about a prophet, or a question about Islamic history!

Step 3: Build the Smart Reply Function 🧠

This is the chatbot's brain — it looks at what the user typed and finds the best answer.

Python — Step 3
def get_reply(user_message, knowledge_base):
    """
    Look for a matching answer in the knowledge base.
    We check if any keyword from our dictionary
    appears in what the user typed.
    """
    # Make the message lowercase so "Hello" and "hello" both work
    message = user_message.lower().strip()

    # Check each keyword in our knowledge base
    for keyword, answer in knowledge_base.items():
        if keyword in message:
            return answer   # Found a match! Return the answer

    # No match found - give a polite default reply
    return "Hmm, I'm not sure about that. Please ask a parent, teacher, or imam! 🤲"

🔍 How Does This Work?

The function loops through every keyword in our dictionary. If the keyword appears anywhere in what the user typed, it returns that answer. It's like a search engine — but tiny and Islamic! 😄

Example: User types "tell me about zakat please" → the function finds "what is zakat" contains the word "zakat" → returns the zakat answer!

Step 4: The Main Chat Loop 🔁

Now we make the chatbot keep talking until the user says "quit". This is a while loop — it keeps going as long as a condition is true.

Python — Step 4
# Keep chatting until the user says "quit"
while True:
    # Ask the user for their message
    user_input = input("You: ")

    # Check if they want to leave
    if user_input.lower() == "quit":
        print(f"{chatbot_name}: Wa Alaikum Assalam! May Allah bless you! 🌙")
        break   # Exit the loop

    # Get the chatbot's reply
    reply = get_reply(user_input, knowledge)

    # Show the reply
    print(f"{chatbot_name}: {reply}")
    print()   # Empty line for readability

💡 What is a While Loop?

A while True loop runs forever — until we tell it to stop with break. It's like a conversation that keeps going until someone says goodbye!

Think of it like a game: the game keeps playing until you press "Exit". The break is the Exit button!

🚀 Complete Code

🚀 The Complete Chatbot — All Together!

Here is the full chatbot code. Copy it into your Python file, run it, and watch your chatbot come to life! 🎉

noor_chatbot.py — Complete Code
# ============================================
# My Islamic Chatbot - Built by AI Superheroes!
# Session 6 - Khalida Foundation
# ============================================

# --- STEP 1: Chatbot Identity ---
chatbot_name = "Noor"   # Change to YOUR chatbot's name!

print("=" * 45)
print(f"  Assalamu Alaikum! I am {chatbot_name} 🤖")
print("  Your friendly Islamic learning buddy!")
print("  Type 'quit' anytime to say goodbye.")
print("=" * 45)
print()

# --- STEP 2: Knowledge Base (Q&A Dictionary) ---
knowledge = {
    "hello":              "Wa Alaikum Assalam! How can I help you today? 😊",
    "assalamu alaikum":   "Wa Alaikum Assalam wa Rahmatullahi wa Barakatuh! 🌙",
    "how many prayers":   "Muslims pray 5 times a day: Fajr, Dhuhr, Asr, Maghrib, Isha. 🕌",
    "what is zakat":      "Zakat means giving 2.5% of your savings to help people in need. 💛",
    "who is allah":       "Allah is the One God, the Creator of everything. 🌟",
    "what is quran":      "The Quran is the holy book of Islam, with 114 surahs! 📖",
    "what is ramadan":    "Ramadan is the blessed month of fasting. 🌙",
    "what is eid":        "Eid is a joyful celebration after Ramadan and during Hajj season! 🎉",
    "what is dua":        "Dua means talking to Allah and asking for His help. 🤲",
    "what is hadith":     "A Hadith is a saying or action of Prophet Muhammad ﷺ. 📜",
    "what is sunnah":     "Sunnah means following the example of Prophet Muhammad ﷺ. ✨",
    "how to make wudu":   "Wudu: wash hands, mouth, nose, face, arms, head, ears, feet. 💧",
    "what is sadaqah":    "Sadaqah is voluntary charity — giving with a kind heart! 💚",
    "thank you":          "JazakAllahu Khayran — may Allah reward you! 🌸",
    "bye":                "Wa Alaikum Assalam! May Allah bless you! 🌙",
}

# --- STEP 3: Smart Reply Function ---
def get_reply(user_message, knowledge_base):
    """Find the best answer for the user's message."""
    message = user_message.lower().strip()

    for keyword, answer in knowledge_base.items():
        if keyword in message:
            return answer

    return "I'm not sure about that. Please ask a parent, teacher, or imam! 🤲"

# --- STEP 4: Main Chat Loop ---
while True:
    user_input = input("You: ")

    if user_input.lower() == "quit":
        print(f"{chatbot_name}: Wa Alaikum Assalam! May Allah bless you! 🌙")
        break

    reply = get_reply(user_input, knowledge)
    print(f"{chatbot_name}: {reply}")
    print()

🎉 Run Your Bot Checkpoint!

Save your file as noor_chatbot.py and run it! Try asking: "What is Ramadan?" and "How many prayers?" — does your chatbot answer correctly? High five if it does! ✋

============================================= Assalamu Alaikum! I am Noor 🤖 Your friendly Islamic learning buddy! Type 'quit' anytime to say goodbye. ============================================= You: assalamu alaikum Noor: Wa Alaikum Assalam wa Rahmatullahi wa Barakatuh! 🌙 You: what is ramadan Noor: Ramadan is the blessed month of fasting. 🌙 You: tell me about zakat Noor: Zakat means giving 2.5% of your savings to help people in need. 💛 You: what is the weather Noor: I'm not sure about that. Please ask a parent, teacher, or imam! 🤲 You: quit Noor: Wa Alaikum Assalam! May Allah bless you! 🌙
🛡️ Best Practices

🛡️ Building a Safe & Respectful Chatbot

A great chatbot isn't just smart — it's also safe, kind, and honest. Here are the rules every AI Superhero follows:

Kid-Safe Responses

Never include scary, violent, or adult content. Keep everything positive and age-appropriate.

Respectful Islamic Language

Use proper Islamic phrases: ﷺ after the Prophet's name, Alhamdulillah, Insha'Allah, JazakAllahu Khayran.

Say "I Don't Know"

If the chatbot doesn't know, it should say so honestly and redirect to a parent, teacher, or imam.

No Harmful Topics

The chatbot should not discuss violence, politics, or give religious rulings (fatwas). It's a helper, not a mufti!

📋 The Chatbot Safety Checklist

  • ✅ All answers are kind and encouraging
  • ✅ No personal information is collected
  • ✅ Unknown questions get a polite "ask an adult" reply
  • ✅ No religious rulings or fatwas
  • ✅ Works offline — no internet needed
  • ✅ Uses proper Islamic greetings and phrases
👩‍🏫 Instructor Tip — Ethics Discussion (3 min)

Ask the class: "What should Noor say if someone asks 'Is eating pizza haram?'" Let kids discuss. The answer: Noor should say "Please ask your parents or imam for religious guidance!" This teaches that AI is a helper, not an authority.

🌱 Extend & Grow

🌱 How to Make Your Chatbot Even Better!

Your chatbot is working — amazing! Now let's think about how to grow it over time. Here are ideas for future sessions:

Level 1: Add More Knowledge 📚

The easiest way to improve your chatbot is to add more Q&A pairs to the dictionary. Try adding:

Python — Add More Q&A
# Add these to your knowledge dictionary!
"what is hajj":       "Hajj is the pilgrimage to Makkah — one of the 5 pillars of Islam! 🕋",
"who is prophet":     "Prophet Muhammad ﷺ is the last messenger of Allah, born in Makkah. 🌟",
"morning dua":        "Say: 'Alhamdulillahilladhi ahyana ba'da ma amatana' when you wake up! 🌅",
"sleeping dua":       "Say: 'Bismika Allahumma amutu wa ahya' before sleeping! 🌙",
"eating dua":         "Say: 'Bismillah' before eating and 'Alhamdulillah' after! 🍽️",

Level 2: Add a Greeting with the User's Name 👋

Make the chatbot ask for the user's name at the start and use it in replies!

Python — Personalized Greeting
# Add this BEFORE the while loop
user_name = input("What is your name? ")
print(f"\n{chatbot_name}: Assalamu Alaikum, {user_name}! 🌙 How can I help you today?\n")

Level 3: Add Islamic Stories 📖

Add short stories about prophets or Islamic history to your knowledge base!

Python — Story Entry
"story of ibrahim":   "Prophet Ibrahim ﷺ was known as Khalilullah — the friend of Allah. He was tested many times and always trusted Allah. His story teaches us patience and faith! 🌟",
"story of yusuf":     "Prophet Yusuf ﷺ had a beautiful dream about 11 stars. His brothers were jealous, but Allah had a great plan for him. He became a leader in Egypt! 🌙",

🚀 Future Session Preview!

In our next sessions, we'll learn how to:

  • Save the chatbot's conversations to a file
  • Add a score system — earn points for asking good questions!
  • Give the chatbot a web interface so anyone can use it in a browser
  • Connect it to a real AI brain (LLM) for smarter answers
📝 Mini Recap

📝 Today's Mini Recap — Remember This!

Before you go, let's lock in what we learned today. Read this out loud with the class!

🧠 The 5 Things I Learned Today

  • 1️⃣ Python is a simple, powerful language used for AI — and it reads like English!
  • 2️⃣ A dictionary stores Q&A pairs — the chatbot's brain!
  • 3️⃣ if/else lets the chatbot make decisions based on what the user says.
  • 4️⃣ A while loop keeps the conversation going until the user says goodbye.
  • 5️⃣ A good chatbot is safe, kind, honest — and says "I don't know" when it doesn't know!

🏠 Homework Challenges

  • Level 1: Add 5 new Q&A pairs to your chatbot's knowledge base.
  • ⭐⭐ Level 2: Add a personalized greeting that uses the user's name.
  • ⭐⭐⭐ Level 3: Add 3 Islamic stories (prophets, companions, or historical events).
  • 🌟 Bonus: Teach your chatbot a dua for morning, evening, and before eating!
👩‍🏫 Instructor Tip — Closing Moment

End the session by asking each child to say ONE thing they're proud of building today. Even "I typed the code and it worked!" is a win. Celebrate every achievement. Close with a group "Alhamdulillah!" 🤲

🌟 You Are an AI Superhero!

Today you built a real, working chatbot using Python. You designed it, coded it, and ran it. That's something most adults haven't done! Keep learning, keep building, and remember — with knowledge and good intentions, you can use AI to help the world. Alhamdulillah! 🤖🕌

Back to All Blog Posts