Alexa Development Environment

There are many options and tools available when developing for Alexa, but where do you get started? This post will walk you through setting an Alexa development environment. Like many things in software development, there are many (almost infinite) ways you can set things up. Think of this as a good place to start.

The instructions here are for getting setup on a Mac, but should be easily adapted for Linux, or with a little more work windows. Alternatively, for an in depth guide for a Windows environment try Setting up a Local Alexa Skill Development Environment

Prerequisites

This post assumes you have a few things already setup on your Mac. Below is a list with links to instructions incase you don’t:

Start with Node.js

Node.js is required for the Alexa command line tools, and it is also the language we will use for an example skill.
We strongly encourage you to use NVM to install and manage node.js versions, but id does add an extra layer of complexity when getting started (you can always add it later).

With NVM

1
2
brew install nvm
mkdir ~/.nvm

Edit your ~/.bash_profile and add

1
2
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

Now open a new terminal and install node.js

1
2
3
4
# install
nvm install 8.10
# set the version to use when opening a new shell
nvm alias default 8.10.0

Node.js 8.10 is the latest version supported by AWS Lambda, and so the version we will use.

Without NVM (use a single version of Node.js on your machine)

Download and open the current LTS installation package from nodejs.org or use the 8.10.0 package to match the AWS lambda version.

Amazon Accounts

Alexa development requires a developer account with Amazon and a place to host your skill code. Because Amazon will give you AWS credits to support hosting your code (see AWS Promotional Credits), AWS is the best place to host your first skills. Even if you already have an AWS account, using an account per skill is a good idea for managing costs. For managing multiple AWS accounts see AWS Organizations.

Amazon Developer Account

Go to https://developer.amazon.com/alexa

  • Click Sign in
  • Click the Create your Amazon Developer account button
  • Fill out the registration with your information
  • Read the agreement and agree to in
  • Select monetization options. no to both for Alexa skills, you can change it later
  • Click on Alexa Skills Kit tab to start working on your skill

AWS Account For Hosting

You will need to enter a credit card, and valid phone that you can be reached on while setting up the account
Go to https://aws.amazon.com/free/

  • Click Create a Free Account
  • Enter registration information
  • Select a Personal account unless you have your business info available (tax ID, etc)
  • Fill out the account registration
  • Read the Terms - AWS Customer Agreement
  • Fill in credit card information
  • Enter phone number for account conformation callback
  • Verify your account by automated call
  • Click on the Free plan button. Unless you want to by a support plan
  • Click Sign into Console
  • Sign in with the email and password you used to register

ASK CLI installation

Installing the ASK CLI is strait forward, but linking it to an AWS account is a little more complicated if you don’t know where to start. You will need to:

  • Create a new Security Policy
  • Create a new User and assign Security Policy
  • Install the ASK CLI
  • Setting up a Local AWS Profile
  • Associate the User to the ASK CLI

Create a new Security Policy

Go to https://developer.amazon.com/docs/smapi/set-up-credentials-for-an-amazon-web-services-account.html
and copy the JSON for creating a policy. It should look like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:GetRole",
"iam:AttachRolePolicy",
"iam:PassRole"
],
"Resource": "arn:aws:iam::*:role/ask-*"
},
{
"Effect": "Allow",
"Action": [
"lambda:AddPermission",
"lambda:CreateFunction",
"lambda:GetFunction",
"lambda:UpdateFunctionCode",
"lambda:ListFunctions"
],
"Resource": "arn:aws:lambda:*:*:function:ask-*"
},
{
"Effect": "Allow",
"Action": [
"logs:FilterLogEvents",
"logs:getLogEvents",
"logs:describeLogStreams"
],
"Resource": "arn:aws:logs:*:*:log-group:/aws/lambda/ask-*"
}
]
}
  • Open the IAM Identity and Access Management Console. Sign in with your AWS account that you will use to create AWS Lambda functions for your Alexa skills (the one you created).
  • Click Policies
  • Click Create Policy
  • Click on the JSON tab
  • Paste the JSON above into the window replacing what is there
  • Click Review Policy, name it AskCliAccess (or a name of your choice)
  • Click Create Policy

Create a new User and assign Security Policy

  • Click on Users
  • Click Add User
  • Name your user ask-cli (or a name of your choice)
  • Select Programmatic access and AWS Management Console access
  • Select Autogenerated password
  • Make sure Require password reset is not selected
  • Click Next: Permissions
  • Click Attach existing policies directly
  • Find the policy you created (search for AskCliAccess) and select it
  • Click Next: Review
  • Verify the details and click Create User
  • Click Download .csv to save the credentials (~/Downloads/credentials.csv), you will not be able to access them again

Install the ASK CLI

Open a terminal and install ask-cli globally

1
npm install -g ask-cli

Setting up a Local AWS Profile

1
ask init --aws-setup

name the profile to use (default) then enter the AWS Access Key ID and AWS Secret Access Key from the credentials.csv you downloaded.

Associate the User to the ASK CLI

1
ask init

choose the profile to use (default) and when the browser opens log in with the Amazon Developer account you created (not the AWS account), then click Allow.

Install a code editor

This is a highly personal choice, and you can pretty much use what ever you want, however if you don’t have a preference try Visual Studio Code, it is free, open source, and works well for developing Alexa skills. Other good options that we have used are:

VS Code CLI

If you choose to use VS Code, then it is worth it to set up the ability to launch code from the terminal.
Go to https://code.visualstudio.com/docs/setup/mac for the official instructions.

  • Open Visual Studio Code
  • Open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install ‘code’ command in PATH command.
  • Restart the terminal for the new $PATH value to take effect. You’ll be able to type ‘code .’ in any folder to start editing files in that folder.

Create a Skill

Open a terminal and create/change to a directory for your skill

1
ask new

Enter a name for your skill (My Skill), then open you code editor

1
code My\ Skill

The skill is created from a template that Amazon provides called Greeter Skill.

  • skill.json contains the meta data for your skill
  • models contains the voice model for your skill
  • lambda/custom contains the code for the Lambda that powers your skill

Once you have your skill to a point where you are ready to deploy it, you can do so

1
ask deploy

Other Tools And Resources

AWS Promotional Credits

Amazon offers skill publishers AWS credits to help cover hosting costs, but you have to sign up. Don’t miss out on this great opportunity, sign up here:
AWS Promotional Credits

Alexa Developer rewards

Amazon pays publishers of top skills. Every month you can earn money for engaging skills. If your skill is in one of the categories listed and has great user engagement, you will get paid. Sign up here:
Alexa Developer rewards

BeSpoken Tools

BeSpoken Tools provide developers with a set of tools to test and monitor Alexa skills.

Jovo Tech

A Framework for Voice App Development. Build multimodal apps for Amazon Alexa and Google Assistant.

Storyline

Create Alexa skills without coding!