Skip to main content

Deploying Your First Alexa Skill

Hands-On Lab

 

Photo of Larry Fritts

Larry Fritts

Python Development Training Architect II

Length

00:30:00

Difficulty

Beginner

In this lab, we will learn how to use ASK to create a new skill from templates. We will learn how to set up our lab environment for Alexa skill building, and then we will deploy a simple skill and test it. By the end of the lab, you will have deployed your first Alexa skill and proven it functions successfully. Objectives for this lab include learning to initialize the ask-cli, deploying a templated skill and making a slight modification to it, and deploying the skill and testing it works as expected. Note: You must have your own Amazon Developer account, which you can sign up for if you do not already have one.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Deploying Your First Alexa Skill

Introduction

In this lab, we will learn how to use ASK to create a new skill from templates. We will learn how to set up our lab environment for Alexa skill building, and then we will deploy a simple skill and test it. By the end of the lab, you will have deployed your first Alexa skill and proven it functions successfully. Objectives for this lab include learning to initialize the ask-cli, deploying a templated skill and making a slight modification to it, and deploying the skill and testing it works as expected. Note: You must have your own Amazon Developer account, which you can sign up for if you do not already have one.

Solution

If you have not created an Amazon Developer account yet, make sure you do so before starting the lab: Amazon Developer account creation.

Open a terminal window and log in to the lab server using the credentials provided:

ssh cloud_user@<PUBLIC IP ADDRESS>

Note: If you copy and paste the changes into the files when using Vim, you may need to first enter :set paste in order to avoid adding extra spaces or hashes.

Configure Amazon Skills Kit to Use Your AWS Developer Account

  1. Initialize the ASK CLI:

    ask init --no-browser
  2. Copy the URL that appears from the terminal and paste it into a new browser window.

  3. Log in to the developer console when prompted.

  4. Copy the authorization code and paste it into the terminal.

  5. Enter Y to connect to the AWS account already set up on the VM.

  6. Hit Enter to choose the default AWS account.

Clone and Check Out Branch

  1. Clone the template skill:

    ask new --url https://github.com/linuxacademy/content-aws-skill-builder.git
  2. Hit Enter to accept the default skill name.

  3. Enter y at the prompt.

  4. Navigate into the directory:

    cd content-aws-skill-builder/
  5. Start with a template to perform the lab tasks:

    git checkout lab_first_deploy

    Note: To start with the solution to the lab instead, run git checkout lab_first_deploy_solution.

  6. Make sure you're on the right branch:

    git branch

    We should see *lab_first_deploy and master, which means we're on the right branch.

Update Skill Code

In skill.json:

  1. Open the skill.json template:

    vim /home/cloud_user/content-aws-skill-builder/skill.json
  2. Make the following changes:

    "name": "exclusive-vet-services"
    "examplePhrases": ["Alexa open exclusive vet services"]
    "uri": "alexa-skill-exclusive-vet-services"

    The skill.json file should look like:

    {
      "manifest": {
        "publishingInformation": {
          "locales": {
            "en-US": {
              "name": "exclusive-vet-services",
              "summary": "Exclusive Veterinary Services",
              "description": "Exclusive Veterinary Services",
              "examplePhrases": [
                "Alexa open exclusive vet services"
              ],
              "keywords": []
            }
          },
          "isAvailableWorldwide": true,
          "testingInstructions": "Sample Testing Instructions.",
          "category": "KNOWLEDGE_AND_TRIVIA",
          "distributionCountries": []
        },
        "apis": {
          "custom": {
            "endpoint": {
              "sourceDir": "lambda/custom",
              "uri": "alexa-skill-exclusive-vet-services"
            }
          }
        },
        "manifestVersion": "1.0"
      }
    }

    Save and quit the file with :wq!.

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

  1. Open the /models/en-US.json template:

    vim /home/cloud_user/content-aws-skill-builder/models/en-US.json
  2. Change the invocationName to "exclusive vet".

  3. Rename HelloWorldIntent to WelcomeExclusiveVetIntent.

  4. Change WelcomeExclusiveVet "samples" to just be "hello".

  5. Save and quit the file with :wq!.

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

  1. Open the /lambda/custom/index.js template:

    vim /home/cloud_user/content-aws-skill-builder/lambda/custom/index.js
  2. Change the LaunchRequestHandler speakOutput message to be "I am Alexa. Please say hello.".

  3. Change HelloWorldIntentHandler to ExclusiveVetIntentHandler.

  4. Change canHandle in ExclusiveVetIntentHandler:

        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
                && Alexa.getIntentName(handlerInput.requestEnvelope) === 'WelcomeExclusiveVetIntent';
  5. Change ExclusiveVetIntentHandler speakOutput to "Hello Exclusive Veterinary Services staff. I look forward to helping you serve your customers' needs.".

  6. Change the name of HelloWorldIntentHandler to ExclusiveVetIntentHandler in exports.handler.addRequestHandlers:

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

    Save and quit the file with :wq!.

Deploy and Test

  1. Deploy the skill:

    ask deploy
  2. Begin performing a test:

    ask dialog --locale en-US

    Note: This will allow you to interact with the skill as if you were talking to Alexa through the keyboard.

  3. The prompt will change to User >.

  4. Enter open exclusive vet.

  5. At the next User > prompt, enter hello.

Clean Up Amazon Developer Account Alexa Console

  1. In a browser tab, navigate to your Alexa Developer Console.

  2. In the Actions column, click Delete.

  3. In the confirmation dialog window, click Yes, Delete Skill.

Conclusion

Congratulations on successfully completing this hands-on lab!