How To Build Your Own Amazon Echo Skill: Testing and Customization (Part 3)

DZone 's Guide to

How To Build Your Own Amazon Echo Skill: Testing and Customization (Part 3)

Before publishing your Alexa skill, it's important to test and tweak. In addition to some of Amazon's best practices recommendations, this guide will get your skill up to par.

· IoT Zone ·
Free Resource

This article is part of the 4-part series about how to build your very own Amazon Echo skill. If you just landed here, you can go back to Step Two: How To Build Your Own Amazon Echo Skill: Building It or start from step one here.

In this series of four articles, we explore how and why you should build an Alexa Skill. In this Part 3 of 4 article let’s dive into the steps to test and customize your skill below.

Step Three: Test Your Alexa Skill

Open your Alexa Skill

In the Service Simulator, type “open {Alexa skill name}” and select “Ask My Fact Skill”:

You should see a formatted JSON request from the Alexa Service and your Lambda function’s response. Review to make sure the Lambda response is correct and make note of the the card output. You may want to customize this later.

Tweak Your Code and Continue Testing

You can test your Lambda responses with your Echo device. Make sure it is online and you’re logged in to your developer account. You should see your skill enabled in the Alexa app. We recommend recruiting 3-5 testers to test your Alexa skill to make sure you’ve covered all the possible commands people can come up with to activate it. Once you’ve finished testing your code, click “Next”.

Step Four: Customize Your Alexa Skill

Replace Space Facts With Your Own

Unzip the FactSkillTemplate.zip file you downloaded earlier and open index.js in a text editor. On line 10, you’ll find an array of space facts. Replace these strings with your custom facts. Input one fact per line. Take care not to delete any quotation marks and commas:

Enter Your Alexa Responses/Facts

Amazon recommends adding close to 100 responses/facts to prevent them from repeating too often. To add facts, edit the name of the array. Change the name SPACE_FACTS to something that represents your fact type. Then use “Find” to locate the other instances of SPACE_FACTS in the code and rename them as well.

Change references of “Space Geek” to the name of your skill. Go back to your Alexa skill in the developer console and select the Skill Information area (from the left sidebar). Copy your Application ID (It will look something like this: “amzn1.echo-sdk-ams.app.2e4bc136...”).

Upload the New ZIP File Containing Your Custom Facts to the Lambda Function

In the index.js file, look for this bit of code:

* App ID for the skill

var APP_ID = undefined; //replace with "amzn1.echo-sdk-ams.app.[your-unique-value-here]";

Replace “undefined” with your Application ID [inside the quotes], followed by a semicolon. Click Save.

Zip your newly updated index.js file and nd node_modules folder (from the ZIP archive you downloaded earlier) into a new ZIP archive. Your new .zip file should have your customized index.js file and node_modules folder.

Go back to your Lambda function in the AWS console, and under the Code tab, upload the new zip archive. Click Save.

Test your skill as you did earlier, tweaking your code where necessary. Click “Next” when you’re done testing to publish your Alexa skill!

Action Items for Building Your Own Amazon Echo Skill (Part 3)

Following the steps above, test your Alexa skill to make sure it works the way you intended it to. Then, you can customize it with your own responses to the voice commands:

1. Replace space facts with your own.

2. Enter your Alexa responses/facts.

3. Upload the new zip file containing your custom facts to the Lambda function.

4. Test your skill as you did earlier, tweaking your code where necessary.

We've written up the above secrets as part of a free help guide on designing your own Alexa Skills. You can download it here: How to Build your First Amazon Alexa Skill.

alexa skills, amazon echo, iot, software testing, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}