Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 4.6 KB

README.md

File metadata and controls

63 lines (44 loc) · 4.6 KB

Alexa Smart Properties Smart Home Sample Skill

Skill Open

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.

Skill Overview

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

About

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.

Pre-requisites

Additional Documentation

Code Layout

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

Guide Contents

  1. Skill Overview ⇐ (You are here)
  2. Initialization and Setup: Cognito and DynamoDB
  3. Skill Deployment
  4. Skill Enablement
  5. Delegated Account Linking
  6. Smart Home Features