Featured resource
Forrester Wave Report 2025
Pluralsight named a Leader in the Forrester Wave™

Our tech skill development platform earned the highest scores possible across 11 criteria.

Learn more
  • Labs icon Lab
  • AI
  • Cloud
Google Cloud Platform icon
Labs

Adding a Custom Intent to an Alexa Skill

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.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 30m
Published
Clock icon Jul 23, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Configure Amazon Skills Kit to Use Your AWS Developer Account

    1. Initialize the ASK CLI:
    ask init --no-browser
    
    1. Copy/paste the URL that appears from the terminal to a browser window.
    2. Log in to the developer console when prompted.
    3. Copy/paste the authorization code.
    4. Enter y for Yes to connect to the AWS account already set up on the VM.
    5. Choose the default AWS account.
  2. Challenge

    Clone Skill and Check Out Branch

    1. Use the following to clone the template skill:
    ask new --url https://github.com/linuxacademy/content-aws-skill-builder.git
    
    1. Navigate into the directory with:
    cd content-aws-skill-builder
    
    1. To start with a template and perform the tasks for this lab yourself:
    git checkout lab_intents
    
    1. To start with the solution to the lab:

      git checkout lab_intents_solution
      
  3. Challenge

    Update Skill Code

    In ../models/en-US.json:

    1. Create RegisterPetIntent:

        {
            "name": "RegisterPetIntent",
            "slots": [],
            "samples": [
              "I want to register my pet"
            ]
        },
      

    In ../lambda/custom/index.js:

    1. Change the LaunchRequestHandler message to be "Exclusive Veterinary Services welcomes you. Please say I want to register my pet."

    2. 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();
        }
      };
      
    3. Add RegisterPetIntentHandler to the exports.handler at the end of the file:

      exports.handler = Alexa.SkillBuilders.custom()
        .addRequestHandlers(
          LaunchRequestHandler,
          ExclusiveVetIntentHandler,
          RegisterPetIntentHandler,
          HelpIntentHandler,
          CancelAndStopIntentHandler,
          FallbackIntentHandler,
          SessionEndedRequestHandler)
        .addErrorHandlers(
          ErrorHandler)
        .lambda();
      
  4. Challenge

    Deploy and Test

    1. Deploy the skill:

      ask deploy
      
    2. Begin performing a test:

      ask dialog --locale en-US
      
    3. The prompt will change to User >.

    4. Enter open exclusive vet and follow the prompts.

  5. Challenge

    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.

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.