SHOP NOW

Shopping Cart

No products in the cart.

SHOP NOW

Shopping Cart

No products in the cart.

Kevin Elgan
April 12, 2020

Day 12: What time is it in Timbuktu?

On day 12 of our 30-day skill challenge, we'll be learning about Date / Time objects and how we use them to teach Chatterbox to how to tell time around the world.

So far we've learned how to get weather based on your location or find answers to complicated questions. But what if we wanted answers to simple questions like "What's the date?" or "What time is it in Paris?"

Did you know that every computer has an internal clock that keeps track of time? The problem is that the internal clock of most computers use a special date/time format that makes it hard for people to read and use. But if you understand some basics about Date/Time, making skills using date and time is very easy.

Let's talk about Date / Time objects

What exactly is a Date/Time object? For computers, knowing the exact date and time in a human-readable format isn't necessary. But if you were to ask Chatterbox what the time was it wouldn't help if it responded with "1586760036."

That's because the computers store information in ways that make it easy to work with, but all this changes when you are talking to a computer like Chatterbox and need to respond to commands.

The Get Current Date Time block returns the current date/time in an easy to use way

You can use the Get current Date Time blocks to get the current date time, but what if you want Chatterbox to Speak it? In order to accomplish this, we've created a handful of special blocks to translate Date / Time from computer speak to a human readable format.

The Pronounce time and Pronounce date blocks translate the date/time block into something that we can understand

The Pronounce Time and Pronounce Date blocks are special blocks that translate date/time objects (in this case the Get current date time block) into a format that we can understand.

Let's put it all together

Now that we've covered the basics, let's build a date and time skill that will give us the time for any location in the world.

Quick review: We use the When I hear block whenever we have an exact match for how we would like to invoke a skill. We use the On Phrases block whenever we want multiple ways of invoking (or activating) a skill.

Use the When I hear block if there is only one way to make requests. The On Phrases block is when you want Chatterbox to listen for multiple utterances.

When asking about time, you might say: "What time is it?" or "What's the time?" So we'll be using the On Phrases block. Try to think of all the ways that people will ask for the time.

Next, you are going to use the Speak block with a Pronounce Time block that will translate the Current Data Time block data into a format that we'll understand.

Completed time skill

To get the time in a "location," we'll make a similar skill to the time skill above, but will need to create a "location" variable. We'll also need to use the Get Current Date/Time in [location] instead of the regular block.

For the time in location skill, you'll need to create a location variable to use the current date/time in block

The Date skill follows the same pattern as the time skill, except that you use the Pronounce Date block to extract and speak the date.

Your final skill should look something similar to this:

Get a 10% discount code when you sign up for our newsletter!

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