Make your own chatbot!

Programming with

1. Create a Scratch account at scratch.mit.edu

(if you don't have one already)

 

2. Open this project template

 

3. Click "Remix" to make your own copy

 

 

As of right now, the program looks like this:

Click the green flag to "run" the program and see what it does.

After asking if you would like to know about cats, dogs, or horses - nothing happens!

 

We need to add code that tells the program what to do based on the user's answer.

 

To do this, we will use the IF / ELSE block:

Actually, we'll use it multiple times, nested inside of other IF statements!

Customize the questions & responses however you want!

Next, we might want to make it easy to start over and pick another topic, without having to enter your name all over again.

 

One way to solve this is to let the user click on the cat to pick another topic.

 

Go to the next slide to see how that's done.

Let's duplicate the code starting from Line 3 (where you ask the user to choose a topic)

 

Right-click to duplicate

This time, attach it to an event called: "when this sprite clicked"

Test your code by restarting the program, and then click on the cat after getting the response for your first topic choice.

scratch-chatbot

By Michelle Lim

scratch-chatbot

  • 878