Tutorial: The Alexa Skill – Amazon Alexa and OurWeather – Part 3

Tutorial: The Alexa Skill – Amazon Alexa and OurWeather – Part 3

We are pleased to announce Version 026 of the OurWeather software and the big change is that we now support the Amazon Alexa, Echo, Echo Plus, and all other Amazon Voice systems.   In this series of tutorials we will show you how to connect up the Alexa systems in your house to your OurWeather station.   We will be rolling this really cool feature set into our other major kit offerings including:

 

This is a five part instructional tutorial to get your Amazon Alexa to OurWeather Interface working.  All source code is provided!

While we are focusing on OurWeather in this series, the techniques we developed are good for many projects.

 

 

 

The Alexa Voice to OurWeather Project

There are four major parts to this project.

  • PubNub – MQTT Broker between OurWeather and the AWS Lambda functionAlexa
  • The Alexa Skill – Controls Alexa on Echos in your house
  • The AWS Lambda Serverless Function for brokering information from PubNub to the Alexa Skill
  • OurWeather – MQTT Publisher Weather Information to PubNub

In part 3, we address the Alexa Skill on Amazon.

Setting up the Alexa Skill

The Alexa skill talks to the Amazon Echo or other Alexa device in your home.   It is a bi-directional link, sending recorded voice for translation to text by the Amazon servers, and then returning text that will be rendered as voice through the Alexa device.

Following are the steps for setting up an Amazon Skill on developer.amazon.com. If you’ve done this before, just copy the intents, and sample utterances, and skip to part 4.  Copy and paste your App ID and keep it for Part 4.

We will need to tell the Alexa Skill what phrase (“invocation”) we want it to respond to (“Ask OurWeather” in this case),which will activate our app (“skill”) and then what commands (“intents”) to listen for. We also specify what end point it should ping (which we will generate in part 4 – the Lambda Function).

Set up your Free Developer Account

Make a new Account on developer.amazon.com.   Make sure you use the same Amazon account name and password that you use on your Echo devices or else you won’t be able to talk to your Alexa Devices.

Once you are logged in you should see a screen like this.  Click on the Amazon Alexa link.

 

 

Next click on “Add Capabilities to Alexa” as shown below:

 

 

Then click on “Start a Skill” and we are off to the races.

 

 

Building Your Skill

 Now we’ll give Amazon some information about your application.  If you want to change some of this, you will be able to do that later.   The names you use for this Alexa Skill are unique to your account.  If we were to publish this (which we will NOT be doing – it is only for your own account) we would need to have a more unique name.

 

  • Leave skill type as “Custom Interaction Model”
  • Type in “OurWeather Alexa App” for the name
  • Type in “our weather” for the invocation (this is what we’ll say to activate this Alexa app)
  • Leave the other fields at “no”

You should have a screen that looks like this:

 

Alexa

Click “save” and then the application ID will be generated. Do a cut and paste and save this application ID. We will need it for the Lambda function.  Your screen will then look the this.  Note:  This application ID below will not work.  It has been disabled.  You must use your own.

 

 

Now click “Next” to continue or on the “Interaction Model” tab to the left.

Enter the Intent Schema and Utterances

When you create a custom skill, you implement the logic for the skill, and you also define the voice interface through which users interact with the skill. To define the voice interface, you map users’ spoken input to the intents your cloud-based service can handle.   This is done by inputting Intents and Utterances .

  1. Intents: An intent represents an action that fulfills a user’s spoken request. Intents can optionally have arguments called slots, which we will not be using.  The Intents are entered using JSON format (see part 1).
  2. Utterances: A set of likely spoken phrases mapped to the intents. This should include as many representative phrases as possible.   This is entered in the form:  Name of Intent (from above) on right and the phrase a user might speak to signal that intent on the right.
  3. Custom slot types: A representative list of possible values for a slot. Custom slot types are used for lists of items that are not covered by one of Amazon’s built-in slot types.  We are not using this in the OurWeather Skill, but we could.
  4. Dialog model (optional): A structure that identifies the steps for a multi-turn conversation between your skill and the user to collect all the information needed to fulfill each intent. This simplifies the code you need to write to ask the user for information.   We will not building a dialog model for our simple skill.

BTW, do NOT CLICK the Launch Skill Builder Beat at this time.  If you do, go to the bottom of the Skill Builder and click “opt-out of the bata program”.   It’s not ready for what we want to do.

Copy and paste the following JSON into the Intent Schema box.   We are building a pretty simple skill with simple intents.   These intents will show up as input to our AWS Lambda function in Part 4.

{
  "intents": [
    {
      "intent": "status"
    },
    {
      "intent": "about"
    },
    {
      "intent": "timestamp"
    },
    {
      "intent": "inside"
    },
    {
      "intent": "rain"
    },
    {
      "intent": "wind"
    },
    {
      "intent": "temperature"
    },
    {
      "intent": "humidity"
    },
    {
      "intent": "solar"
    },
    {
      "intent": "link"
    },
    {
      "intent": "airquality"
    },
    {
      "intent": "AMAZON.HelpIntent"
    },
    {
      "intent": "default"
    }
  ]
}

Next copy and paste the following into the Sample Utterances Box. Note that they are of the form “intent” “phrase”, where intent is from the above Intent Schema box.

status tell me status
status tell me all
status status
status give me status
status give me all
about about
about tell me about
about tell me about you
about tell me about our weather
about Where can I buy you
about buy smart plant
about tell me about you
timestamp timestamp
timestamp when was the last value
inside temperature tell me inside temperature
inside temperature inside temperature
inside temperature give me inside temperature
temperature tell me temperature
temperature temperature
temperature give me temperature
humidity tell me humidity
humidity humidity
humidity give me humidity
solar tell me solar
solar solar
solar give me solar
link tell me link
link link
link give me link
airquality tell me air quality
airquality air quality
airquality give me air quality
AMAZON.HelpIntent help
AMAZON.HelpIntent help me
AMAZON.HelpIntent tell me what you can do
default Pardon

Your screen should now look like the following screen:

Now Click Save and then click Next.

Configuration Screen

This is the screen where we tell Alexa where to go when we send one of our commands.  It can be any endpoint or server (we have used it to point to a web server on a Raspberry Pi for example).    What we will be doing is pointing it an Amazon Lambda function for simplicity and since we don’t need the function to run all the time.  We can use the serverless Lambda function.

We will come back to this screen once we have built our Lambda Function.  We’ll come back to enter in the AWS Lambda ARN as the endpoint. Remember to make note of your Alexa app id as we’ll need it in the Lambda code.

Test, Publishing Information and Privacy & Compliance Tabs

We can safely ignore all of the other screens at this point.   The Test tab is something we can come back to later.

Now on to the Lambda function!

Coming Next

In Part 4, we set up the Lambda function, in part 5 we setup OurWeather and tie it all together.

There are no comments so far

Leave a Comment

Don't worry. We never use your email for spam.

Don't worry. We never use your email for spam.

%d bloggers like this: