Skip to content

Instantly share code, notes, and snippets.

@myke11j myke11j/.env
Created Jul 18, 2018

Embed
What would you like to do?
Alexa skills with Alexa SDK using Node.js
AWS_ENVIRONMENT=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_ROLE_ARN=
AWS_REGION=
AWS_FUNCTION_NAME=skill-name
AWS_HANDLER=index.handler
AWS_MEMORY_SIZE=128
AWS_TIMEOUT=10
AWS_DESCRIPTION=
AWS_RUNTIME=nodejs6.10
PACKAGE_DIRECTORY=build

Running The Alexa Skill

npm i -g node-lambda
node-lambda run

Deploying The Alexa Skill

node-lambda deploy
const Alexa = require('alexa-sdk');
const APP_ID = process.env.APP_ID;
const messages = {
greeting: 'Welcome to the Skill!',
goodBytMsg: 'Thanks for using the Skill!',
reprompt: 'Would you like me to repeat that again?',
help: 'Give a help message to User'
}
const handlers = {
'LaunchRequest': function () {
this.attributes['asked'] = 'launch';
const cardTitle = 'Welcome to your Skill!';
let content = messages.greeting;
this.emit(':askWithCard', content, messages.reprompt, cardTitle, content, null)
},
'AMAZON.HelpIntent': function () {
const content = messages.help;
this.attributes['asked'] = 'launch';
this.emit(':askWithCard', content, 'Help from Skill', content, null)
},
'AMAZON.StopIntent': function () {
const cardTitle= messages.goodBytMsg;
const content = messages.goodBytMsg;
this.emit(':tellWithCard', content, cardTitle, content, null)
},
'AMAZON.CancelIntent': function () {
this.emit('AMAZON.StopIntent');
}
};
exports.handler = function (event, context, callback) {
try {
const alexa = Alexa.handler(event, context, callback);
alexa.registerHandlers(handlers);
alexa.appId = APP_ID // APP_ID is your skill id which can be found in the Amazon developer console where you create the skill.
alexa.execute();
} catch (error) {
console.log(`Error in Hinky Pinky Skill, ${error}`);
}
};
{
"name": "your-skill-name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mukul<@mukul1904>",
"license": "ISC",
"dependencies": {
"alexa-sdk": "^1.0.25"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.