Javi

Alexa: Azure function

Mar 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. module.exports = function (context, req) {
  2. context.log('Call: ' + JSON.stringify(req));
  3.  
  4. let action = req.body.request.intent.slots.action ?
  5. req.body.request.intent.slots.action.value : 'Unknown';
  6.  
  7. let device = req.body.request.intent.slots.device ?
  8. req.body.request.intent.slots.device.value : 'Unknown';
  9.  
  10. let message = 'Action is ' + action + ' and device is ' + device;
  11.  
  12. let response = {
  13. "version": "string",
  14. "sessionAttributes": {
  15. "key": "value"
  16. },
  17. "response": {
  18. "outputSpeech": {
  19. "type": "PlainText",
  20. "text": message
  21. },
  22. "card": {
  23. "type": "Standard",
  24. "title": "Test",
  25. "content": "This is just a simple card",
  26. "text": "Do you see any Teletubbies in here? Do you see a slender plastic tag clipped to my shirt with my name printed on it? Do you see a little Asian child with a blank expression on his face sitting outside on a mechanical helicopter that shakes when you put quarters in it? No? Well, that's what you see at a toy store. And you must think you're in a toy store, because you're here shopping for an infant named Jeb.",
  27. "image": {
  28. "smallImageUrl": "https://s3.amazonaws.com/imgserv.ownlocal.com/pets-and-animals/pet-care/pet-care01-640x480%3E.jpg",
  29. "largeImageUrl": "https://metrouk2.files.wordpress.com/2017/03/pets-e1490696661315.jpg"
  30. }
  31. },
  32. "shouldEndSession": true
  33. }
  34. };
  35.  
  36. context.res = {
  37. status: 200,
  38. body: response
  39. };
  40.  
  41. context.done();
  42. };
Add Comment
Please, Sign In to add comment