On day 14 of our 30-day skill challenge, we continue learning about date and time to build a Chatterbox alarm clock!
Let's continue our journey with time to learn how we can teach Chatterbox to wake you up to your favorite song.
While a timer is for a specific duration of time, alarms will alert you when the system date/time matches your "wake up" time.
Just in the previous timer skill, the mechanism for both timers and alarms are the same: date/time objects. But in practice there are a couple subtle differences.
Since, alarms and timers are essentially the same building blocks, we are going to look at our timer code as a starting point and build out our alarm skill from there.
Let's start with how we'll be asking for an alarm. You might say "Set an alarm for 7am" or "Wake me up at 7am." Instead of the duration variable, we'll need a "time" variable. After these changes, your skill should look like this:
Now the general actions inside the Listen block that are needed are the same, but the variables, event name and speech needs to be altered. We'll now be extracting date from "time" instead of "duration."
It's also good practice to name the event, so we can call this alarm. The When slot will remain the same with Extracted_date.
Last of all, we need to program the action that we want. We'll be using a Speak block to speak a custom wake up message, then we'll be using the Play Audio block to play your favorite song from Youtube.
Inside the Schedule Event block should look similar to this:
For this skill, we'll be waking up to Viva la Vida by Coldplay https://www.youtube.com/watch?v=dvgZkm1xWPE
Last step will be to acknowledge the user that the alarm has been set.
Your skill should look something similar to the following:
Chatterbox has a couple very basic skills to make it easier for you. There are built-in welcome skills, volume skills, and a Stop skill. To turn off the alarm, push the big yellow button and say "Stop" and Chatterbox will stop the current action.