Chapter 5: Building a Bot

Illustration for Chapter 5

"So you want to build your own chatbot?" Ms. Chen asked, clearly pleased by Jack and Jill's enthusiasm. It was Tuesday afternoon, and they had stayed after school to talk with their technology teacher.

"Yes! We think it would make our science project more interactive," Jill explained. "But we don't know where to start."

"Is it really possible for kids our age to make one?" Jack added.

Ms. Chen smiled. "Absolutely! Modern tools have made it much easier. You won't be building something as sophisticated as the commercial chatbots you've researched, but you can definitely create a simple one that responds to specific questions."

She led them to a computer and opened a student-friendly programming platform. "This is a visual programming environment designed for students. Instead of typing code, you connect blocks that represent different functions."

"Like a digital puzzle!" Jack observed.

"Exactly. Now, the first step in building any chatbot is deciding what it will do," Ms. Chen explained. "What topic would you like your chatbot to help with?"

The siblings looked at each other. "What if we made a chatbot that answers questions about... chatbots?" Jill suggested with a grin.

"Meta!" Ms. Chen laughed. "I love it. A chatbot that explains chatbots."

For the next hour, Ms. Chen guided them through the process. First, they created a flowchart on paper, mapping out how their chatbot would respond to different questions.

"This is called decision tree logic," Ms. Chen explained. "If the user asks X, respond with Y. If they ask Z, respond with W."

Jack nodded. "So basically we're creating a bunch of if-then statements?"

"That's a great way to think about it," their teacher confirmed.

Using the visual programming tool, they started building their chatbot one piece at a time. They dragged blocks that detected keywords in questions and connected them to blocks containing appropriate answers.

"Let's test it," Jill suggested after they had programmed several responses. She typed: "What is a chatbot?"

Their creation responded: "A chatbot is a computer program designed to have conversations with humans through text or speech."

"It works!" Jack exclaimed. "Let me try one." He typed: "Who invented chatbots?"

The chatbot replied: "The first chatbot was created in 1966 by Joseph Weizenbaum. It was called ELIZA and was designed to mimic a psychotherapist."

"That's the fact we learned earlier!" Jack said, high-fiving his sister.

They continued adding more questions and answers to their chatbot, covering the history of chatbots, how they work, and their various uses.

"What happens if someone asks something we didn't program it to answer?" Jill wondered.

"Good question," Ms. Chen said. "We should create a default response." She helped them add a block that would activate if no keywords were matched, with the message: "I'm still learning about chatbots. Could you try asking your question differently, or ask me about chatbot history, how chatbots work, or what chatbots are used for?"

By the end of the session, their chatbot could answer about fifteen different questions related to chatbots.

"This is amazing," Jack said, watching their creation respond to questions. "We built an actual working chatbot!"

"It's pretty simple compared to commercial ones," Jill acknowledged, "but we actually made it ourselves!"

Ms. Chen nodded approvingly. "What you've built is called a rule-based chatbot. It's one of the simpler types, but it's perfect for your project. The commercial chatbots you use every day work on similar principles, just with much more complex systems behind them."

"Can we keep working on it?" Jack asked eagerly. "I have more ideas for questions we could add."

"The computer lab is open every day after school this week," Ms. Chen told them. "And I've saved your project to the school network so you can continue developing it."

As they packed up their notebooks, Jill couldn't stop smiling. "We should name our chatbot!"

"How about ChatMaster 3000?" Jack suggested.

Jill laughed. "Maybe something simpler. What about BotBuddy?"

"Perfect," Jack agreed. "BotBuddy: the chatbot that teaches you about chatbots!"