# Alexa skill, written in Node JS, Using Express, with ask-sdk-express-adapter


In 2018, after reading an [article on Hackaday](https://hackaday.com/2018/01/17/an-alexa-skill-among-other-things-in-a-few-minutes/), I picked up an Amazon Echo Dot to experiment with building voice interfaces. It was surprisingly easy, and with no experience, I got something up and running in a couple hours.

I haven't looked at this in a while, and had another project in mind. Looking at the Alexa development documentation today, all the examples leverage Amazon's Lambda's compute service. For my project, I didn't want to use Lambda, I just wanted to use Express on Node JS. Amazon has NPM library for this, [ask-sdk-express-adapter](https://www.npmjs.com/package/ask-sdk-express-adapter), but I couldn't find ANY end-to-end example, and I struggled for a bit to get it to work. I think it took me longer the 2nd time around!

SO - here's a simple example, hopefully it's got the right keywords for anyone who's stumbling on the same problem. Keywords:

- node js
- javascript
- ask-sdk-express-adapter
- express
- sample code
- example code
- alexa  
    

```
const express = require('express');
const { ExpressAdapter } = require('ask-sdk-express-adapter');
const Alexa = require('ask-sdk-core');
const app = express();
const skillBuilder = Alexa.SkillBuilders.custom();

var PORT = process.env.port || 8080;

const LaunchRequestHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
    },
    handle(handlerInput) {
        const speechText = 'Hello World - Your skill has launched';

        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withSimpleCard('Hello World', speechText)
            .getResponse();
    }
};

skillBuilder.addRequestHandlers(
    LaunchRequestHandler
)

const skill = skillBuilder.create();

const adapter = new ExpressAdapter(skill, false, false);

app.post('/', adapter.getRequestHandlers());

app.listen(PORT);
```

Hope that helps!

