Your Alexa Dashboards Settings

Alexa Python Tutorial

Build a voice experience in 5 minutes or less

Start building for voice with Alexa

Learn to build for voice with Alexa, Amazon’s voice service and the brain behind millions of devices including Amazon Echo. Alexa provides capabilities, or skills, that enable customers to create a more personalized experience.

Start building for Alexa with this quick walkthrough of the skill-building process. You’ll end with a simple but complete Alexa skill that can run on Amazon Echo or any device with Alexa. This tutorial uses the Alexa Skills Kit, AWS Lambda, and Python.

How fast can you build? Let us know by tweeting @alexadevs.

Sign in to Amazon Web Services (AWS) and create a function

1.

Log in to the AWS Management Console. If you haven’t done so already, you’ll need to create a free account.

2.

From the list of services, select Lambda.

3.

Click the region drop-down in the upper-right corner of the console and select US East (N. Virginia), which is a supported region for Lambda functions used with the Alexa Skills Kit.

4.

Choose Create a Lambda Function or Get Started Now to choose a blueprint for your new function.

5.

In the search filter box, type alexa.

6.

Select blueprint alexa-skills-kit-color-expert-python. Make sure to choose the blueprint that ends in -python.

7.

Make sure the trigger is set to Alexa Skills Kit, then choose Next.

8.

Name your function. We’ll use myColorSkill for this walkthrough.

9.

Make sure pop-ups are enabled. Then, under Lambda function handler and role, select Create a custom role.

10.

When the IAM role management console opens, choose Allow to go back to the previous Lambda console.

11.

The role is now populated with lambda_ basic_execution. Choose Next then choose Create function.

12.

Copy the Amazon Resource Name (ARN) displayed in the upper-right corner of the console that starts with arn:aws:lambda....

Use the Amazon developer portal to configure your skill

1.

Sign in to the Amazon developer portal. If you haven’t done so already, you’ll need to create a free account.

2.

From the top navigation bar, select Alexa.

3.

Under Alexa Skills Kit, choose Get Started >.

4.

Choose Add a New Skill.

5.

Name your skill. This is the name displayed to users in the Alexa app. For this example, we’ll call it Color Picker.

6.

Create an invocation name. This is the word or phrase that users will speak to activate the skill. For this walkthrough, we’ll use the skill name Color Picker (case-sensitive). Users will say, "Alexa, open Color Picker" to interact with your skill. Choose Save to continue to development for Color Picker.

7.

Choose Next to continue to development for Color Picker.

8.

In the Intent Schema box, paste the following JSON code.

{
  "intents": [
    {
      "intent": "MyColorIsIntent",
      "slots": [
        {
          "name": "Color",
          "type": "LIST_OF_COLORS"
        }
      ]
    },
    {
      "intent": "WhatsMyColorIntent"
    },
    {
      "intent": "AMAZON.HelpIntent"
    }
  ]
}
9.

Now we will add a Custom Slot Type.

10.

Enter type LIST_OF_COLORS, and enter the following values.

green
red
blue
orange
gold
silver
yellow
black
white
11.

Enter additional values if you'd like, and then choose Add.

12.

Under Sample Utterances, enter all the phrases that you think users might say to interact with your skill. The more phrases you enter, the better the results. For our example, paste the following:

WhatsMyColorIntent what's my favorite color
WhatsMyColorIntent what is my favorite color
WhatsMyColorIntent what's my color
WhatsMyColorIntent what is my color
WhatsMyColorIntent my color
WhatsMyColorIntent my favorite color
WhatsMyColorIntent get my color
WhatsMyColorIntent get my favorite color
WhatsMyColorIntent give me my favorite color
WhatsMyColorIntent give me my color
WhatsMyColorIntent what my color is
WhatsMyColorIntent what my favorite color is
WhatsMyColorIntent yes
WhatsMyColorIntent yup
WhatsMyColorIntent sure
WhatsMyColorIntent yes please
MyColorIsIntent my favorite color is {Color}
13.

Choose Next and wait until the interaction model finishes loading, in no more than a few seconds.

14.

Select the Endpoint AWS Lambda ARN then paste your ARN code from step 1-14. Select North America as your region, and for Account Linking select No, then choose Next.

Test your skill one of three ways

Test your skill on your Amazon Echo, Echo Dot, or any Alexa device by saying, "Alexa, open Color Picker."

Use the Service Simulator from the Test step of Color Picker development. Try entering Open Color Picker or My favorite color is red to see how Alexa responds.

Try the Echo Simulator Community Edition at Echosim.io. Simply click and hold the microphone icon and speak your commands.

Success!

Congratulations! You've created an Alexa skill. Now build a skill that's all your own.

With the Alexa Skills Kit (ASK), designers, developers, and brands can build engaging skills and reach millions of customers. ASK is a collection of self-service APIs, tools, documentation, and code samples that makes it fast and easy for you to add skills to Alexa. With ASK, you can leverage Amazon’s knowledge and pioneering work in the field of voice design.

Start building your next skill today.