Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Alexa = require('alexa-sdk');
- const APP_ID = 'amzn1.ask.skill.be810433-aaae-4cd3-99fc-708e3047a807';
- exports.handler = (event, context, callback) => {
- const alexa = Alexa.handler(event, context);
- alexa.appId = APP_ID;
- alexa.registerHandlers(handlers);
- alexa.execute();
- };
- const handlers = {
- 'LaunchRequest': function() {
- const welcomeMessage = 'Welcome to plan my trip from Lambda. You can say Help me plan my trip';
- const repromptMessage = 'You can use this skill by saying Plan my trip';
- this.response.speak(welcomeMessage).listen(repromptMessage);
- this.emit(':responseReady');
- },
- 'SessionEndedRequest': function() {
- // close some connection
- // send out emails
- },
- 'AMAZON.HelpIntent': function() {
- this.emit('LaunchRequest');
- },
- 'AMAZON.CancelIntent': function() {
- this.response.speak('Goodbye');
- this.emit(':responseReady');
- },
- 'AMAZON.StopIntent': function() {
- this.response.speak('Goodbye');
- this.emit(':responseReady');
- },
- 'PlanMyTrip': function() {
- if (this.event.request.dialogState === 'COMPLETED') {
- let speechOutput = "Your itenary is ";
- const fromCity = this.event.request.intent.slots.fromCity.value;
- const toCity = this.event.request.intent.slots.toCity.value;
- const travelDate = this.event.request.intent.slots.travelDate.value;
- speechOutput += " from " + fromCity + " to " + toCity + " on " + travelDate;
- this.response.speak(speechOutput);
- this.emit(':responseReady');
- }
- else {
- this.emit(":delegate");
- }
- }
- };
Add Comment
Please, Sign In to add comment