Alexa skill handler

Flow to handle a custom Alexa skill. This is a part of a hackster walabot example

https://www.hackster.io/dfw-hackster/alexa-are-the-kids-up-0f0852

[{"id":"5a127c38.fea13c","type":"tab","label":"Flow 11","disabled":false,"info":""},{"id":"f8ccb14d.b8b27","type":"http in","z":"5a127c38.fea13c","name":"Echo request","url":"/echo","method":"post","upload":false,"swaggerDoc":"","x":110,"y":80,"wires":[["f938d9d0.dccc6","8c19a09e.766f1"]]},{"id":"f938d9d0.dccc6","type":"switch","z":"5a127c38.fea13c","name":"Request Type","property":"payload.request.type","propertyType":"msg","rules":[{"t":"eq","v":"LaunchRequest","vt":"str"},{"t":"eq","v":"IntentRequest","vt":"str"},{"t":"eq","v":"SessionEndedRequest","vt":"str"}],"checkall":"true","outputs":3,"x":295,"y":80,"wires":[["f2edc3da.e0fb8"],["c82e207a.952618"],[]]},{"id":"35ceb507.7632c2","type":"template","z":"5a127c38.fea13c","name":"Format response","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"version\": \"1.0\",\n  \"response\": {\n    \"outputSpeech\": {\n      \"type\": \"PlainText\",\n      \"text\": \"{{payload}}\"\n    },\n    \"shouldEndSession\": true\n  }\n}","x":395,"y":151,"wires":[["43998b07.72d92c"]]},{"id":"43998b07.72d92c","type":"json","z":"5a127c38.fea13c","name":"","x":568,"y":151,"wires":[["909853ca.191798"]]},{"id":"909853ca.191798","type":"http response","z":"5a127c38.fea13c","name":"","x":705,"y":151,"wires":[]},{"id":"c82e207a.952618","type":"switch","z":"5a127c38.fea13c","name":"Intents","property":"payload.request.intent.name","propertyType":"msg","rules":[{"t":"eq","v":"QueryIntent","vt":"str"},{"t":"eq","v":"CommandIntent","vt":"str"},{"t":"else"}],"checkall":"true","outputs":3,"x":491,"y":80.00000762939453,"wires":[["f2edc3da.e0fb8"],["4947fdd6.659d4c"],[]]},{"id":"25b4a780.c97f5","type":"template","z":"5a127c38.fea13c","name":"Response","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Ok waking them up!","x":346,"y":233,"wires":[["525a054d.31a8bc"]]},{"id":"525a054d.31a8bc","type":"template","z":"5a127c38.fea13c","name":"Format response","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"version\": \"1.0\",\n  \"response\": {\n    \"outputSpeech\": {\n      \"type\": \"PlainText\",\n      \"text\": \"{{payload}}\"\n    },\n    \"shouldEndSession\": true\n  }\n}","x":534,"y":233,"wires":[["edc78601.8dc588"]]},{"id":"edc78601.8dc588","type":"json","z":"5a127c38.fea13c","name":"","x":713,"y":233,"wires":[["38f30042.4cdd78"]]},{"id":"38f30042.4cdd78","type":"http response","z":"5a127c38.fea13c","name":"","x":851,"y":233,"wires":[]},{"id":"4947fdd6.659d4c","type":"function","z":"5a127c38.fea13c","name":"Send Command","func":"// Add something to do here\nvar msg1 = { payload: 1 };\nreturn [ msg, msg1 ];","outputs":"2","noerr":0,"x":154,"y":240,"wires":[["25b4a780.c97f5"],["551e0678.af508"]]},{"id":"796cb425.5c6adc","type":"mqtt in","z":"5a127c38.fea13c","name":"MQTT In","topic":"fileark/f/watsonlink","qos":"2","broker":"1b42a690.206209","x":127.5,"y":492.2333679199219,"wires":[["8b99ef7c.2a946","ccb62794.9a62b8"]]},{"id":"ccb62794.9a62b8","type":"debug","z":"5a127c38.fea13c","name":"","active":true,"console":"false","complete":"false","x":567.5,"y":493.1333312988281,"wires":[]},{"id":"551e0678.af508","type":"mqtt out","z":"5a127c38.fea13c","name":"MQTT Out","topic":"fileark/f/watsoncmd","qos":"","retain":"","broker":"1b42a690.206209","x":354.5,"y":278.66668701171875,"wires":[]},{"id":"2155f8b4.2c926","type":"inject","z":"5a127c38.fea13c","name":"test trigger","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":172.5,"y":279.36663818359375,"wires":[["551e0678.af508"]]},{"id":"f2edc3da.e0fb8","type":"function","z":"5a127c38.fea13c","name":"Check last update","func":"var ld = new Date(global.get(\"LastUpdate\"));\nvar d = new Date();\n\nvar minutes = (d.getTime() - ld.getTime()) / 1000 / 60 ;\nminutes = Math.round(minutes);\n\nif (minutes <= 30)\n{\n    hrs = minutes / 60;\n    say = \"Yes, they are up!\";\n}\nelse if (minutes > 60)\n{\n    hrs = minutes / 60;\n    say = \"I have not seen movement in \" + Math.round(hrs) + \" hours.\";\n}\nelse\n{\n     say = \"I have not seen movement in \" + minutes + \" minutes\";   \n}\n\n\nmsg.payload = say;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":154.0333251953125,"y":151.0999755859375,"wires":[["35ceb507.7632c2"]]},{"id":"8b99ef7c.2a946","type":"function","z":"5a127c38.fea13c","name":"Store Last Update","func":"//construct and format a date timestamp from now()\nd = new Date();\ndformat = [d.getMonth()+1,\nd.getDate(),\nd.getFullYear()].join('/')+' '+\n[d.getHours(),\nd.getMinutes(),\nd.getSeconds()].join(':');\n\nglobal.set(\"LastUpdate\", dformat)\n\nmsg.payload = dformat;\nreturn msg;","outputs":1,"noerr":0,"x":336.5,"y":523.1666870117188,"wires":[["ccb62794.9a62b8"]]},{"id":"bd1bb85d.8d8f68","type":"inject","z":"5a127c38.fea13c","name":"Set date now","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":152.2666473388672,"y":357.2666320800781,"wires":[["2436222a.9f84ae"]]},{"id":"2436222a.9f84ae","type":"function","z":"5a127c38.fea13c","name":"","func":"//construct and format a date timestamp from now()\nd = new Date();\ndformat = [d.getMonth()+1,\nd.getDate(),\nd.getFullYear()].join('/')+' '+\n[d.getHours(),\nd.getMinutes(),\nd.getSeconds()].join(':');\n\nglobal.set(\"LastUpdate\", dformat)\n\nmsg.payload = dformat;\nreturn msg;","outputs":1,"noerr":0,"x":338.03330993652344,"y":357.1666259765625,"wires":[["1544c053.8ca66"]]},{"id":"1544c053.8ca66","type":"debug","z":"5a127c38.fea13c","name":"","active":true,"console":"false","complete":"false","x":562.2666473388672,"y":357.43328857421875,"wires":[]},{"id":"251659c.ac28226","type":"inject","z":"5a127c38.fea13c","name":"Set date -8","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":142.03330993652344,"y":394.89996337890625,"wires":[["1763777a.967369"]]},{"id":"1763777a.967369","type":"function","z":"5a127c38.fea13c","name":"","func":"//construct and format a date timestamp from now()\nd = new Date();\ndformat = [d.getMonth()+1,\nd.getDate(),\nd.getFullYear()].join('/')+' '+\n[d.getHours()-9,\nd.getMinutes(),\nd.getSeconds()].join(':');\n\nglobal.set(\"LastUpdate\", dformat)\n\nmsg.payload = dformat;\nreturn msg;","outputs":1,"noerr":0,"x":337.7999725341797,"y":394.7999572753906,"wires":[["44cc3f7a.2cd39"]]},{"id":"44cc3f7a.2cd39","type":"debug","z":"5a127c38.fea13c","name":"","active":true,"console":"false","complete":"false","x":562.0333099365234,"y":395.0666198730469,"wires":[]},{"id":"8c19a09e.766f1","type":"debug","z":"5a127c38.fea13c","name":"","active":true,"console":"false","complete":"payload","x":285.5,"y":37.133331298828125,"wires":[]},{"id":"bc931ae5.e0935","type":"inject","z":"5a127c38.fea13c","name":"Compare date","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":146.2666473388672,"y":440.2666320800781,"wires":[["5028ce32.d132d8"]]},{"id":"5028ce32.d132d8","type":"function","z":"5a127c38.fea13c","name":"","func":"var ld = new Date(global.get(\"LastUpdate\"));\nvar d = new Date();\n\nvar minutes = (d.getTime() - ld.getTime()) / 1000 / 60 ;\nminutes = Math.round(minutes);\n\nif (minutes <= 30)\n{\n    hrs = minutes / 60;\n    say = \"Yes, they are up!\";\n}\nelse if (minutes > 60)\n{\n    hrs = minutes / 60;\n    say = \"I havent seen movement in \" + hrs + \" hours.\";\n}\nelse\n{\n     say = \"I havent seen movement in \" + minutes + \" minutes\";   \n}\n\n\nmsg.payload = say;\n\nvar msg1 = { payload:  minutes};\nreturn [ [msg, msg1]];\n","outputs":1,"noerr":0,"x":330.03330993652344,"y":441.1666259765625,"wires":[["dcec26.9ee60bd8"]]},{"id":"dcec26.9ee60bd8","type":"debug","z":"5a127c38.fea13c","name":"","active":true,"console":"false","complete":"false","x":552.4999847412109,"y":440.5332946777344,"wires":[]},{"id":"1b42a690.206209","type":"mqtt-broker","z":"","broker":"io.adafruit.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

Flow Info

Created 6 years, 10 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x5)
  • function (x6)
  • http in (x1)
  • http response (x2)
  • inject (x4)
  • json (x2)
  • mqtt in (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • switch (x2)
  • template (x3)
Other
  • tab (x1)

Tags

  • Node-RED
  • Alexa
  • Walabot
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option