Lab 3: Create a Skill in Alexa Conversation in 30 Min

Welcome to lab 3 of our introductory course on building an engaging Alexa Conversations skill. In this lab, we'll learn how to create a skill called "Pet Match".

Time required: 10 - 20 minutes

What you'll learn:

  • How to set up a simple skill called Pet Match with step-by-step instructions
  • How to use the Alexa Developer Console
  • How to host your skill's backend resources
  • How to modify the response that Alexa speaks to customers

Introduction: How Customers Will Interact with Pet Match

With this course you will build Pet Match a simple Alexa Conversations skill that recommends a dog to you customer based their answers to a few questions. The goal of this course is to equip you with the foundational knowledge to build a skill with Alexa Conversations. By the time you've completed all of the labs, in addition to Pet Match, you should have the knowledge to build your own multi-turn skill with Alexa Conversations.

In this lab you will create the skill, turn on Alexa Conversations and update the welcome message to greet your customers so they know they're interacting with Pet Match.

Don't worry if you get stuck along the way or if your code breaks. At the end of each lab, the complete working code solution is provided for you under the Code heading.

At the end of this lab, your first Alexa Conversations skill will have a welcome prompt that says:

"Welcome to pet match. I can find the best dog for you. What are two things you're looking for in a dog?"

Step-by-step: Build the Pet Match Skill

Step 1: Log In

