Step 3 - Building an Alexa skill with ASK CLI

We can build an Alexa skill by going through the following steps:

  1. Prepare the skill manifest JSON file, as shown in the following code:
{
"manifest": {
"publishingInformation": {
"locales": {
"en-US": {
"summary": "A simple skill to say introduction for someone",
"examplePhrases": [
"Alexa please say intro",
"say intro",
"help"
],
"name": "self-intro",
"description": "Simple Intro Skill"
}
},
"isAvailableWorldwide": true,
"testingInstructions": "1) Say 'Alexa, say intro'.",
"category": "ORGANIZERS_AND_ASSISTANTS",
"distributionCountries": []
},
"apis": {
"custom": {
"endpoint": {
"uri": "arn:aws:lambda:us-east-1:<account id>:function:lambda-alexa-simple-intro"
}
}
},
"manifestVersion": "1.0"
}
}

Save this file as skill.json.

I have shown only one locale section for US: en-US. You can add additional locales. For example, you can add en-IN if you are planning to test this with an echo with English (IN) set. I have added two locales in the code files to demonstrate this. 

  1. Create a skill using this JSON file, as shown in the following code:
ask api create-skill --file skill.json

If the skill manifest JSON file was created successfully, you should get the following response:

You can execute the command that is provided to track the skill as follows:

If the skill creation was successful, you should get the following message:

  1. Prepare the model file as follows:
{
"interactionModel": {
"languageModel": {
"invocationName": "self-intro",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "SelfIntroIntent",
"samples": [
"please say intro",
"say intro",
"please say intro for",
"say intro for",
"intro",
"intro for"
]
}
]
}
}
}

Save this file as en-US.json. If you need to support more locales, you can create model files for them as well.

For more details on invocation names, intents, and utterances, refer to the How it works section.

  1. Update the skill with the preceding model file, as follows:
ask api update-model 
--skill-id amzn1.ask.skill.ab1fdfac-42eb-42ae-aeae-b761f3c903c1
--file en-US.json
--locale en-US

Replace the skill ID with the skill ID you receive in Step 2: Provisioning Lambda (AWS CLI).

If the model JSON file was created successfully, you should get the following response:

You can execute the command that is provided to track the skill as follows:

If the model creation was successful, you should get the following message:

If you created more locale files in the previous step, you can use the update-model subcommand to update the skills with those models as well.

  1. Enable the skill using the following code:
ask api enable-skill 
--skill-id amzn1.ask.skill.a585bf93-15bb-4361-ab56-ffbdc66027fd

If successful, you should see the following message:

You can now ask Alexa to open our app ('self intro') and then say one of the sample utterances we defined ('please say intro').

You can use the Alexa simulator available at https://echosim.io if you do not have an Echo device. The homepage for this simulator is shown in the following screenshot:

You can also log in to the AWS developer console and test your skill from the Test tab of your skill, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.189