An Alexa Skill in JavaScript – Part 2

Now that we have the tools and a basic project, let’s see what the Alexa Skills Kit (ASK) has created for us.

snip_20181102043136What’s in the Basic Project?

The ASK Config file contains the info the ASK needs to publish your skill.

The lambda folder contains your JavaScript files that are the code behind your skill.  The node_modules folder contains the downloaded node modules you use.  index.js is the main code file for your skill.  package.json and package-lock.json are files that describe some of the technical aspects of your code, such as dependencies.

The models folder contains the various language versions of your Json skill description, including the intents and slots.

The skill.json file is the skill manifest and is where you describe the skill for your end users and the Amazon publishing process.

Where to Start?

In the image above, we’ll start at the bottom with the skill manifest, then the model, then a couple of minor changes to the package files, then we’ll write a couple of lines of JavaScript code and finally check the .ask\config.

The Skill Manifest (skill.json)

Open the skill.json file.  Notice the areas I’ve highlighted in bold, red text.  These are things we will change.

{
  "manifest": {
    "publishingInformation": {
      "locales": {
        "en-US": {
          "summary": "Sample Short Description",
          "examplePhrases": [
            "Alexa open hello world",
            "Alexa tell hello world hello",
            "Alexa ask hello world say hello"
          ],
          "name": "omwtm-roll-a-dice",
          "description": "Sample Full Description"
        }
      },
      "isAvailableWorldwide": true,
      "testingInstructions": "Sample Testing Instructions.",
      "category": "EDUCATION_AND_REFERENCE",
      "distributionCountries": []
    },
    "apis": {
      "custom": {
        "endpoint": {
          "sourceDir": "lambda/custom"
        }
      }
    },
    "manifestVersion": "1.0"
  }
}

The “summary” entry should be a short description of your skill, for example:

"summary": "Roll some dice, optionally adding a modifier to each die",

The “examplePhrases”: section contains 3, and only 3, sample phrases.  I’ll have two main intents:  “Roll {diceCount} dice” and “Roll {diceCount} dice {plusMinus} {modifier}”, so I want to show those in the example phrases.  For example:

"examplePhrases": [
    "Alexa open roll some dice",
    "Alexa tell roll some dice to roll 2 dice",
    "Alexa ask roll some dice to roll 3 dice plus 1"
],

The “name” entry should be the plain, human-readable, name of your skill that people see in the Alexa Skills Catalog.  Note:  This does not have to be unique in the Catalog.  For example:

"name": "Roll Some Dice",

The “description” entry should describe your skill.  This can be a paragraph or two and will also display in the Alexa Skills Catalog.  Notice the description is all on one line.  In VS Code, you can turn on Word Wrap (View | Toggle Word Wrap) to see the entire description on screen.  For example:

"description": "Roll Some Dice will roll any number of standard dice (d 6's) and optionally add or subtract a modifier from each dice.  Alexa will then tell you the total of the rolls plus or minus the modifiers.  For example, you might say 'Roll 3 dice plus 1' and Alexa will roll 3 d 6, getting, say, 3, 4, and 6, then add 1 to each roll, getting 4, 5, and 7, and will tell you the total, 16.",

“testingInstructions” is something we’ll come back to later.  This is the instructions for the Alexa Skill evaluators to follow to test your skill intents thoroughly.  For now, I’ll leave it as is.

Lastly, the “category” entry is used to classify your skill in the Alexa Skills Catalog.  For this skill, I will pick:

"category": "GAME_INFO_AND_ACCESSORY",

There are a couple of additional settings you will want to add to your skill, if appropriate.  After the “manifest” setting, add this code:

"manifestVersion": "1.0",
"permissions": [],
"privacyAndCompliance": {
    "allowsPurchases": false,
    "isExportCompliant": true,
    "containsAds": false,
    "isChildDirected": false,
    "usesPersonalInfo": false
}

So, the completed file looks like this for now:

{
    "manifest": {
        "publishingInformation": {
            "locales": {
                "en-US": {
                    "summary": "Roll some dice, optionally adding a modifier to each die",
                    "examplePhrases": [
                        "Alexa open roll some dice",
                        "Alexa tell roll some dice to roll 2 dice",
                        "Alexa ask roll some dice to roll 3 dice plus 1"
                    ],
                    "name": "Roll Some Dice",
                    "description": "Roll Some Dice will roll any number of standard dice (d 6's) and optionally add or subtract a modifier from each dice.  Alexa will then tell you the total of the rolls plus or minus the modifiers.  For example, you might say 'Roll 3 dice plus 1' and Alexa will roll 3 d 6, getting, say, 3, 4, and 6, then add 1 to each roll, getting 4, 5, and 7, and will tell you the total, 16."
                }
            },
            "isAvailableWorldwide": true,
            "testingInstructions": "Sample Testing Instructions.",
            "category": "GAME_INFO_AND_ACCESSORY",
            "distributionCountries": []
        },
        "apis": {
            "custom": {
                "endpoint": {
                    "sourceDir": "lambda/custom"
                }
            }
        },
        "manifestVersion": "1.0",
        "permissions": [],
        "privacyAndCompliance": {
            "allowsPurchases": false,
            "isExportCompliant": true,
            "containsAds": false,
            "isChildDirected": false,
            "usesPersonalInfo": false
        }
    }
}

Next up, the skill model, where you define your intents and slots.

Bye for now.

 

 

 

 

2 thoughts on “An Alexa Skill in JavaScript – Part 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s