Build a Skill End-to-end Using an Alexa-hosted Skill

When you create an Alexa skill, you store your code and resources yourself. However, you can create an Alexa-hosted skill, and Alexa stores your code and resources on AWS for you. With an Alexa-hosted skill, you can get started quickly by using one of the skill templates available in the developer console. When you create an Alexa-hosted skill, you write your skill code in an editor directly in the developer console. You can also use the Alexa Skills Kit Command Line Interface (ASK CLI) to create and manage Alexa-hosted skills.

You can only build a skill that uses a custom voice interaction model as an Alexa-hosted skill. You can't create an Alexa-hosted skill that uses a pre-built voice interaction model, such as a smart home skill.

Alexa-hosted skills are available in all locales. All resources are hosted in the US East (N. Virginia) region, which may cause latency issues in skills located far from the region.

Overview

With an Alexa-hosted skill, you can build, edit, and publish a skill without leaving the developer console. When you create an Alexa-hosted skill, you get access to an AWS Lambda endpoint, an Amazon S3 bucket for media storage, and an Amazon S3-backed key-value table for managing session persistence. You use the code editor to edit the backend code for your skill and deploy directly to AWS Lambda.

You don't need an AWS account to create an Alexa-hosted skill. Alexa provisions the AWS resources that you need directly from the Alexa developer console. Alexa places your files and resources in an individual account, separate from the accounts of other users, and your files are never shared with other users. If you need to use additional AWS services, or if your usage exceeds the usage limits, you provision the additional resources in your own AWS account. For more information, see Use Personal AWS Resources with Your Alexa-hosted Skill.

You can build an Alexa-hosted skill with Node.js version 10.x or Python version 3.7. When you create your skill, you select the runtime for your skill. Once you choose the runtime for a skill, you can't change it.

When you create your skill, you also get an AWS CodeCommit repository for managing your code, which you can access by using the ASK CLI to edit your skill. For more information, see Create and Manage Alexa-hosted Skills Using the ASK CLI.

If you have an existing skill and you want to convert it into an Alexa-hosted skill, first create a new Alexa-hosted skill, and then add your skill content to the Alexa-hosted skill. Currently, you can't transition directly from an existing Alexa skill to an Alexa-hosted skill. However, you can import an Alexa-hosted skill from a public Git repository. For more information, see Import an Alexa-hosted Skill from a Public Git Repository.

If you have an Alexa-hosted skill and you want to host it yourself, you must move any resources hosted in Amazon S3 from your Alexa-hosted skill to your own storage, manually copy and paste your code to your new skill endpoint, and change the endpoint of the skill in the developer console.

Usage limits

Your developer.amazon.com account is limited to 75 Alexa-hosted skills. When there are 75 Alexa-hosted skills on your account, you must delete an Alexa-hosted skill from your account before you can create another Alexa-hosted skill.

Your Alexa-hosted skill uses AWS resources. Your resource usage is limited to the AWS Free Tier. The following limits apply to each Alexa account.

  • AWS Lambda: 1 million free AWS Lambda requests and 3.2 million seconds of compute time per month.
  • Amazon S3: 5 GB of Amazon S3 storage, 20,000 get requests, 2,000 put requests, and 15 GB of data transfer out per month.
  • AWS CodeCommit: 50 GB-month of storage and 10,000 Git requests per month.

If your usage exceeds the AWS Free Tier limits, you have 30 days to bring usage below the limit by moving at least one of your skills to a personal AWS account or other cloud services account.

Your Amazon S3 storage usage appears in the Alexa developer console on the code editor tab for your skill as Media storage: S3 [n.n/5GB]. Usage includes storage of media files and data for session persistence.

Create an Alexa-hosted skill in the console

You can create an Alexa-hosted skill in the developer console by using the procedure that follows. To create an Alexa-hosted skill by importing a skill project from a public Git repository, see Import an Alexa-hosted Skill from a Public Git Repository. To create an Alexa-hosted skill by using the ASK CLI, see Create and Manage Alexa-hosted Skills Using the ASK CLI.

To create an Alexa-hosted skill in the console

  1. Open the Alexa developer console and log in.
  2. Click Create Skill. The Create a new skill page appears.
  3. For Skill name, enter a name.
  4. For Default language, choose a language.
  5. For Choose a model to add to your skill, select Custom.
  6. For Choose a method to host your skill's backend resources, select Alexa-Hosted (Node.js) or Alexa-Hosted (Python).
  7. Click Create Skill.

After you create your skill, the voice model, AWS resources, and code editor are activated, and the developer console initiates a build process for the voice model.

You can store audio and visual files in Amazon S3 to use with your Alexa-hosted skill. For more information, see Use Media Files with Your Alexa-Hosted Skill.

