Photo by on Andres Urena Unsplash Quick guide to building and unit testing an Alexa Skill What is Test Driven Development? According to , it means “Requirements are turned into very specific , then the software is improved to pass the new tests, only.” Basically, you would first have to write the test of the software/feature you are developing before you start working on the developing the software/feature itself. Wikipedia test cases Here are a few more articles on the benefits and why you should apply TDD:- by - by Test Driven Development Jan Olbrich Isn’t TDD twice the work? Why should you care? Navdeep Singh Preparation Here are a few thing you might want to have set up or installed before getting started: account (a free one will work just fine) Amazon Web Service (personally though, I prefer installing and maintaining it through ) node.js nvm Text editor of your choice Setting up Create a new project folder ( ) mkdir project-name Navigate into that new folder ( ) cd project-name Initialize npm ( ) npm init Follow through everything as you prefer (if you don’t know what it is, just press enter and it’ll keep the default) except for , put in instead. The command line should look something like the snippet below. test command: node test/testflow.js This utility will walk you through creating a package.json file.It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fieldsand exactly what they do. Use `npm install <pkg>` afterwards to install a package andsave it as a dependency in the package.json file. Press ^C at any time to quit.package name: (emptyproject)version: (1.0.0)description:entry point: (index.js)test command: node test/testflow.jsgit repository:keywords:author:license: (ISC) Now you have node.js setup for the project. Unit testing Shout out to for maintaining that provides unit testing for Alexa skills. Here’s what the following commands will do : robmccauley testflow Clone testflow repository into your project at the ‘test’ folder. (If this project is also a git project itself, I recommend doing instead of .) git submodule add git clone Create a folder named ‘dialogs’ Create a file named ‘default.txt’ in the ‘dialog’ folder Edit the ‘SourceCodeFile’ line in the cloned ‘testflow’ repository to point to the ‘index.js’ in the base level of the folder (feel free to edit it to your personal preference). git clone :robm26/testflow.git testmkdir dialogstouch dialogs/default.txtsed -i '9c const SourceCodeFile = "../index.js"' test/testflow.js git@github.com Inside the ‘default.txt’ file in the ‘dialogs’ folder, you should have the intents you are trying to test. The default in the testflow repository consist of the followings but you should definitely add some more customized ones to it depending on what you are trying to do in your skill. LaunchRequestAMAZON.HelpIntentAMAZON.StopIntent In case where you are taking in variables through utterances, you can do something like this : DoSomething Input1=userInput1 Input2=userInput2 To get a deeper understanding into using testflow, I recommend looking into its and the by the author himself. tutorial page blog post Developing the skill To be honest, I don’t have too much to talk about on this topic. Here is some sample code of how a sample skill can look like. (Also remember to do .) npm install --save alexa-sdk I recommend looking into the official that provides all kinds of sample skills that you can work on top of. Alexa GitHub repository Deployment Alexa Skill Kit Go to and select ‘Create Skill’. In there you should see options to ‘add intents’ and ‘custom slot types’. You should add the appropriate slot types and intents accordingly from above. After you are done with that, select ‘Endpoint’ from the side bar and select ‘AWS Lambda ARN’ as the skill’s service endpoint. Make a copy of the Skill ID as you will need it later. this page AWS Lambda Create an AWS Lambda function selecting ‘from scratch’. After that, you should have an option to ‘add trigger’ where you would select ‘Alexa Skills Kit’. Now in the configuration dialog, you should put in the Skill ID you took a copy of previously then select ‘Add’. After this, select back to the box that labeled your project name. There should be a ‘Function code’ dialog box appeared below. While you can definitely copy and paste your code onto the online text editor, there might be chance where the packages you have installed and used in your code is included by default. It is also possible that you have more than 1 JavaScript files for the skill. In this case, you would select ‘Upload a .ZIP file’ under ‘Code entry type’. Locally, zip up all the JavaScript files along with the folder then upload the resulting zip file. node_modules Submission When you are done, you can go back to the Alexa Skill Kit page, select the ‘Distribution’ tab and fill out the appropriate information before submitting your skill for review. Hopefully everything goes well and your skill gets published at the Alexa Skill Store! About me I recently started working at Facebook as a Software Engineer. I spend a lot of my free time experimenting and building new things with technologies I find fun and interesting. Follow my exploration journey or on . here GitHub Credits Build Skills with the Alexa Skills Kit TestFlow: Simulate Conversations with Your Alexa Skill Code to Ease Debugging