Ask the Wolf!
Let's learn how to make Chatterbox answer our toughest questions. We'll learn what an API is and learn how to use one in our skill. We'll also learn about Wolfram Alpha and how we can use it to answer questions like: What's the distance to the moon? How many days until Christmas? What is the meaning of life?
Let's talk about questions
Before we go any further let's talk about questions. Before we start building a skill, it's important to understand the question being asked.
What states border California?
As humans, we are able to process most questions easily, but it's often harder to get computers to answer the same questions. In the example above, we are essentially asking 4 different questions:
What state is North of California? Oregon
What state is West of California? None
What state is South of California? None
What state or states are East of California? Nevada and Arizona
Even people might need a map for reference. It's simple to make a skill that listens for "What states border California?" But what if we wanted to change it to: "What states border Iowa?" How would we get this information without having to manually check each time, or even one time. How do we get computers do this? That's a much tougher question.
👂 What is Wolfram Alpha?
As a skill designer, your thought process should be:
- What is the user asking?
- Where can I find the information that they are asking?
- How to properly respond for the user?
Most of the time, the hardest part of this process has to do with how to find an answer to their question. This is where an amazing company and Chatterbox Partner comes in.
Meet Wolfram Alpha. According to its website,
WolframAlpha is a computational knowledge engine or answer engine.
In other words, WolframAlpha has lots and lots of different information that can be mixed, matched and computed with each using WolframAlpha technology. What does this mean for us? It means that we can simply ask it all sorts of questions in plain speech and get exactly the answer that we were looking for. It's AMAZING!
We are able to use Wolfram Alpha using their API which is short for "Application Programming Interface" which is a fancy way of saying that it is a building block that we can build with. We'll learn how in the next section.
Building an "Ask the wolf" skill
First, make sure you have the Internet extension enabled from the Extensions page.
Next, we need to figure out people will invoke (invoke means trigger or activate) the skill. For this skill, we'll keep it simple and use "Ask the wolf."
We'll be asking Wolfram Alpha all sorts of questions, so it's good practice to store these questions in a variable. Add the "question" variable to the When I hear block.
Finally, we want to search the Internet category for the Wolfram Alpha Short Answer block. This block uses the Wolfram Alpha API to search for answers and calculations from the entire Wolfram Alpha service. What's great is that it returns an answer that Chatterbox can speak.
Congratulations! You've just built a voice skill that integrates with the Wolfram Alpha API. Your final skill will look similar to this:
Special note: If you ask a question and Chatterbox responds with "Wolfram Alpha did not understand your input," it's because your question might have gotten cut off a little bit. To fix this, you can try speaking a little bit faster or you can shorten "Ask the wolf" to "Find" or whatever else you would like.
✅ Review
You've just turned your Chatterbox into a mini-supercomputer that not too long ago, would've been nearly impossible to create. Below are some questions to get you going:
What is the distance to the Moon?
How deep is the Pacific Ocean?
How many days until Thanksgiving?
What is the meaning of life?
What are words that rhyme with banana?
What states border California?
Where in the world is Carmen Sandiego?
How much wood could a woodchuck chuck?
What is 45 times 67?