To get started, log into the Alexa Developer Console (https://developer.amazon.com/alexa/console/ask) with your Amazon Developer account. If you do not have an account, click here to create one.

Alexa Developer Console Login Screen

Once you've logged in, you are now ready to create your first Alexa Conversations skill!

Step 2: Create Your Skill

  1. Click the Create Skill button on the right-hand side of the console. This will create your skill.
Create Skill
  1. In the Skill name field enter "Pet Match".

  2. Choose English (US).

  3. Select skill type as Custom. You will specify that you are using Alexa Conversations later on.

  4. Under Choose a method to host your skill's backend resources, select Alexa-Hosted (Node.js).

Skill Setup
  1. At the top of the page, click Create skill.
Create Skill
  1. Select Start from Scratch and click Continue with template.

This will serve as a blank slate for our skill.

template selection

Because you've chosen an Alexa-hosted skill, your skill will automatically have AWS resources provisioned to host your skill code. It will take a few minutes to provision those resources for your skill. Once the process finishes you can activate Alexa Conversations. Once your skill is set up and you're ready, move on to the next section.

Step 3: Enable Alexa Conversations

The first thing you need to do is to enable Alexa Conversations. This will allow you to build out the conversational experience using Alexa Conversations' new features.

  1. In the left-hand column, click on the Interfaces button.

  2. Scroll down through the Interfaces screen until you see Alexa Conversations in the menu. Click on the switch to enable the interface.

  3. Click on the Use Alexa Conversations as the Default Dialog Manager checkbox.

This will set your skill to use Alexa Conversations as the dialog manager instead of the custom interaction model.

  1. Click Save Interfaces.

The Alexa Conversations UI elements will now appear at the top of the left navigation bar.

Enable Interfaces

Step 4: Greet Your Customer

In order to invoke your skill, the customer must refer to your skill some how. When you build your skill, you define an invocation name. Pet Match's invocation name is pet match. In order to interact with skill, your customer will need to say, "Alexa, open pet match".

Be default, the skill's invocation name is "change me". You need to update it to be 'pet match'.

  1. Return to the invocation tab by clicking Invocation on the left navbar.

  2. Change the skill invocation from change me to pet match.

Update invocation phrase
  1. Click Save on the left side of the top navbar to save your work.
Save

Now that you've updated your invocation name, try updating your greeting message.

  1. Click on Alexa Conversations on the left nav bar to expand the menu.

  2. Click on responses.

Create new AC model
  1. Click on Create New Alexa Conversations Model link.

Responses are pre-defined sets of phrases that Alexa can use to respond to a given conversation turn. You can use the APL for audio prompts associated with a response template to create conditional responses. You can also pass argument values into the response to make the conversation feel dynamic. The "welcome" response is triggered when the skill is opened and is a great basic example of the core functionalities offered by response templates.

In order to have your skill say "Welcome to pet match. I can find the best dog for you. What are two things you're looking for in a dog?" when the skill is opened, you will need to edit the welcome response templates.

  1. Locate the welcome response template and click on edit.

Take a look at the Audio Response section. This section allows you to specify and modify any audio outputs that Alexa will provide to the customer as part of the response.

  1. Click on 'Edit Audio Response' to open the APL for audio editor in a new tab.

APLA supports a random item selector that randomly picks an item from a list. This allows you to create a pool of greetings so your skill won't be overly repetitious.

Edit Audio Response
  1. Update your response template so that it includes a set of welcome variations:
  • "Welcome to pet match. I can find the best dog for you. What are the two things you're looking for in a dog?"
  • "Welcome to pet match. I can find the best dog for you. What size of dog are you looking for?"
  • "Welcome to pet match. I can find the best dog for you. What temperament are you looking for in a dog?"

Do this by copying the type, contentType, and content fields into additional array items as seen in the code sample below. An example of what this looks like is below:

{
    "type": "APLA",
    "version": "0.8",
    "mainTemplate": {
        "parameters": [
            "payload"
        ],
        "item": {
            "type": "Selector",
            "strategy": "randomItem",
            "description": "Change 'type' above to try different Selector Component Types like Sequencer",
            "items": [
                {
                    "type": "Speech",
                    "contentType": "text",
                    "content": "Welcome to pet match. I can find the best dog for you. What are the two things you're looking for in a dog?",
                    "description": "Expand on 'items' array to add multiple prompts, use response template arguments by adding it to 'content' like this ${payload.input_argument_name} and add SSML by changing 'contentType' to 'SSML' and adding SSML to 'content' <amazon:effect name=\"whispered\">like that</amazon:effect>"
                },
                {
                    "type": "Speech",
                    "contentType": "text",
                    "content": "Welcome to pet match. I can find the best dog for you. What size of dog are you looking for?",
                    "description": "Expand on 'items' array to add multiple prompts, use response template arguments by adding it to 'content' like this ${payload.input_argument_name} and add SSML by changing 'contentType' to 'SSML' and adding SSML to 'content' <amazon:effect name=\"whispered\">like that</amazon:effect>"
                },
                {
                    "type": "Speech",
                    "contentType": "text",
                    "content": "Welcome to pet match. I can find the best dog for you. What temperament are you looking for in a dog?",
                    "description": "Expand on 'items' array to add multiple prompts, use response template arguments by adding it to 'content' like this ${payload.input_argument_name} and add SSML by changing 'contentType' to 'SSML' and adding SSML to 'content' <amazon:effect name=\"whispered\">like that</amazon:effect>"
                }                 
            ]
        }
    }
}
Add audio response
  1. Click the Play Button several times.

Does the response change or stay the same? The response should now be randomly selected from the options you provided.

Play audio response
  1. Once it's all working, click on the save button in the top right to save your work.

You can now close the APL for audio editor tab and return to the Alexa developer console.

save icon

Now that you are back in the developer console, save your skill too.

  1. In the developer console, click on the save button in the top left.
save model

Step 5: Update the Help Template

You need to update your help template to tell your customers how they can interact with it in case they get stuck.

  1. Return to the Responses tab.

  2. Click Edit. The edit provide_help response template page will appear. We'll now update the default help message in the same way we did the last response.

build model
  1. Click Edit Audio Response.

  2. Replace the Content field with: "This is pet match. I can help you find the perfect pet for you. You can say, I want a large dog."

build model
  1. Click Save and return to the other tab.

Finally, you need to build your model so that the changes take effect.

build model

Now that you've finished building the Welcome and Provide_help responses, you need to build more components in order to successfully create an Alexa Conversations model. By the end of lab 4, you'll have a working model and a functional back-end that can service requests for dog recommendations.

Wrap Up

Congratulations! You have laid the groundwork for your skill.

There is still a lot to learn! In the next lab, you will expand the skill with all the necessary build-time components. To continue adding more skill functionality, click next to move on to the next lab.


Was this page helpful?