This is a fork of the Alexa High Low Game template skill that uses the Jargon SDK to manage content. This skill demonstrates the use of session and persistent attributes using Amazon DynamoDB and Amazon S3.
Each skill consists of two basic parts, a front end and a back end. The front end is the voice interface, or VUI. The voice interface is configured through the voice interaction model. The back end is where the logic of your skill resides.
Note: The High Low Game uses persistent attributes. When you create an Alexa-hosted skill, the persistence layer the sample code uses is Amazon S3. No configuration or additional setup is required to use the S3 bucket provided with an Alexa-hosted skill. When you create an AWS-hosted skill, the persistence layer the sample code uses is Amazon DynamoDB. The tutorial will walk you through any additional steps required to setup and access DynamoDB.
- Node.js (> v8)
- Register for an AWS Account
- Register for an Amazon Developer Account
- Install and Setup ASK CLI
-
Make sure you are running the latest version of the CLI
npm update -g ask-cli
-
Clone the repository.
ask new --url https://github.com/l-hartman/skill-sample-nodejs-highlowgame.git --skill-name high-low-game
ASK CLI will create the skill and the lambda function for you. The Lambda function will be created in us-east-1 (Northern Virginia)
by default.
- Navigate to the project's root directory. you should see a file named 'skill.json' there.
- Deploy the skill and the lambda function in one step by running the following command:
ask deploy
- Once deployed, additional permissions need to be added to the AWS IAM role being used by the function since it is persisting data in Amazon DynamoDB. Locate the execution role used by the skill's Lambda function in the AWS IAM Console.
- Open the AWS Console: https://console.aws.amazon.com/iam
- Click on Roles.
- Type (at least part of) the name of your skill in the search box. (Replace spaces with dashes.)
- Click the role that corresponds to your skill's function.
Note: If you can't find the correct role, first locate your skill's function in AWS Lambda. Scroll down to the section labeled Execution Role and find the role name there.
- On the right side of the Permissions tab, click + Add inline policy.
- Click the JSON tab.
- Select the existing JSON and replace it with the following policy document. This policy grants access to the role to (1) create the needed table and (2) read/write items to the table. It is restricted to this for just a table named 'High-Low-Game'.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DynamoDBTableCreationAndAccess", "Effect": "Allow", "Action": [ "dynamodb:CreateTable", "dynamodb:PutItem", "dynamodb:GetItem", "dynamodb:UpdateItem" ], "Resource": "arn:aws:dynamodb:*:*:table/High-Low-Game" } ] }
> Note: The table name as specified in the sample code is `High-Low-Game`. If you want to use a different name, change it in the policy and in the sample code. The name doesn't matter as long as they match.
- Click Review Policy.
- Enter
DynamoDBTableAccess
as the Name. - Click Create Policy.
-
To test, you need to login to Alexa Developer Console, and enable the "Test" switch on your skill from the "Test" Tab.
-
Simulate verbal interaction with your skill through the command line (this might take a few moments) using the following example:
ask simulate -l en-GB -t "start high low game" ✓ Simulation created for simulation id: 4a7a9ed8-94b2-40c0-b3bd-fb63d9887fa7 ◡ Waiting for simulation response{ "status": "SUCCESSFUL", ...
-
Once the "Test" switch is enabled, your skill can be tested on devices associated with the developer account as well. Speak to Alexa from any enabled device, from your browser at echosim.io, or through your Amazon Mobile App and say :
Alexa, start high low game
-
./skill.json
Change the skill name, example phrase, icons, testing instructions etc ...
Remember than many information are locale-specific and must be changed for each locale (en-GB and en-US)
See the Skill Manifest Documentation for more information.
-
./lambda/custom/index.js
Modify messages, and data from the source code to customize the skill.
-
./models/*.json
Change the model definition to replace the invocation name and the sample phrase for each intent. Repeat the operation for each locale you are planning to support.
-
Remember to re-deploy your skill and lambda function for your changes to take effect.
- Amazon Developer Forums - Join the conversation!
- Hackster.io - See what others are building with Alexa.
- Voice Design Guide - A great resource for learning conversational and voice user interface design.
- Codecademy: Learn Alexa - Learn how to build an Alexa Skill from within your browser with this beginner friendly tutorial on Codecademy!