The Smart Home Skill API is a new addition to the Alexa Skills Kit, which enables developers to add capabilities, called skills, to Alexa. With this new API you can teach Alexa how to control your own cloud-controlled lighting and thermostat devices. For example, customers can simply say, “Alexa, turn on the kitchen lights” or “Alexa, turn up the heat downstairs” and Alexa will communicate directly with your Smart Home device. Smart home skills are created in the same developer portal as existing custom skills and follow a similar process.
To create your smart home skill, you’ll first configure your skill using a new Smart Home Skill API flow in the developer portal. Ensure you have selected the Smart Home Skill API skill type, enter a Name for your skill and then simply click Next.
Unlike custom skills, smart home skills already have an existing interaction model for you. This means you won’t have to define the intent schema and sample utterances like you would in a custom skill. Click Next to move to the Configuration tab.
The configuration tab will be where you set up your skill adapter and skill authorization, via oAuth. The skill adapter translates between Alexa’s skills and your device’s proprietary control systems, as the means to relay discovery and control commands from Alexa to your device control cloud. Alexa acts as an OAuth client and requests resources from the device control cloud. To facilitate this, you will need to provide information about your OAuth server information when creating a skill adapter so the user of the application can grant permissions for Alexa to retrieve device information. That information can then be used to control those devices.
We will be using AWS Lambda to create our skill adapter using a Lambda blueprint that has already been created for us to quickly get started. To get started, sign in to your AWS Account, and create the Lambda function. To do this:
Your final event sources configuration screen should look similar to this:
In addition, for a control request, the name specifies the kind of request. In this example code, the only request type handled is aTurnOnRequest. You should handle every type of request a user would make to your skill. For information about all of the request and response messages, see Smart Home Skill API Reference.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
def lambda_handler(event, context): access_token = event['payload']['accessToken']
if event['header']['namespace'] == 'Alexa.ConnectedHome.Discovery': return handleDiscovery(context, event)
elif event['header']['namespace'] == 'Alexa.ConnectedHome.Control': return handleControl(context, event)
def handleDiscovery(context, event): payload = '' header = { "namespace": "Alexa.ConnectedHome.Discovery", "name": "DiscoverAppliancesResponse", "payloadVersion": "2" }
if event['header']['name'] == 'DiscoverAppliancesRequest': payload = { "discoveredAppliances":[ { "applianceId":"device001", "manufacturerName":"yourManufacturerName", "modelName":"model 01", "version":"your software version number here.", "friendlyName":"Smart Home Virtual Device", "friendlyDescription":"Virtual Device for the Sample Hello World Skill", "isReachable":True, "actions":[ "turnOn", "turnOff" ], "additionalApplianceDetails":{ "extraDetail1":"optionalDetailForSkillAdapterToReferenceThisDevice", "extraDetail2":"There can be multiple entries", "extraDetail3":"but they should only be used for reference purposes.", "extraDetail4":"This is not a suitable place to maintain current device state" } } ] }
def handleControl(context, event): payload = '' device_id = event['payload']['appliance']['applianceId'] message_id = event['header']['messageId']
if event['header']['name'] == 'TurnOnRequest': payload = { }
header = { "namespace":"Alexa.ConnectedHome.Control", "name":"TurnOnConfirmation", "payloadVersion":"2", "messageId": message_id } |
To finish registering your skill, you must configure OAuth 2.0 for your skill. You can use Login with Amazon or another provider for this section.
The following fields are required:
To learn more about Authorizing Alexa users with your Smart Home Skill check out the Linking an Alexa User with a User in Your System guide here.
You can now test your smart home skill by using it with your own Alexa-enabled device. To do this:
Like custom skills, smart home skills must pass our certification process before they go live. Learn more about our certification process here. Approved smart home skills will be available for customers in the Alexa app by the end of April.
To start this process, do the following:
You have now successfully created and submitted a smart home skill for certification. If you have questions during the certification process you can reach the team directly here and selecting Alexa from the drop down subject.
With the recent launch of Echo Dot and Amazon Tap, there are more ways than ever to control smart home devices like lights, switches, plugs, and thermostats using Alexa. To help customers find, discover and buy Alexa-compatible smart home devices, today we also introduced a refreshed Alexa Smart Home store. The store allows customers to shop smart home products by brand or solution and it offers brands new opportunities to get their products noticed by Alexa customers. To learn more, visit www.amazon.com/alexasmarthome.
For more information about getting started with Alexa Smart Home skills, check out the following additional assets:
Smart Home Skill API
Understanding the Smart Home Skill API
Creating a Smart Home Skill
Smart Home Skill API Reference
Alexa Training with Big Nerd Ranch
Intro to Alexa Skills On Demand
Voice Design 101 On Demand
-Dave (@TheDaveDev)