[ { "id": "25f90c0d.65d254", "type": "tab", "label": "Telegram Chat Bot", "disabled": false, "info": "" }, { "id": "715e63a4.b3a57c", "type": "telegram command", "z": "25f90c0d.65d254", "name": "/help", "command": "/help", "bot": "da15078.aa18ff8", "x": 130, "y": 240, "wires": [ [ "d62a88e1.359eb8" ], [] ] }, { "id": "d62a88e1.359eb8", "type": "function", "z": "25f90c0d.65d254", "name": "create help respone", "func": "var help = \"/help - shows help (this)\\r\\n\";\nhelp += \"/run - show available commands \\r\\n\";\n\nmsg.payload.content = help;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 420, "y": 220, "wires": [ [ "1f670b7d.001245" ] ] }, { "id": "1f670b7d.001245", "type": "telegram sender", "z": "25f90c0d.65d254", "name": "", "bot": "da15078.aa18ff8", "x": 770, "y": 220, "wires": [ [] ] }, { "id": "ad02e9be.0f0748", "type": "telegram command", "z": "25f90c0d.65d254", "name": "/run", "command": "/run", "bot": "da15078.aa18ff8", "x": 130, "y": 380, "wires": [ [ "cd187b86.03a648" ], [ "e98879a2.4ec298", "f58d7e96.d2737" ] ] }, { "id": "cd187b86.03a648", "type": "function", "z": "25f90c0d.65d254", "name": "confirmation message", "func": "context.global.keyboard = { pending : true };\ncontext.global.cmd = { pending : true };\n\nvar opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n keyboard: [['Turn ON Bedroom','Turn OFF Bedroom'],['Turn ON Kitchen','Turn OFF Kitchen']],\n 'resize_keyboard' : true, \n 'one_time_keyboard' : true\n })\n};\n\nmsg.payload.content = 'Choose command';\nmsg.payload.options = opts;\n\nreturn [ msg ];\n", "outputs": "1", "noerr": 0, "x": 423.5, "y": 269, "wires": [ [ "1f670b7d.001245" ] ] }, { "id": "e98879a2.4ec298", "type": "function", "z": "25f90c0d.65d254", "name": "create response", "func": "if(context.global.keyboard.pending)\n{\n context.global.keyboard.pending = false;\n msg.payload = msg.payload.content;\n return msg;\n /*\n if(msg.payload.content === 'ON: Bedroom')\n {\n msg.payload.content = 'Turn ON Bedroom';\n return msg; \n }\n else if(msg.payload.content === 'OFF: Bedroom')\n {\n msg.payload.content = 'Turn OFF Bedroom';\n return msg; \n }\n else if(msg.payload.content === 'ON: Kitchen')\n {\n msg.payload.content = 'Turn ON Kitchen';\n return msg; \n }\n else if(msg.payload.content === 'OFF: Kitchen')\n {\n msg.payload.content = 'Turn OFF Kitchen';\n return msg; \n }*/\n}\n", "outputs": "1", "noerr": 0, "x": 400, "y": 320, "wires": [ [ "1f670b7d.001245" ] ] }, { "id": "f58d7e96.d2737", "type": "function", "z": "25f90c0d.65d254", "name": "set cmd", "func": "if(context.global.cmd.pending)\n{\n context.global.cmd.pending = false;\n if(msg.payload.content === 'Turn ON Bedroom')\n {\n msg.payload = 'ON';\n return [msg, null, null, null]; \n }\n else if(msg.payload.content === 'Turn OFF Bedroom')\n {\n msg.payload = 'OFF';\n return [null, msg, null, null]; \n }\n else if(msg.payload.content === 'Turn ON Kitchen')\n {\n msg.payload = 'ON';\n return [null, null, msg, null]; \n }\n else if(msg.payload.content === 'Turn OFF Kitchen')\n {\n msg.payload = 'OFF';\n return [null, null, null, msg]; \n }\n}\n", "outputs": "4", "noerr": 0, "x": 380, "y": 420, "wires": [ [ "468f6d80.14d7c4" ], [ "468f6d80.14d7c4" ], [ "7441378a.cf9c68" ], [ "7441378a.cf9c68" ] ], "outputLabels": [ "Turn ON Bedroom", "Turn OFF Bedroom", "Turn ON Kitchen", "Turn OFF Kitchen" ] }, { "id": "468f6d80.14d7c4", "type": "realknx-out", "z": "25f90c0d.65d254", "name": "Bedroom", "controller": "b1d2fbe.d184108", "itemname": "Bedroom - Ceiling", "topic": "", "payload": "", "booleaninput": true, "x": 610.9999847412109, "y": 405.9999747276306, "wires": [] }, { "id": "7441378a.cf9c68", "type": "realknx-out", "z": "25f90c0d.65d254", "name": "Kitchen", "controller": "b1d2fbe.d184108", "itemname": "Living Room - Ceiling", "topic": "", "payload": "", "booleaninput": true, "x": 613.9999847412109, "y": 463.9999361038208, "wires": [] }, { "id": "c4878259.e32c6", "type": "telegram receiver", "z": "25f90c0d.65d254", "name": "", "bot": "da15078.aa18ff8", "saveDataDir": "", "x": 170, "y": 640, "wires": [ [ "a5b1e6e5.626808" ], [ "edd031d8.d9722" ] ] }, { "id": "a5b1e6e5.626808", "type": "debug", "z": "25f90c0d.65d254", "name": "", "active": false, "console": "false", "complete": "true", "x": 350, "y": 600, "wires": [] }, { "id": "edd031d8.d9722", "type": "debug", "z": "25f90c0d.65d254", "name": "", "active": false, "console": "false", "complete": "true", "x": 350, "y": 660, "wires": [] }, { "id": "1623288.98637d8", "type": "comment", "z": "25f90c0d.65d254", "name": "Debug for Chat ID", "info": "", "x": 170, "y": 600, "wires": [] }, { "id": "da15078.aa18ff8", "type": "telegram bot", "z": "", "botname": "realknx1", "usernames": "", "chatids": "" }, { "id": "b1d2fbe.d184108", "type": "realknx-controller", "z": "", "name": "realknx-ctrl", "host": "localhost", "port": "3000" } ]