IFTTT trigger and endpoint
Subflows to create ifttt endpoints and triggers.
Uses the default http requests and http in nodes to send and recieve requests. Endpoints needs to be accessible from the internet.
I'm running nginx reverse proxy, and I've configured it as following
location /ifttt/ {
auth_basic "Restricted";
auth_basic_user_file conf/htpasswd;
proxy_pass http://127.0.0.1:1880/ifttt/;
proxy_set_header Authorization "";
}
For the test, make two new applets
If Button Widget Then Webhooks
- Url: https://username:password@your-domain.com/ifttt/test
- Method: POST
- Content-Type: application/json
- Body: {"value1":"test1","value2":"test2","value3":"test3"}
If Webhooks Then Notification
- Event Name: test
- Message: {{Value1}} - {{Value2}} - {{Value3}}
Head over to Webhooks Settings to get your IFTTT-key.
Enter the key in the trigger node, along with test as Event. In the endpoint node, enter /ifttt/test
Deploy changes, then head over to your phone to send the Button-event from the IFTTT widget.
You should then recieve a notification on your phone with the text test1 - test2 - test3, and the debug node should output
msg.payload : Object
{ value1: "test1", value2: "test2", value3: "test3" }
msg.payload : string[44]
"Congratulations! You've fired the test event"
[{"id":"453e1982.d8ab98","type":"subflow","name":"ifttt trigger","info":"Sends an event to IFTTT.com\n\nCan be paired directly with an ifttt endpoint.\n\nKey and event are required.\n\nBody can be set by sending msg.payload\n\n```\n{\n \"value1\":\"test1\",\n \"value2\":\"test2\",\n \"value3\":\"test3\"\n}\n```","category":"","in":[{"x":60,"y":40,"wires":[{"id":"f4c357d2.c37b78"}]}],"out":[{"x":720,"y":40,"wires":[{"id":"c481c885.0a9e98","port":0}]}],"env":[{"name":"key","type":"str","value":"","ui":{"icon":"font-awesome/fa-key","label":{"en-US":"Key"},"type":"input","opts":{"types":["str"]}}},{"name":"event","type":"str","value":"","ui":{"icon":"font-awesome/fa-chain","label":{"en-US":"Event"},"type":"input","opts":{"types":["str"]}}},{"name":"value1","type":"str","value":"","ui":{"icon":"font-awesome/fa-angle-right","type":"input","opts":{"types":["str"]},"label":{}}},{"name":"value2","type":"str","value":"","ui":{"icon":"font-awesome/fa-angle-right","type":"input","opts":{"types":["str"]},"label":{}}},{"name":"value3","type":"str","value":"","ui":{"icon":"font-awesome/fa-angle-right","type":"input","opts":{"types":["str"]},"label":{}}}],"color":"#3FADB5","icon":"font-awesome/fa-cloud-upload","status":{"x":720,"y":100,"wires":[{"id":"79306850.82d7e8","port":0}]}},{"id":"c481c885.0a9e98","type":"http request","z":"453e1982.d8ab98","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"","tls":"b659c663.2aede8","persist":false,"proxy":"","authType":"","x":390,"y":40,"wires":[["79306850.82d7e8"]]},{"id":"f4c357d2.c37b78","type":"function","z":"453e1982.d8ab98","name":"make payload","func":"let key = env.get(\"key\");\nlet event = env.get(\"event\");\nlet value1 = env.get(\"value1\");\nlet value2 = env.get(\"value2\");\nlet value3 = env.get(\"value3\");\nvar body = msg.payload;\nif (typeof body === 'object' && body !== null){\n msg.payload = body;\n} else {\n msg.payload = {\"value1\":value1,\"value2\":value2,\"value3\":value3};\n}\nmsg.url = \"https://maker.ifttt.com/trigger/\"+event+\"/with/key/\"+key\nreturn msg;\n","outputs":1,"noerr":0,"x":200,"y":40,"wires":[["c481c885.0a9e98"]]},{"id":"79306850.82d7e8","type":"function","z":"453e1982.d8ab98","name":"StatusCode","func":"statusCode = msg.statusCode;\nif (statusCode == 200){\n msg.payload = {fill:\"green\",shape:\"dot\",text:statusCode}\n} else {\n msg.payload = {fill:\"red\",shape:\"dot\",text:statusCode}\n}\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":100,"wires":[[]]},{"id":"b659c663.2aede8","type":"tls-config","z":"","name":"No Verify","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false},{"id":"4486a751.ad6dd8","type":"subflow","name":"ifttt endpoint","info":"Recieve an event from IFTTT.com\n\nCan be paired up directly to an ifttt trigger.\n\nNeeds to be forwarded in firewall/proxy etc.\n\nOutput in msg.payload as JSON Object\n\n```\n{\n \"value1\":\"test1\",\n \"value2\":\"test2\",\n \"value3\":\"test3\"\n}\n```","category":"","in":[],"out":[{"x":540,"y":180,"wires":[{"id":"f0e27690.57b908","port":0}]}],"env":[{"name":"endpoint","type":"str","value":"","ui":{"icon":"font-awesome/fa-chain","label":{"en-US":"Endpoint"},"type":"input","opts":{"types":["str"]}}}],"color":"#3FADB5","icon":"font-awesome/fa-cloud-download","status":{"x":540,"y":240,"wires":[{"id":"bad1d2f8.53181","port":0}]}},{"id":"f0e27690.57b908","type":"http in","z":"4486a751.ad6dd8","name":"","url":"${endpoint}","method":"post","upload":false,"swaggerDoc":"","x":190,"y":140,"wires":[["227d812d.0f983e","bad1d2f8.53181"]]},{"id":"227d812d.0f983e","type":"http response","z":"4486a751.ad6dd8","name":"","statusCode":"200","headers":{},"x":440,"y":100,"wires":[]},{"id":"bad1d2f8.53181","type":"function","z":"4486a751.ad6dd8","name":"timestamp","func":"var date = new Date().toLocaleString();\nmsg.payload = {fill:\"grey\",shape:\"ring\",text:date}\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":240,"wires":[[]]},{"id":"303d5bb.6107ba4","type":"tab","label":"ifttt","disabled":false,"info":""},{"id":"9a386a5e.20c398","type":"subflow:4486a751.ad6dd8","z":"303d5bb.6107ba4","name":"/ifttt/test","env":[{"name":"endpoint","value":"/ifttt/test","type":"str"}],"x":110,"y":160,"wires":[["3634e110.c212ae","c1f3cadc.3c3b38"]]},{"id":"3634e110.c212ae","type":"debug","z":"303d5bb.6107ba4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":450,"y":220,"wires":[]},{"id":"c1f3cadc.3c3b38","type":"subflow:453e1982.d8ab98","z":"303d5bb.6107ba4","name":"","env":[{"name":"key","value":"your-key","type":"str"},{"name":"event","value":"test","type":"str"}],"x":320,"y":160,"wires":[["3634e110.c212ae"]]}]