Kevin Elgan
April 10, 2020

Day 10: Ask Wolfram Alpha

On day 10 of our 30-day skill challenge, we'll be teaching Chatterbox how to get answers to life's toughest questions. We'll be able to find out the distance to the moon, calculate the number of days until Thanksgiving and get the answer to what is the meaning of life.

Today we are going to learn how to teach Chatterbox how to find answers to some of our toughest questions. So far we've learned how to make Chatterbox respond to commands and get information. But what happens if we want to find an answer to a more complicated question, such as "What states border California?"

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:

  1. What is the user asking?
  2. Where can I find the information that they are asking?
  3. 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!

Let's build the skill and try it out!

Building the 'Ask Wolfram Alpha' 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 wolfram alpha"

Remember the double-sided text block can be found in the Data block category

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.

Adding the question variable let's you automatically store the question in a variable to use throughout your skill

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.

This expression makes Chatterbox speak the Wolfram Alpha answer to a question

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 wolfram alpha" to "Ask wolfram" or whatever else you would like.

Trying out the Wolfram Alpha service with Chatterbox

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?

We hope you enjoy your supercharged Chatterbox!

Chatterbox
Sign up for our newsletter to get the latest news, updates and discounts on Chatterbox.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram