Skip to content

This is a sample skill using a set of built in trivia questions that will allow developers to get a head start on their trivia game skill using buttons. It allows for roll-call of the players, asking trivia questions and determining whether the voice inputs matched the answers.

License

Notifications You must be signed in to change notification settings

cmaluend/skill-sample-nodejs-buttons-trivia

 
 

Repository files navigation

Echo Buttons Trivia Game Template

Important: The Gadgets Skill API is in beta and is subject to change at any time without notice. We welcome your feedback.

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.

Pre-requisites

Installation

  1. Clone the repository.

    $ git clone https://github.com/alexa/skill-sample-nodejs-buttons-trivia/
  2. Initialize the ASK CLI by Navigating into the repository and running the command: ask init and create a new profile called trivia-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
  3. Install npm dependencies by navigating into the /lambda/custom directory and running the npm command: npm install

    $ cd lambda/custom
    $ npm install

Deployment

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.

  1. Deploy the skill and the lambda function in one step by running the following command:

    $ ask deploy -p trivia-skill

Add DynamoDB permissions to the Lambda role

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

  1. Sign in to the AWS Management Console
  2. Navigate to the IAM Service console which is located under Compute services.
  3. 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-*
  4. On the Permissions tab, click the Attach Policy button
  5. In the search box, search for AmazonDynamoDBFullAccess, select the policy by clicking the checkbox to the left, and click the Attach Policy button at the bottom of the page.

Testing

  1. To test, you need to login to Alexa Developer Console, and enable the "Test" switch on your skill from the "Test" Tab.

  2. 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",
      ...
  3. 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
    

Customization

  1. ./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.

  2. ./lambda/custom/index.js

    Modify messages, and facts from the source code to customize the skill.

  3. ./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.

Additional Resources

Community

Tutorials & Guides

  • 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.

Documentation

License

This library is licensed under the Amazon Software License.

About

This is a sample skill using a set of built in trivia questions that will allow developers to get a head start on their trivia game skill using buttons. It allows for roll-call of the players, asking trivia questions and determining whether the voice inputs matched the answers.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%