This Alexa sample skill demonstrates how to build a skill for Alexa Smart Properties that utilizes Delegated Account Linking. The skill supports both Authorization and Delegation flows but the emphasis is on learning how to extract the delegated scope/partition value from an Alexa request in order to properly segment device control to individual rooms while allowing the convenience of a single account link. This is in contrast to to the consumer/authorization flow in which one would have to manage and link separate 3P accounts for each room on property.
You may use this sample skill as a starting point to build your own Alexa Smart Properties Smart Home skill, though significant changes will be necessary to properly customize it for your back end service.
This skill can be linked to units in a building via Account Linking Delegation Flow or Account Linking Authorization Flow. In either case three "dummy" Smart Home devices will be created for the link - a light, a thermostat, and an interior blinds. The state of these "dummy" devices will be stored in DynamoDB and Account Linking credentials will be managed by Cognito.
The following are example utterances for controlling the devices.
- "Alexa, turn on the light" - Turns on the light
- "Alexa, turn off the light" - Turns off the light
- "Alexa, open the blinds" - Opens the blinds
- "Alexa, close the blinds" - Closes the blinds
- "Alexa, set the thermostat to sixty eight" - Changes the setpoint of the thermostat to 68 F
- "Alexa, make it warmer in here" - Increases the setpoint of the thermostat by 2 degrees F
- "Alexa, what's the temperature in here?" - Responds with the current temperature
This is not meant to be step by step guide to walk you through the fundamentals of skill development and deployment. There are plenty of guides to help in this area available on the Alexa GitHub page. Instead the focus will be going into detail on features helpful or specific to Alexa Smart Properties.
This guide assumes you have your developer environment ready to go and that you are familiar with Alexa Skill development, Node.js/Javascript, CLI (Command Line Interface) Tools, AWS, and the ASK Developer Portal.
- Node.js (> v20)
- Register for an Amazon Business Account
- Register for an AWS Account
- Register for an Amazon Developer Account
- Official Alexa Smart Home Developer Documentation - The official documentation covering all Smart Home features in Alexa
- Official Alexa Skills Kit Node.js SDK - The official Node.js SDK Documentation
- Official Alexa Skills Kit Documentation - Official Alexa Skills Kit Documentation
- Official Alexa Smart Properties Documentation - Alexa Smart Properties enables property owners and managers to deploy and manage Alexa-enabled devices at scale.
Code is organized is standard ASK CLI v2 form. Here are some file descriptions to aid finding specific features...
./lambda/cognito.js # Interact with Cognito to pull profile information
./lambda/constants.js # Centralized skill configuration
./lambda/ddb.js # DynamoDB Client for reading and storing device state
./lambda/index.js # Lambda entry point
./lambda/response.js # Helper for generating Alexa response directives
./lambda/smarthome.js # Smarthome discovery, control, reporting
- Skill Overview ⇐ (You are here)
- Initialization and Setup: Cognito and DynamoDB
- Skill Deployment
- Skill Enablement
- Delegated Account Linking
- Smart Home Features