Guest User

Untitled

a guest
Jan 18th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. const Alexa = require('alexa-sdk');
  2. const APP_ID = 'amzn1.ask.skill.be810433-aaae-4cd3-99fc-708e3047a807';
  3.  
  4. exports.handler = (event, context, callback) => {
  5. const alexa = Alexa.handler(event, context);
  6. alexa.appId = APP_ID;
  7. alexa.registerHandlers(handlers);
  8. alexa.execute();
  9. };
  10.  
  11. const handlers = {
  12. 'LaunchRequest': function() {
  13. const welcomeMessage = 'Welcome to plan my trip from Lambda. You can say Help me plan my trip';
  14. const repromptMessage = 'You can use this skill by saying Plan my trip';
  15. this.response.speak(welcomeMessage).listen(repromptMessage);
  16. this.emit(':responseReady');
  17. },
  18. 'SessionEndedRequest': function() {
  19. // close some connection
  20. // send out emails
  21. },
  22. 'AMAZON.HelpIntent': function() {
  23. this.emit('LaunchRequest');
  24. },
  25. 'AMAZON.CancelIntent': function() {
  26. this.response.speak('Goodbye');
  27. this.emit(':responseReady');
  28. },
  29. 'AMAZON.StopIntent': function() {
  30. this.response.speak('Goodbye');
  31. this.emit(':responseReady');
  32. },
  33. 'PlanMyTrip': function() {
  34.  
  35. if (this.event.request.dialogState === 'COMPLETED') {
  36.  
  37.  
  38. let speechOutput = "Your itenary is ";
  39.  
  40. const fromCity = this.event.request.intent.slots.fromCity.value;
  41. const toCity = this.event.request.intent.slots.toCity.value;
  42. const travelDate = this.event.request.intent.slots.travelDate.value;
  43. speechOutput += " from " + fromCity + " to " + toCity + " on " + travelDate;
  44.  
  45. this.response.speak(speechOutput);
  46. this.emit(':responseReady');
  47.  
  48.  
  49. }
  50. else {
  51.  
  52. this.emit(":delegate");
  53.  
  54. }
  55. }
  56. };
Add Comment
Please, Sign In to add comment