Important: The Gadgets Skill API is in beta and is subject to change at any time without notice. We welcome your feedback.
- [08/03/2018] Updated for ASK SDK Version 2
This template offers a starting point for you to build your own Trivia Game skill featuring Echo Buttons. The template implements roll call and a game loop that handles asking and answering trivia questions. It handles receiving Echo Button events as well as animating the Echo Buttons lights.
Note You may use this template as a starting point to build your own trivia game skill. You can customize the questions list and some game parameters without making any code changes although in order to provide a unique game experience, you may have to make some code changes.
This sample skill uses:
- The node.js framework (>= v8.10) for the skill code
- The Alexa Skills Kit (ASK) SDK for Node.js to simplify the skill code
- AWS Lambda to host the skill
- Amazon DynamoDB to save a state table (Optional)
- An animation library to create simple animations such as fade out and breathe, as shown in Animations.
- A fully configurable settings file to customize your game without having to write code.
- A list of questions and answers you can modify to create your own game without modifying the game code. Note this will require you to update slot values in your skill's language model.
- Node.js (> v6.9)
- Register for an AWS Account
- Install and Setup AWS CLI
- Configure a named AWS CLI Profile
- Register for an Amazon Developer Account
- Install and Setup ASK CLI
-
Clone the repository.
$ git clone https://github.com/alexa/skill-sample-nodejs-buttons-trivia/
-
Initialize the ASK CLI by Navigating into the repository and running the command:
ask init
and create a new profile calledtrivia-skill
. Follow the prompts to configure the profile and associate it with one of your AWS profiles$ cd skill-sample-nodejs-buttons-trivia $ ask init
-
Install npm dependencies by navigating into the
/lambda/custom
directory and running the npm command:npm install
$ cd lambda/custom $ npm install
ASK CLI will create the skill and the lambda function for you. The Lambda function will be created in the region associated with the AWS profile that you selected.
-
Deploy the skill and the lambda function in one step by running the following command:
$ ask deploy -p trivia-skill
The ASK CLI automatically created a role for your lambda function to run under that can execute lambda functions and write to cloudwatch logs, but since we are using the built-in persistence of the Alexa Skills Kit for NodeJS SDK, we need to add a policy that will allow the role to create/read/write to DynamoDB
- Sign in to the AWS Management Console
- Navigate to the IAM Service console which is located under Compute services.
- Click Roles on the left side bar and find the role created for you by the ASK CLI. The name should start with
ask-lambda-*
- On the Permissions tab, click the
Attach Policy
button - In the search box, search for
AmazonDynamoDBFullAccess
, select the policy by clicking the checkbox to the left, and click theAttach Policy
button at the bottom of the page.
-
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 using the following example:
$ ask simulate -l en-US -p trivia-skill -t "alexa, open buttons trivia" ✓ 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, open buttons trivia
-
./skill.json
Change the skill name, example phrase, icons, testing instructions etc ...
Remember that many information is 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 facts 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.
- 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.
- Color Changer Sample - A simpler skill that shows how to do roll call and control light animations for Echo Buttons.
- Official Alexa Skills Kit Documentation - Official Alexa Skills Kit Documentation
- Alexa Skills Kit Node.js SDK v1 - Note that Alexa Skills Kit Node.js SDK v2 is now available but this skill is built using Alexa Skills Kit Node.js SDK v1.
This library is licensed under the Amazon Software License.