-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiNeed.json
1 lines (1 loc) · 3.25 KB
/
iNeed.json
1
[{"id":"86494e0e.8a272","type":"streaming-stt","z":"937c4028.23ef08","name":"","cmd":"","x":395.78570556640625,"y":196.14285278320312,"wires":[["1373c1c1.2576c6"],[]]},{"id":"c38d5e03.2c559","type":"inject","z":"937c4028.23ef08","name":"Start Listening ","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":168.7857208251953,"y":198.14285469055176,"wires":[["86494e0e.8a272"]]},{"id":"4809cea5.7ce558","type":"inject","z":"937c4028.23ef08","name":"Stop Listening ","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"x":167.2857208251953,"y":270.14285469055176,"wires":[["86494e0e.8a272"]]},{"id":"e4d512bb.9dccd8","type":"function","z":"937c4028.23ef08","name":"set payload","func":"if(msg.payload.results[0].alternatives[0].transcript)\n{\n msg.payload = msg.payload.results[0].alternatives[0].transcript;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":667.1428833007812,"y":195.71429443359375,"wires":[["91a23ee.8ec08c","542b280.6ba03d8"]]},{"id":"1373c1c1.2576c6","type":"delay","z":"937c4028.23ef08","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":424,"y":294,"wires":[["e4d512bb.9dccd8"]]},{"id":"de8f47c2.18ecb","type":"http request","z":"937c4028.23ef08","name":"IFTTT Request.","method":"POST","ret":"txt","url":"","tls":"","x":1115.8571166992188,"y":196.28570556640625,"wires":[["81075f77.7573b8"]]},{"id":"81075f77.7573b8","type":"debug","z":"937c4028.23ef08","name":"","active":true,"console":"true","complete":"true","x":1273.5,"y":307,"wires":[]},{"id":"91a23ee.8ec08c","type":"function","z":"937c4028.23ef08","name":"Tokenize","func":"var tokens = msg.payload.split(\" \");\nfor(i = 0;i< tokens.length;i++)\n{\n if(tokens[i]===\"need\")\n {\n var item = tokens[i+1];\n var qty = 1;\n if(i+2<tokens.length)\n {\n if(tokens[i+2]!=\"please\")\n {\n qty = tokens[i+2]\n }\n \n }\n var json = { \"value1\" : item, \"value2\" : qty};\n msg.url = \"https://maker.ifttt.com/trigger/add_to_list/with/key/hj9q0op-sYdOb9x_fz0IF0e7qlO0IdKAVBLilI91H1Z\";\n msg.payload = json;\n return msg;\n\n }\n \n else if(tokens[i]===\"have\")\n {\n var item = tokens[i+1];\n var qty = 1;\n if(i+2<tokens.length)\n {\n if(tokens[i+2]!=\"please\")\n {\n qty = tokens[i+2]\n }\n \n }\n var json = { \"value1\" : item, \"value2\" : qty};\n msg.url = \"https://maker.ifttt.com/trigger/add_item/with/key/hj9q0op-sYdOb9x_fz0IF0e7qlO0IdKAVBLilI91H1Z\";\n msg.payload = json;\n return msg;\n } \n}\n\n\n\n","outputs":1,"noerr":0,"x":887.5,"y":196,"wires":[["542b280.6ba03d8","de8f47c2.18ecb"]]},{"id":"82232a40.c08c6","type":"comment","z":"937c4028.23ef08","name":"Sets REST params","info":"set parameters for REST call","x":886.5,"y":145,"wires":[]},{"id":"11bbb30.31851cd","type":"comment","z":"937c4028.23ef08","name":"POST/GET request","info":"POST/GET request to IFTTT with JSON params","x":1113,"y":143,"wires":[]},{"id":"542b280.6ba03d8","type":"debug","z":"937c4028.23ef08","name":"","active":true,"console":"false","complete":"true","x":1018.5,"y":368,"wires":[]}]