Jacob Chan

How We Test Alexa Skills (AWS Lambda)

13 Jan 2019

The Alexa Skills Kit provides a great testing interface, and even is available through the command line. A downside to this is that one needs to publish the AWS Lambda function in order to use this testing feature. In our team, we’ve found that working in teams and publishing AWS Lambda functions can get difficult. We decided that automated testing is the way to go.

Furthermore, because our Alexa skill is separated from our main user interface (written in Rails), testing these two in conjunction proved to be a tedious and ambiguous process (depending on what is being tested).

At the end of this post, I have a link to the JSON templates we use to test the skill.

Automated Testing

We use lambda-local for testing, and express to run our test server.

The structure of the express app is simple - when a POST request is received at /test, it will run the body of that request as an Alexa request using lambda-local. It’s important to note that the machine that runs this server will have to have your aws credentials stored in profilePath.

const express = require('express')
const app = express()
var path = require("path");
const lambdaLocal = require('lambda-local');
const bodyParser = require('body-parser');
const port = 3001

var jsonParser = bodyParser.json()

app.get('/', (req, res) => res.send('Hello World!'))
app.post('/test', jsonParser, function(req, res){
        event: req.body,
        lambdaPath: path.join(__dirname, '../index.js'),
        profilePath: '~/.aws/credentials',
        profileName: 'default',
        timeoutMs: 3000
    }).then(function(done) {
    }).catch(function(err) {

app.listen(port, () => console.log(`port: ${port}!`))

We have an automated testing structure written Ruby that POSTs to port 3001 (based on JSON templates), and from there checks the responses against the ActiveRecord.

You can find my repository of Alexa JSON templates here!

Hope you find this useful!