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

With an Alexa-hosted skill, you can get started quickly using Alexa-hosted AWS resources to power your skill in conjunction with a code editor in the developer console where you can deploy changes to your code. Without leaving the console, you can take your Alexa-hosted skill all the way from start to publish.

Alexa-hosted skills are in developer preview, with a limited group of participants. If you are interested in participating, fill out this form.

Frequently asked questions

What services are included?
With an Alexa-hosted skill, you can build, edit, and publish a skill without leaving the developer console. You get access to an AWS Lambda endpoint, an Amazon S3 bucket for media storage, and a table for managing session persistence. The code editor allows you to edit the backend code for your skill and deploy directly to AWS Lambda. When you create the skill, the developer console sets up a CodeCommit repository to manage your code.
How do I access Alexa-hosted skills?
In the developer console, you can access Alexa-hosted skills from the Create Skill page. The bottom of the page shows options for hosting the backend resources for your skill. Select the Alexa-hosted option. When 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 then need to complete at least one deployment from the code editor to AWS Lambda before you can test your skill using the simulator in the developer console.
What are the usage limits?
Usage is limited to the AWS Free Tier. The following limits apply to each 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.
Do I need an AWS account?
No. You can provision the resources needed to power your Alexa skill directly from the developer console without an AWS account. If you need to use other AWS services or if your usage exceeds the AWS Free Tier, you need to provision the additional resources in your own AWS account.
What happens once a skill hits the thresholds of the AWS Free Tier?
Once your usage passes the limit of the AWS Free Tier, 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.
What types of skills can I build as an Alexa-hosted skill?
You can build a custom skill as an Alexa-hosted skill. You cannot use an Alexa-hosted skill to build a skill with a pre-built model, for example a smart home skill.
Are Alexa-hosted skills available in all locales? In which region are the resources and endpoints hosted?
Alexa-hosted skills are available across all locales, though the Code tab on the developer console has not yet been translated into Japanese. During the developer preview, all resources are hosted in the US East (N. Virginia) region, which may cause latency issues in skills located far from the region.
How do I migrate an Alexa-hosted skill to another service?
During the developer preview, you need to change the endpoint in the console and manually copy and paste your code to your new endpoint. You must also move any resources hosted in S3. As the developer preview evolves, additional options may become available.
Can I use the ASK CLI to work with an Alexa-hosted skill?
You cannot use the ASK CLI with Alexa-hosted skills yet. At this time, you must provision and edit Alexa-hosted skills using the developer console.
What programming languages are supported by Alexa-hosted skills?
Alexa-hosted skills currently support Node.js version 8.
Are my files shared with other accounts?
The service places your files and resources in an individual account, separate from the accounts of other users. The developer console provisions and manages your individual account and the resources inside the account.
Can I run NPM install with Alexa-hosted skills?
We are provisioning AWS CodeBuild as part of the skill in order to execute the build script. NPM install executes as part of the build script. You do not need to run NPM install because you can put dependencies into package.json, and AWS CodeBuild runs NPM install when you click the Deploy button.
How do I add a library or a new dependency to an Alexa-hosted skill?
You can add a dependency or library to the package.json file within the AWS Lambda package for the skill. Dependencies are fetched and built when you click the Deploy button.
How do I access my AWS Lambda logs via Amazon CloudWatch?
Alexa-hosted skills provide you with a limited view of the AWS console so that you can access information critical to developing your skill. To access the Amazon Cloudwatch logs for your skill, in the lower left corner of the code editor click the Logs: Amazon CloudWatch link, which opens a limited view of the AWS console and provides access to the logs.
How do I use session persistence in an Alexa-hosted skill?
First, in your package.json file, add the following npm dependency in the dependencies section:
"ask-sdk-s3-persistence-adapter": "^2.0.0"

Then, in your index.js file, add the following:

// 1. import ask persistence adapter
const persistenceAdapter = require('ask-sdk-s3-persistence-adapter');

// 2. initialize the skill builder with adapter
const skillBuilder = Alexa.SkillBuilders.custom().withPersistenceAdapter(
    new persistenceAdapter.S3PersistenceAdapter({bucketName:process.env.S3_PERSISTENCE_BUCKET})

// 3. sample handler to save attributes
async handle(handlerInput){

    const attributesManager = handlerInput.attributesManager;
    let s3Attributes = {"counter":10};
    await attributesManager.savePersistentAttributes();

    let speechOutput = `Hi there, Hello World! Your saved counter is ${s3Attributes.counter}`;

    return handlerInput.responseBuilder

// 4. sample handler to read attributes
async handle(handlerInput){

    const attributesManager = handlerInput.attributesManager;
    const s3Attributes = await attributesManager.getPersistentAttributes() || {};
    console.log('s3Attributes is: ', s3Attributes);

    const counter = s3Attributes.hasOwnProperty('counter')? s3Attributes.counter : 0;

    let speechOutput = `Hi there, Hello World! Your counter is ${counter}`;

    return handlerInput.responseBuilder
How do I use media files in an Alexa-hosted skill?
You can upload media files, for example pictures and audio, to the S3 bucket provisioned by the Alexa-hosted skill. To upload, in the lower left corner of the code editor click the Media storage: Amazon S3 link, which opens a new browser tab directing you to S3 functionality in the AWS console. The bucket name and folder appear similar to amzn1-ask-skill-xxxxxxx-xxxx-buildsnapshotbucket-xxxxx/Media/.

To access a file on S3 from the index.js for your skill, you need to require util.js and then get the pre-signed URL using the utility function getS3PreSignedUrl(), as shown in the following code example where the requested file is picture.jpg.

The URL expires in 60 seconds, and you cannot override the expiration from the utility function.

const Util = require('util.js');

    const pictureUrl = Util.getS3PreSignedUrl("Media/picture.jpg");    
    return handlerInput.responseBuilder
        .speak('hello world with picture')
        .withStandardCard('card title', 'card text', pictureUrl)
What happens if I change my endpoint?
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 console's code editor will not deploy to the new endpoint.
How do I deploy my code to a development endpoint?
Once 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.
How do I promote development changes to the live endpoint?
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.
How do I make a quick fix to my live endpoint?
To fix live code for an Alexa-hosted skill, it is recommended 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 will not be 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.