This post is a continuation of a series of posts describing how to create a custom skill for the Alexa Voice System (AVS). The posts in this series are:
1. Overview and prerequisites.
2. How to set-up your development environment (this post).
3. How to develop a custom skill.
4. How to test your skill on an Alexa-enabled device.
5. How to successfully certify your skill.
All the source code for this project can be found on Github.
To develop an Alexa skill locally we'll need to set-up our environment with Node, and use Node Package Manager (NPM) to pull down the required packages. Then we're going to set-up the Alexa App Server package to allow us to run and test our skills locally.
The following steps detail what you need to do to set-up your local development environment to be able to locally develop an Alexa custom skill.
Node & NVM
Before we can start we need to ensure we have node installed, and not just the latest version (oh no). We need to make sure we use the version of Node that's supported by Lambda (check here for current support).
Depending on the OS you're running, you will need to find instructions to install Node Version Manager (NVM). I'm running Windows and I used this version.
When done if you run nvm list you should see the following (where I’ve got v0.10.36 in use):
Next I'm going to create a folder in my local code directory (i.e. C:\Code\SJCNet.Alexa.Skills.WhoIsRight).
In this folder I'm going to create a src and test folder. Then run
npm init to generate a package.json file. Please note, when asked about the test command use "mocha".
Once that's all be done, you'll need to install the required NPM modules. We'll be installing the following modules:
- alexa-app - Encapsulates some of the Alexa api instructions for us. (NPM Link).
- chai - A BDD/TDD assertion library for node.js that can be paired with Mocha. (NPM Link).
I'm installing the packages using the following commands.
npm install alexa-app --save npm install mocha chai --save-dev
Install Alexa App Server
The Alexa App Server is a web server module for Alexa skills using Node.JS and Express. Using this we can run and test our skills locally.
To install this package create another folder (e.g. C:\Code\alexa-app-server) and use GIT to clone the Github Repo. For example:
git clone https://github.com/matt-kruse/alexa-app-server.git
Once the repo has been pulled locally, open a command prompt and move into the alexa-app-folder. Then run
npm install to pull down any package dependencies.
Next move into the alexa-app-server/examples folder and run
node server to start the express server.
In the console output you should see the sample apps load (with their respective URLs) and you'll see the port the app server is running on.
Next you can test the helloworld skill by going to the following URL (depends on the port your app server opened on):
Here you can test the skill by changing the request type and run the NameIntent to generate Alexa output in the response (shown below).
If you want to test against the local app server, you need to leave the command prompt open.
Now we're ready to move onto the next post and start creating our custom skill intents.