4. Your alien friend! Tera!


You are going to learn how to program your own talking robot friend! It is also called Chatbot which means a bot that can chat! You have probably seen Talking Tom or Angela, we will create our own version.

Watch the Video tutorial here:



Before we start, you need an empty project so you have to get rid of the monkey sprite from the Screen by right-clicking and deleting it.

Step 1: Your Alien Friend! Tera!

Activity Checklist
Before you start making your Chatbot, you need to decide on its personality.

We need to think about:
    - What would be the name of your new friend?
    - Where would he or she live?
    - Is it going to be happy? serious? funny? shy? friendly?

Open up the AdamaScript IDE and start your project.

First, we have to get our Character sprite, from the Sprite library. We will use:

Tera from the Space section of the Sprite library. She is from Moon and she is a jolly and friendly alien.

Choose a backdrop that fits your Chatbot’s personality. We will choose Moon from space section of the backdrop library.

Save your project.

Step 2: A talking Chatbot

Now that you have a Chatbot with a personality, let’s program it to talk to you.

Activity Checklist
Click on your Chatbot character, and add this code:

Click your Chatbot to test it out. After you are asked your name, type it into the box along the bottom of the stage.

Your Chatbot simply replies What a lovely name! every time. You can
personalize your Chatbot’s reply, by making use of the user’s answer.
Change the Chatbot’s code, so that it looks like this:

To create the last block, you’ll need to first drag on a green join block,
and drag it on to the say block.


Get the blue answer block from the Sensing section.


Test out this new program. Does it work as you expected? Can you fix
any problems that you can see? (Hint: you can try adding in a space
Also maybe you would want to store the user’s name in a variable so that
you can use it again later. Create a new variable called name. If you’ve
forgotten how to do this, the ‘Catch the banana’ project will help you.
The information that you entered is already stored in a special variable
called answer. Go to the Sensing group of blocks and click the answer
block so that a tick appears. The current value in answer should then be
shown on the top-left of the stage.

Once you’ve created your new variable, make sure that your Chatbot’s
code looks like this:

If you test your program again, you’ll notice that the answer is stored in the name variable, and is shown in the top-left of the stage. The name variable should now contain the same value as the answer variable.

If you’d rather not see the variables on your stage, you can click the tick next to the variable names in the ‘Scripts’ tab to hide them.

Save your project

Challenge: More questions

Program your Chatbot to ask another question. Can you store their answer in a variable?

Hint: Name the variable according to the type of question. For example, if you ask a question like where do you live? your variable name should be something like “place”.

Save your project

Step 3: Making decisions

You can program your Chatbot to decide what to do, based on the user’s responses.

Activity Checklist
Let’s get your Chatbot to ask the user a question which has a yes or
no answer. Here’s an example, but you can change the question if you

Notice that now you’ve stored the user’s name in a variable, you can use it as much as you like.

To test this program properly, you’ll need to test it twice - once typing No as your answer, and once typing Yes. You should only get a response from your Chatbot if you answer Yes.

The trouble with your Chatbot is that it doesn’t give a reply if the user
answers no . You can fix this, by changing the if block to an if/else block, so that your code now looks like this:

If you test your code, you’ll now see that you get a response when you answer Yes or no. Your Chatbot should reply with That's great to hear! when you answer yes, but will reply with Oh no! if you type anything other than yes (else means ‘otherwise’).

You can put any code inside an if or else block, not just code to make your Chatbot speak. For example, you can change the Chatbot’s costume to match the response.

If you have a look at your Chatbot’s costumes, you may see that there is more than one.

You can use these costumes as part of your Chatbot’s response, by adding this code:

Test out your program, and you should see your Chatbot’s face change
depending on the answer you give.
Save your project

Step 4: Changing location

You can also program your Chatbot to change its location.

Activity Checklist
Add another backdrop to your stage, for example, the ‘moon’ backdrop.

You can now program your Chatbot to change location, by adding this code to your Chatbot:


Your overall code will look like this:

Save your project.

Challenge: Make your own Chatbot.

Use what you have learned to make your own Chatbot.

You can download the PDF here.