Skip to content

Companion project to the MMM-Alexa project. This is the Alexa skill that communicates with the Magic Mirror MMM-Alexa via the AWS IOT Gateway.

License

Notifications You must be signed in to change notification settings

boghammar/MMM-AlexaSkill

Repository files navigation

MMM-AlexaSkill

This is an AWS Lambda deployed Alexa skill that communicates with the MagicMirror module MMM-Alexa via the AWS IOT Gateway.

This work is inspired by joanaz Mirror Mirror On The Wall Alexa Skill. Major difference is that this implementation use the alexa-app SDK instead of the alexa-skills-kit-sdk-for-nodejs for creating the skill and of course there are other features of the skill.

The main features that I developed this skill for was:

Installation

  1. Install the MMM-Alexa module in your Magic Mirror installation
  2. Clone this repository with git clone https://github.com/boghammar/MMM-AlexaSkill.git
  3. Install dependencies by cd MMM-AlexaSkill and then npm install
  4. Setup an AWS IOT device according to the instructions below
  5. Configure your skill with the credentials from the AWS IOT device creation
  6. Deploy your code to AWS Lambda (see below)

Setup an AWS IOT device

Configure your skill

Deploy your code to AWS Lambda

Preparing the zip file

Since this skill relies on AWS IOT to communicate with the Magic Mirror you need to deploy your certificates along with the code when deploying to AWS Lambda. For that purpose use the utility prepareDeploy.js to pack the correct files for deployment. What this utility does is

  1. Find out the secret directory by reading the Alexa.configPath in the package.js file.
  2. Reads the Alexa.configPath+/deployConfig.js file that contains the following parameters
// This is the deploy configuration for MMM-AlexaSkill
var cfg = {
	IOTEndpoint: 'apt******.iot.us-east-1.amazonaws.com',
	certPath: 'C:/_data/dev/certs', // Where are the certificates
	certID: '16cc68c66f'            // Whats the prefix of the certificate files
}
module.exports = cfg;
  1. Copies the certificates files to the directory ./certs within your source tree
  2. Copies the deployConfig file to the directory ./certs within your source tree
  3. Zips all necessary source files (including the node_modules directory) along with the ./certs directory.

The resulting zip file can then be uploaded using the AWS Lambda Console.

Create intents and utterances

The utility createUtterances.js is used to create the files alexa/schema.txtand alexa/utterances.txt. The contents of these files can be pasted into the appropriate windows in the Amazon Alexa Skill configuration.

Message format

The messages sent from the skill to the IOT device have the following format:

{
    "module": "nameofmodule",
    "body": {
        // Module specific module data
    }
}

for instance the SonosPlay module takes this message

{
    "module": "SonosPlay",
    "body": {
        "action": "play",
        "what": "beatles",
        "from": "spotify",
        "where": "kitchen"
    }
}

the MMM-Video module takes this message

{
    "module": "MMM-Video",
    "body": {
        "action": "play",
        "video": {
            "ix": 0
        }
    }
}

About

Companion project to the MMM-Alexa project. This is the Alexa skill that communicates with the Magic Mirror MMM-Alexa via the AWS IOT Gateway.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published