On day 6 of our 30-day skill challenge, we'll be teaching Chatterbox how to help us play the Mad Libs game! We'll learn how to make Chatterbox ask questions and use the answer in a response.
So far we've made Chatterbox listen, speak and look up information from the internet. Now we're going to teach Chatterbox how to ask questions and put all together in a Mad Libs game.
Let's talk about Variables...
But first... Let's talk about Variables. You've actually already used variables in a previous skill. Remember the utterance_remainder block? That's a variable! A variable is an object that "remembers" or stores information.
The utterance remainder block is a block that we've made, but did you know that you can make your own variables by clicking the 'Create variable' button in the Variables menu. You'll see two different variable blocks. The block on the left let's you SET the contents of the variable. The block on the right let's you USE the variable.
To Do: Create a variable named Answer
Hey Chatterbox, ask me a question!
Before we jump into making Chatterbox ask a question, let's stop and think about what actually happens when someone asks us a question.
When someone asks you your name: 1. You Listen to the question 2. They Ask a question 2. You Answer the question 3. They might respond with your name: Hi _________!
It's the same basic process to get Chatterbox to ask a question, except the block is called Get response for question. You can find this block in the Speak category because the block makes Chatterbox speak a question.
To try this out, let's build a simple question skill. In the Get Response for question, type: Would you rather eat snails or crickets?
Finally, we need to have Chatterbox respond using the spoken answer. Use a Speak block with a double sided speech block
Your final skill should look something like this:
What did we learn? We learned that using the Get Response with a variable lets us save an answer that we can use in a response to the user.
Building a Mad Libs Game
Mad Libs is a silly word game where you ask someone a bunch of questions, then use their answers to fill in the blanks in a pre-written story. We're going to our own spin and build a Mad Libs game that you can share with friends and family inspired by one of their printables.
In this Skill Challenge, we are going to give you a written template that you'll turn into a Chatterbox voice skill.
Mad Libs Script
Intent trigger: play mad libs
Chatterbox speaks: Let's play mad libs! I'm going to ask you a bunch of questions and tell me the first thing that pops into mind.
Chatterbox asks questions and stores the answers: Words in brackets should be created variables.
What is your [name]? Pick a [theme]. Pick a [place] or location. Pick a [day] of the week. Pick a [time] of day. Pick a [verb]. Pick an [animal]. Name a [body] part.
Using the answers from above: [Name] is formally invited to Chatterbox's [theme] party. It's going to be at [place] on [day]. Please make sure to show up at [time] or else you will be required to [verb] a [animal] with your [body] See you at the party!
Hints for the Skill Challenge:
Hint #1: Create all your variables first
Hint #2: Ask all your questions second.
Hint #3: Once you've asked all your questions, make Chatterbox speak sentences using variables and text blocks.