No hay resultados
Today’s post comes from J. Michael Palermo IV, Sr. Evangelist at Amazon Alexa. Learn what steps you should take before developing with the Smart Home Skill API.
Before creating a skill, you must first determine if you want to build a custom skill or a smart home skill. Most skills are built using the Alexa Skills Kit (ASK) and are broadly known as custom skills. However, if the end goal is to enable a skill to have voice control over a device or appliance in the home, you will want to develop a smart home skill using the Smart Home Skill API.
Smart home skills differ from custom skills in these ways:
With the above differences in mind, your approach to creating a smart home skill may require more work to be done upfront than with a custom skill. However, know that with a smart home API skill, you wouldn’t need to define and maintain a language model yourself, and as Alexa improves its language model overall, you get the improvements for free.
Follow these steps to confirm you have what you need before developing a smart home skill. Start by following these five steps to meet the Smart Home Skill API prerequisites:
Sebastien Stormacq recently authored an excellent blog post providing step-by-step guidance to implement account linking for custom skills. While much of the information in that post applies here too, there are some differences in implementation details. This post will provide complete guidance for setting up account linking for smart home skills, with some admitted overlap to Sebastien’s post. For a fine overview of OAuth 2.0 and understanding of options, it may benefit you to read the first two sections of his post and then resume here.
If you have already created or chosen a specific OAuth 2.0 provider, you can proceed to the next step. If not, the remainder of this step will show how to fulfill this requirement by using Login with Amazon (LWA).
First, you need to create an LWA security profile. Here’s how:
Figure 1 : Access Login With Amazon.
Fill in all three required fields to create your security profile and click “Save”. For the purpose of this post, the privacy URL points to Amazon’s. Make sure to replace the link with a link to your own Data Privacy policy.
Figure 2 : Create Security Profile
Before you complete this step, be sure to click on the link named “Show Client ID and Client Secret” (see Figure 3) and copy revealed values to a text editor so they're easily available. You’ll need these values later in a future step.
Figure 3 : Collect Client ID and Client Secret
In this step, you will start the process of creating an Alexa skill.
Figure 4: Alexa Skills Kit
Figure 5: Create a New Alexa Skill
Figure 6: Interaction Model
Figure 7 : Skill Application ID
Skills developed with the Smart Home Skill API must be hosted in an AWS Lambda function. Here is how to create it.
Once in the AWS Console, select “Services,” then “All AWS Services,” and choose “Lambda.”
Figure 8: AWS Services
Figure 9 : Select blueprint
A new screen appears prompting for an Application Id. Enter the value you collected from step two (see Figure 7), and click the “Next” button.
Figure 10: Lambda Application Id
Figure 11 : Configure function
Figure 12 : Lambda function code
Figure 13 : Lambda function handler and role
Figure 14 : Lambda ARN
The skill started in the second step of this article will now be configured to support account linking.
Figure 15: Edit Skill
Figure 16 : Configuration
Figure 17: Configure Account Linking
Table 1 : Skill configuration values
Key |
Value |
Endpoint |
ARN value from skill adapter hosted in AWS Lambda function (See Figure 14) |
Authorization URL* |
(note that this is different from the authorization URL for custom skills as shown in Sebastien’s LWA blog post)
|
Client ID* |
The client ID value received from LWA during the first step. (See Figure 3) |
Domain List |
A list of up to 15 domains the authorization URL will fetch content from. No additional domain names were needed in this example. |
Scope* |
LWA supports several scopes. for this example, let’s use “profile”. This will allow your code to retrieve a unique Amazon userid, email address, and full name for the user. |
Authorization Grant Type |
“Auth Code Grant” is required for smart home skills. |
Access Token URI* |
This is the URI the Alexa Service needs to use to exchange an authorization code for a token and to refresh expired tokens. This is the same value for all Login with Amazon applications : https://api.amazon.com/auth/o2/token |
Client Secret* |
The client secret value received from LWA during the first step. (See Figure 3) |
Client Authentication Scheme * |
HTTP Basic (recommended) |
* Values provided are specific to LWA. If using another OAuth 2.0 provider, refer to its support documentation for how to obtain these values.
Figure 18 : Show this skill in the Alexa App.
You are finished with this step. You may optionally provide publishing information if you click the “Next” button, but it is not required in the context of this article.
This final step will take you full circle to the first step. A small but significant value needs to be added to the LWA profile for account linking to function correctly. Here is what to do.
Figure 19 : Login with Amazon Configurations
Figure 20 : Allowed Return URLs
Your LWA profile is complete. It is now time to confirm account linking was successfully configured by enabling the smart home skill in the Alexa companion app. Here is what to do.
Figure 21 : Your Skills
Figure 22 : Select smart skill in development
Figure 23 : Enable Skill
Figure 24 : Sign in
Figure 25 : Alexa has been successfully linked
Congratulations, you have met the prerequisites for creating a skill using the Smart Home Skill API.
What next?
Well if you recall, the code file in skill adapter was left blank. This was done to prove that enabling account linking with the Smart Home Skill API does not require code. However, accessing account values, enabling device discovery, and controlling devices all require code. These topics will be covered in upcoming articles, so stay tuned.