You can store session data in Amazon S3 to use with your Alexa-hosted skill. For more information, see Use Session Persistence with Your Alexa-hosted Skill.

Skill endpoint and deployment

An Alexa-hosted skill provisions an AWS Lambda endpoint and links your skill to the endpoint. If you change the hosted endpoint, your skill is no longer an Alexa-hosted skill and the code editor in the console does not deploy to the new endpoint. In the console, after you change the endpoint, the code tab gives you an option to reconnect to a hosted endpoint.

After your Alexa-hosted skill is published, two stages of your skill appear in the console: one for the live stage and one for the development stage. In the development stage for your skill, you can use the code editor to edit, save and deploy code to the development version of your AWS Lambda endpoint. This action does not affect the live endpoint for your skill. You can then go to the Test tab and test your changes.

If you change the voice model for your skill, you must submit your skill for re-certification. If you change only the code for your skill, you can promote code from development to live by clicking the Promote to live button in the code editor. This action replaces the live code for your published skill.

To make a quick fix to live code for an Alexa-hosted skill, we recommend that you first make changes in the development stage, test the changes, and then promote the changes to the live endpoint for your skill. If you want to make a quick fix to your live code and your development code has other changes that you do not want to promote, you can make your fix directly to the live endpoint. However, you are not able to test your changes. Open the code editor for the live stage, edit your code, and then deploy changes directly to the live endpoint. This action directly affects your live skill.

Add dependencies

Alexa provisions AWS CodeBuild as part of your skill to run the build script. NPM (Node.js) or pip (Python) runs automatically as part of the build script. You can add new libraries and dependencies to your skill, and dependencies are fetched and built when you click the Deploy button.

  • Node.js — Add dependencies in the dependencies section of your package.json file:

    "i18next": "^10.5.0"
    
  • Python — Add dependencies in the dependencies section of your requirements.txt file. For example:

    boto3==1.9.216
    

View CloudWatch logs

Your Alexa-hosted skill automatically provides you with CloudWatch logs so you can access information critical to developing your skill.

To view your CloudWatch logs

  1. Open the Alexa developer console and log in.
  2. In the list of your skills, click the name of the skill that you want to view.
  3. Click the Code tab.
  4. In the lower left corner, click the link Logs: Amazon CloudWatch. A limited view of the AWS console opens and your logs appear. If your skill is not live yet, you don't have logs yet.

Download your skill

You can download your skill from the Code tab of your skill, either in the development stage or the live stage. In the development stage, you can download the skill with the latest code changes. In the live stage, you can download a copy of the live skill. The download package includes the skill's interaction model, source code files, and skill manifest.

To download a copy of your skill

  1. Open the Alexa developer console and log in.
  2. In the list of your skills, click the name of the skill that you want to download.
  3. Click the Code tab.
  4. In the upper left corner, click the Download Skill icon.
  5. In the pop-up window, choose Continue.
  6. Save your skill as a .zip file.

Filter out skill availability checks

The hosted skills service periodically sends an availability check to your AWS Lambda function to verify that calls to AWS Lambda from your Alexa-hosted skill work properly. Alexa sends the availability check in the form of a LaunchRequest from the user alexa-lambda-availability. If your skill performs an action when it receives a LaunchRequest, filter out requests from the user alexa-lambda-availability to prevent your skill from performing unnecessary actions.

The following code shows an availability check sent from Alexa to your skill.

{
  "version": "1.0",
  "session": {
    "new": true,
    "sessionId": "alexa-lambda-availability",
    "application": {
      "applicationId": "YOUR_SKILL_ID"
    },
    "user": {
      "userId": "alexa-lambda-availability"
    }
  },
  "context": {
    "AudioPlayer": {
      "playerActivity": "IDLE"
    },
    "System": {
      "application": {
        "applicationId": "YOUR_SKILL_ID"
      },
      "user": {
        "userId": "alexa-lambda-availability"
      },
      "device": {
        "deviceId": "test-device",
        "supportedInterfaces": {
          "AudioPlayer": {}
        }
      },
      "apiEndpoint": "https://api.amazonalexa.com",
      "apiAccessToken": "{token}"
    }
  },
  "request": {
    "type": "LaunchRequest",
    "requestId": "amzn1.echo-api.request.alexa.lambda.availability",
    "locale": "en-US",
    "shouldLinkResultBeReturned": false
  }
}

Quickstart tutorial

You can use Alexa-hosted skills to build an engaging skill by going through the 90-minute Cakewalk tutorial. Use the tutorial if you want a hands-on experience with the Alexa Skills Kit (ASK) and voice user interface (VUI).