-
Create a new skill using the CLI.
$ ask new
-
Name the skill "Not_Helpful".
? Please type in your new skill name: Not_Helpful
-
Navigate to your project folder.
$ cd Not_Helpful
-
Explore the project structure. You should see folders for lambda and models, and skill.json file.
$ ls lambda models skill.json
-
Open the models folder.
$ cd models
-
Open the interaction model file, en-US.json.
-
Change the the invocation name in en-US.json to "not helpful" and save the file.
{ "interactionModel": { "languageModel": { "invocationName": "not helpful" } }
-
Go back to the project's root folder.
$ cd ..
-
Navigate to the custom folder under the lambda folder.
$ cd lambda/custom
-
Open the AWS Lambda function code file, index.js.
-
Replace the contents of index.js with the contents of this JS file, and save it.
-
Navigate back to the root project directory.
$ cd ../..
-
Deploy your new skill.
$ ask deploy
-
Test your skill using the Developer Portal or Echosim.io to verify everything is working.
There are ASK CLI commands for creating your in-skill purchases. This guide will walk you through creating three different one-time purchases (entitlements), as well as a subscription. Our sample code is expecting these to be created as described, so make sure to follow along carefully.
-
Create your first in-skill product. You should be in the project's root directory.
$ ask add isp
-
Choose Entitlement.
? List of in-skill product types you can choose (Use arrow keys) ❯ Entitlement Subscription
-
Choose Entitlement_Template as your template.
? List of in-skill product templates you can choose (Use arrow keys) ❯ Entitlement_Template
-
Name your in-skill product help.
? Please type in your new in-skill product name: (Entitlement_Template) help
-
Navigate to the new ISPs directory, and note the new folder, entitlement. This is where the JSON files for each of your in-skill products reside.
$ cd isps $ ls
-
Navigate to the entitlement folder. You should see your help.json file in this directory.
$ cd entitlement $ ls
-
Open help.json
This JSON file contains all of the necessary fields for your in-skill product, but you'll need to add the details to get them ready to sell. Because we used the Entitlement_Template template, we have provided a small explanation for each field, make sure you replace all of them. Take a look at the sample in our docs for an additional reference. For this sample, at a minimum, you will need to update the name (not referenceName!), smallIconUri, largeIconUri, summary, description, purchasePromptDescription, boughtCardDescription, releaseDate and privacyPolicyUrl.
IMPORTANT: Don't change the referenceName in your files, as this lab is relying on those to be consistent.
If you don't want to create your own images right now, you can use these for now:
-
Navigate to the project's root directory. You should see a file named 'skill.json' there.
$ cd ../..
-
Deploy the skill and the Lambda function in one step by running the following command:
$ ask deploy
Assuming that you followed all of the setup instructions for the ASK CLI, your entire skill and Lambda function should be created on their respective portals.
-
To test, login to Alexa Developer Console, click on the Premium Facts Sample entry in your skill list, and click on the "Test" tab. The "Test" switch on your skill should have been automatically enabled. If it was not, enable it now.
-
Your skill can now be tested on devices associated with your developer account, as well as the Test tab in the Developer Portal. To start using your skill, just type or say:
Alexa, start not helpful
Note: The developer account associated with the skill is never charged for in-skill products. For more details about testing skills with in-skill products, please refer to the In-Skill Purchase Testing Guide
If you have extra time after you finish this lab, here are some additional tasks to complete:
-
You now have a skill with an entitlement enabled. Add a subscription ISP.
-
Adapt your code to allow either the entitlement or the subscription to access the help content.
-
Start diagramming a skill you could build that uses in-skill purchases.