|
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}`); |
|
} |
|
}; |