In this lab, we change our skill to have a custom intent that returns a stock phrase. This is in preparation for another lab where we will add custom slots to the intent we create here. The objectives for this lab include creating a simple custom intent and testing that intent using `ask dialog`. **Note:** You must have your own Amazon Developer account, which you can [sign up](https://developer.amazon.com/) for if you do not already have one.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Configure Amazon Skills Kit to Use Your AWS Developer Account
Initialize the ASK CLI:
ask init --no-browser
- Copy/paste the URL that appears from the terminal to a browser window.
- Log in to the developer console when prompted.
- Copy/paste the authorization code.
- Enter
y
forYes
to connect to the AWS account already set up on the VM. - Choose the default AWS account.
- Clone Skill and Check Out Branch
Use the following to clone the template skill:
ask new --url https://github.com/linuxacademy/content-aws-skill-builder.git
Navigate into the directory with:
cd content-aws-skill-builder
To start with a template and perform the tasks for this lab yourself:
git checkout lab_intents
To start with the solution to the lab:
git checkout lab_intents_solution
- Update Skill Code
In
../models/en-US.json
:Create
RegisterPetIntent
:{ "name": "RegisterPetIntent", "slots": [], "samples": [ "I want to register my pet" ] },
In
../lambda/custom/index.js
:Change the
LaunchRequestHandler
message to be"Exclusive Veterinary Services welcomes you. Please say I want to register my pet."
Create a
RegisterPetIntentHandler
:const RegisterPetIntentHandler = { canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'RegisterPetIntent'; }, handle(handlerInput) { const speakOutput = "We are happy to help you register your pet."; return handlerInput.responseBuilder .speak(speakOutput) //.reprompt('add a reprompt if you want to keep the session open for the user to respond') .getResponse(); } };
Add
RegisterPetIntentHandler
to theexports.handler
at the end of the file:exports.handler = Alexa.SkillBuilders.custom() .addRequestHandlers( LaunchRequestHandler, ExclusiveVetIntentHandler, RegisterPetIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, FallbackIntentHandler, SessionEndedRequestHandler) .addErrorHandlers( ErrorHandler) .lambda();
- Deploy and Test
Deploy the skill:
ask deploy
Begin performing a test:
ask dialog --locale en-US
The prompt will change to
User >
.Enter
open exclusive vet
and follow the prompts.
- Cleanup Amazon Developer Account Alexa Console
At this point the skill you just created should be deleted from your Alexa Console.
Please do so at this link Alexa Console.