Skip to content

Instantly share code, notes, and snippets.

@lu4t

lu4t/README.md Secret

Last active February 4, 2022 15:55
Show Gist options
  • Save lu4t/be738b0dbfb683086707b18e39ba1a9e to your computer and use it in GitHub Desktop.
Save lu4t/be738b0dbfb683086707b18e39ba1a9e to your computer and use it in GitHub Desktop.
"Are you sure?", confirm an action triggered on the Dashboard with whatsapp. Whin use case.

On this flow you will see how to get a whatsapp with two buttons (yes / no) that will ask you for confirmation before a kill switch on you node-red Dashboard changes state.

It is useful if your node-red dashboard has a switch that triggers an automation, and you don't want it to happen without your active action.

This example is an alternative to a pop-up message shown on the dashboard which was the original solution suggested on the community forum.

You can see a demo of the flow running here: https://youtu.be/ePGRRq4VTz4


This flow is inspired on this thread: https://discourse.nodered.org/t/are-you-sure-pop-ups/13458/25; it is an alternative implementation using node-red-contrib-whin nodes.

Feb-2022 by inUntil

[
{
"id": "6ae2622fe539cb5b",
"type": "ui_switch",
"z": "42ea5846ccd51a87",
"name": "Kill Switch - whin",
"label": "Kill Switch",
"tooltip": "you have to confirm on whatsapp.",
"group": "d15dc202ba5c70ad",
"order": 18,
"width": "4",
"height": "1",
"passthru": false,
"decouple": "true",
"topic": "",
"topicType": "str",
"style": "",
"onvalue": "0",
"onvalueType": "num",
"onicon": "fa-2x fa-bolt",
"oncolor": "yellow",
"offvalue": "1",
"offvalueType": "num",
"officon": "fa-2x fa-power-off",
"offcolor": "gray",
"animate": true,
"x": 430,
"y": 150,
"wires": [
[
"316a4c6f89e06775",
"740412fc04728eed"
]
]
},
{
"id": "94be09694b3b9b7f",
"type": "function",
"z": "42ea5846ccd51a87",
"name": "feedback to ui",
"func": "//only accept YES msg's\nif (msg.payload.whin == 'YES') {\n msg.payload = msg.payload.ui;\n node.send(msg);\n}\nreturn null;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1305,
"y": 100,
"wires": [
[
"6ae2622fe539cb5b"
]
]
},
{
"id": "316a4c6f89e06775",
"type": "change",
"z": "42ea5846ccd51a87",
"name": "prepare join",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "ui",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 100,
"wires": [
[
"4e9e8b9036fb5ccc"
]
]
},
{
"id": "84230657bb262ecb",
"type": "comment",
"z": "42ea5846ccd51a87",
"name": "credits",
"info": "this flow is inspired on this thread:\n\nhttps://discourse.nodered.org/t/are-you-sure-pop-ups/13458/25\n\nit is an alternative implementation, based on node-red-contrib-whin\n\nFeb-2022 by inUntil",
"x": 450,
"y": 225,
"wires": []
},
{
"id": "108b995d75b8ae17",
"type": "whin-confirm",
"z": "42ea5846ccd51a87",
"name": "whin confirm",
"auth": "1dd48adf4bee331d",
"x": 830,
"y": 175,
"wires": [
[
"d527236c8370eed5"
]
]
},
{
"id": "740412fc04728eed",
"type": "change",
"z": "42ea5846ccd51a87",
"name": "question and TTL",
"rules": [
{
"t": "set",
"p": "ttl",
"pt": "msg",
"to": "20000",
"tot": "num"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "DID YOU LIKE IT?",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 175,
"wires": [
[
"108b995d75b8ae17"
]
]
},
{
"id": "4e9e8b9036fb5ccc",
"type": "join",
"z": "42ea5846ccd51a87",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 1150,
"y": 100,
"wires": [
[
"94be09694b3b9b7f"
]
]
},
{
"id": "d527236c8370eed5",
"type": "change",
"z": "42ea5846ccd51a87",
"name": "prepare join",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "whin",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 995,
"y": 175,
"wires": [
[
"4e9e8b9036fb5ccc"
]
]
},
{
"id": "2c3d329496048e74",
"type": "comment",
"z": "42ea5846ccd51a87",
"name": "Passes the original value along",
"info": "",
"x": 855,
"y": 75,
"wires": []
},
{
"id": "c0360ef897a22090",
"type": "comment",
"z": "42ea5846ccd51a87",
"name": "Asks for confirmation on whatsapp",
"info": "",
"x": 915,
"y": 225,
"wires": []
},
{
"id": "d15dc202ba5c70ad",
"type": "ui_group",
"name": "",
"tab": "c8377355.8e04f",
"order": 2,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "1dd48adf4bee331d",
"type": "whin-config",
"name": "demo config",
"phone": "YOUR_PHONE",
"token": "YOUR_WHIN_TOKEN"
},
{
"id": "c8377355.8e04f",
"type": "ui_tab",
"name": "whin confirm - demo",
"icon": "dashboard",
"order": 3,
"disabled": false,
"hidden": false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment