2. Test Your Talkbot as a Web App

Playback Speed:
Transcript

In the previous video, you made a copy of the talkbot starter project in Apps Script.

In this video, you will try out the talkbot, make changes to the code, then test the results.

To start, make sure you’re in the file "JavaScript.html".

This file contains the code for your talkbot’s responses.

The other files contain the text on the webpage and the style of the page, but you won’t need to use those for this lesson.

Each line of the code is numbered.

On line 11, there’s a conditional statement.

In this case, if the first condition is met, then the computer will perform an action.

Both the condition and the action are in single quotation marks.

This code says that if the user of the talkbot types the word "hi," then the talkbot will respond with the phrase “hello world.”

Test it out.

To use your talkbot, you’ll need to deploy the project as a web app.

When you deploy your code, you move it from the script editor to a private webpage on the internet.

Since you’re still working on your project, just create a test deployment.

Later, you’ll publish it online, but for now, you only want to test it.

Click the URL to open the test deployment.

The web app will appear in a new tab.

That’s your talkbot.

Try it out.

Type the word “hi” in the chat box, and click Submit.

When the conditional statement “hi” is met, the computer responds with “hello world.”

Reload the page so you can try another response.

Now try writing something else, like “hey” or “what’s up?” in the chat box.

Nothing happens.

The condition of “hi” wasn’t met, so the computer won’t respond with “hello world.”

What if you type something with the word “hi” in it, like “shirt”?

Try it.

That works too.

So even though “hello world” doesn’t make sense as a response to “shirt,” the computer only understands the condition of “hi,” which is met by the word “shirt.”

In the next video, you’ll change your code so it responds to different words and phrases.

Instructions

  1. Create a test deployment.
  2. Test your talkbot by typing in the chat box.