Important: The Gadgets Skill API is in beta and is subject to change at any time without notice. We welcome your feedback.
These instructions show how to create a simple skill called Hello Buttons. This skill demonstrates how to send directives to, and receive events from, Echo Buttons.
Note: Hello Buttons demonstrates how to use the Gadget interfaces (GameEngine and GadgetController). It is not intended to be a comprehensive example. For an end-to-end skill, please refer to the Color Changer skill in the Alexa Github.
This sample skill uses:
- The developer portal to configure the skill and specify the interaction model
- The Node.js framework for the skill code
- AWS Lambda to host the skill
- The Alexa Skills Kit (ASK) SDK for Node.js to simplify the skill code
- Hello Buttons Skill Flow
- Preparation
- Step 1: Create the Deployment Package
- Step 2: Upload the Deployment Package to AWS Lambda
- Step 3: Find the ARN of the Lambda function
- Step 4: Create the Skill
- Step 5: Create an Interaction Model
- Step 6: Select Gadget Interfaces
- Step 7: Enter the Endpoint
- Step 8: Enter Publishing Information
- Step 9: Enter Privacy and Compliance Information
- Step 10: Enable the Skill in the Alexa App
- Step 11: Invoke the Skill
- License
When the Hello Buttons skill begins, it will send animation directives for the three possible trigger events (buttonDown
, buttonUp
and none
) to all the Echo Buttons. Alexa will then ask you to press the buttons, and an audio file will play.
When you press a button, the skill will interrupt Alexa's speech. If the button that you pressed is not awake, the skill will initialize the button by sending animation directives for buttonDown
, buttonUp
and none
to that button. This is different from the original LaunchRequest
intent, which sent initialization directives to all buttons.
If the pressed button wakes up, you will see a different color on buttonDown
and buttonUp
events, as well as a breathing animation for the none
event. If you cancel the skill (for example, by saying "Alexa, cancel") or the Input Handler expires, the buttons will fade from white to black.
Before you create the Hello Buttons skill, you must take the following steps:
-
Create an Amazon developer account If you don't already have an Amazon developer account, go to the developer portal and select Sign In in the upper right to create a free account.
-
Sign up for AWS If you haven't already, sign up for AWS by going to AWS Free Tier. For most developers, the AWS Lambda Free Tier is sufficient for the function that supports an Alexa skill.
-
Get Echo Buttons This skill requires two Echo Buttons.
- Clone the repository.
$ git clone https://github.com/alexa/skill-sample-nodejs-buttons-hellobuttons/
- Install npm dependencies by running the npm command
npm install
from the directory of the repo you just cloned in the previous step.
$ cd skill-sample-nodejs-buttons-hellobuttons
$ npm install
- Create an archive to upload to AWS Lambda.
$ zip -r -X ../HelloButtonsDeploymentPackage.zip *
In this step, you upload create an archive of the skill code and supporting modules and upload the archive to AWS Lambda. Later, when you set up the skill in the developer portal, you will specify that this function is the endpoint for the skill.
- Sign in to the AWS Management Console and navigate to the AWS Lambda console, which is located under Compute services.
- Using the region selector at the top right of the page, select US East (N.Virginia).
- Select Create function.
- Select Author from scratch.
- For Name, enter
HelloButtons
. - For Runtime, select Node.js 6.10.
- For Role, select Create new role from template(s).
- For Role name, enter
HelloButtonsRole
. - From the Policy templates list, select Simple Microservice permissions.
- In the lower right, click the Create function button. The function might take a moment to create.
- Under the Function code section, for Code entry type, select Upload a .ZIP file. Then click Upload and choose the
HelloButtonsDeploymentPackage.zip
file. - For Runtime, select Node.js 6.10.
- Under the Designer section, under Add triggers, select the Alexa Skills Kit option, and then select the Add button in the lower right.
- At the top of the page, select Save.
In this step, you find the Amazon Resource Name (ARN) of the Lambda function that you just created. The ARN serves as the ID of the function. You can find the ARN at the top right of the Hello Buttons function page in the AWS Lambda console. The ARN will look something
like arn:aws:lambda:us-east-1:012345678910:function:HelloButtons
.
Copy the ARN. Later, when you set up the Hello Buttons skill in the developer portal, you will provide this ARN as the endpoint for the skill.
Next, create the skill in the developer console by using the following steps:
- Sign in to the Alexa Skills Kit developer console.
- Select Create Skill.
- For Skill Name, enter Hello Buttons, and then select Next in the upper right.
- For Choose a model to add to your skill, select Custom, and then select Create Skill in the upper right.
Important: If you get an 'unspecified error' when performing any of the remaining steps, try logging out and then logging back in to the developer console.
Continuing from the previous step, do the following:
- On the left side, select Invocation.
- For Skill Invocation Name, enter
hello buttons
, and then select Save Model. - On the left side, select Intents.
- Select Add Intent.
- Under Create custom intent, enter
LaunchIntent
, and then select Create custom intent. - For Sample Utterances, enter the following text:
Open Hello Buttons
- On the right side of the text field, select the + sign.
- At the top of the page, select Save Model.
- Select Build Model. The model might take a moment to build.
Continuing from the previous step, do the following:
- On the left side, select Interfaces.
- In the Alexa Gadget row of the interface list, select Gadget Controller and Game Engine.
- At the top of the page, select Save Interfaces.
Continuing from the previous step, do the following:
- On the left side, select Endpoint.
- For Service Endpoint Type, select AWS Lambda ARN.
- In the Default Region field, paste the ARN of the Lambda function that you created in an earlier step. Leave the other options at their default values.
- At the top of the page, select Save Endpoints.
Continuing from the previous step, do the following:
- At the top of the page, select Launch.
- For One Sentence Description and Detailed Description, enter
This is a sample skill for Echo Buttons.
- For Example Phrases, enter
Alexa, open Hello Buttons
. - For Echo Button Use, select Required.
- For Number of Echo Buttons, select a Min of 2 and a Max of 4.
- For Number of Players, select 1 for both Min and Max.
- Skip the icon part for now.
- For Category, select Games.
- At the bottom of the page, select Save and continue.
Continuing from the previous step, do the following:
- For Does this skill allow users to make purchases or spend real money?, select No.
- For Does this Alexa skill collect users' personal information?, select No.
- For Is this skill directed to or does it target children under the age of 13?, select No.
- For Does this skill contain advertising? select No.
- For Export Compliance, select the checkbox.
- For Testing Instructions, enter
None
. - At the bottom of the page, select Save and continue.
- Again, select Save and continue to accept the default options on the Availability page.
You should now be on the Submission page, which will tell you that fixes are required (to add icons). You don't need to add icons now because you can test the skill without submitting it for certification.
Your Hello Buttons skill is in the development state and available for you to test with your Amazon Echo device and your Echo Buttons. First, you must ensure that the skill is enabled in the Alexa app. To check this, do the following:
- Go to the web version of the Alexa app and sign in with your Amazon developer account.
- Choose Skills from the main menu.
- In the upper right, choose Your Skills.
- Using the search bar, search for the Hello Buttons skill.
- Select the skill.
- Select ENABLE.
Pair your Echo Buttons to your Amazon Echo device, and then invoke the Hello Buttons skill by saying "Alexa, open Hello Buttons". The skill should run as described in the skill flow.
This library is licensed under the Amazon Software License.