Guest User

Untitled

a guest
Jan 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. console.log('Loading event');
  2. var AWS = require('aws-sdk');
  3.  
  4. // Close dialog with the customer
  5. function close(sessionAttributes, fulfillmentState, message) {
  6. return {
  7. sessionAttributes,
  8. dialogAction: {
  9. type: 'ElicitIntent',
  10. message,
  11. },
  12. };
  13. }
  14.  
  15. function buildResponse(intent, callback) {
  16. console.log("buildResponse");
  17.  
  18. let responseText = "Welcome to our service. Are you interested in registering? Reply REGISTER if interested, otherwise reply CANCEL or just ignore this message.";
  19.  
  20. callback(close(intent.sessionAttributes, 'Fulfilled', {
  21. 'contentType': 'PlainText',
  22. 'content': responseText
  23. }));
  24.  
  25. };
  26.  
  27. // --------------- Main handler -----------------------
  28.  
  29. // Route the incoming request based on intent.
  30. // The JSON body of the request is provided in the event slot.
  31. exports.handler = (event, context, callback) => {
  32. try {
  33. console.log(event);
  34. console.log(`request received for userId=${event.userId}, intentName=${event.currentIntent.name}`);
  35.  
  36. buildResponse(event,
  37. (response) => {
  38. callback(null, response);
  39. });
  40. } catch (err) {
  41. callback(err);
  42. }
  43. };
Add Comment
Please, Sign In to add comment