Hi all!
Actually i have been using a custom Telegram "menu" in a simple way. I mean, a command node, and some functions to work together.
An example in the following screen shot.
The code:
[
{
"id": "a006ca3c.bf57f8",
"type": "function",
"z": "31d2354e.c7d47a",
"name": "confirmation message",
"func": "var opts = {\n reply_markup: JSON.stringify({\n keyboard: [\n ['Bajar peliculas'],\n ['Iluminacion'],\n ['Resetear Sonoffs'],\n ['Versiones Sonoffs'],\n ['Listar dispositivos en red local'],\n ['Ip publica'],\n ['Control de VMs'],\n ['Salir'],\n ],\n 'resize_keyboard' : true, \n 'remove_keyboard' : true\n })\n};\n\nmsg.payload.content = 'Selecciona una opción:';\nmsg.payload.options = opts;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 400,
"y": 100,
"wires": [
[
"3737123ab3432afb"
]
]
},
{
"id": "b9a949ef.104a98",
"type": "function",
"z": "31d2354e.c7d47a",
"name": "create response",
"func": "if(msg.payload.content === 'Bajar peliculas')\n{\n msg.payload.content = '/torrents';\n return [msg, null]; \n}\nif(msg.payload.content === 'Iluminacion')\n{\n msg.payload.content = '/iluminacion';\n return [msg, null];\n}\nif(msg.payload.content === 'Resetear Sonoffs')\n{\n msg.payload.content = '/resetsonoff';\n return [msg, null];\n}\nif(msg.payload.content === 'Versiones Sonoffs')\n{\n msg.payload.content = 'Chequeando versiones Tasmota en los sonoffs...';\n return [msg, null];\n}\nif(msg.payload.content === 'Listar dispositivos en red local')\n{\n msg.payload.content = 'Listar dispositivos en red local';\n return [msg, null];\n}\nif(msg.payload.content === 'Ip publica')\n{\n msg.payload.content = 'Procesando ip publica...';\n return [msg, null];\n}\nif(msg.payload.content === 'Control de VMs')\n{\n msg.payload.content = '/vmhosts';\n return [msg, null];\n}\nif(msg.payload.content === 'Salir')\n{\n msg.payload.content = 'Adios!';\n return [msg, null];\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 140,
"wires": [
[
"b0de20d8.017bf",
"6cf94e31.1f1bf"
]
]
},
{
"id": "b0de20d8.017bf",
"type": "delay",
"z": "31d2354e.c7d47a",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 360,
"y": 180,
"wires": [
[
"e9f67f2c.ee1b9"
]
]
},
{
"id": "e9f67f2c.ee1b9",
"type": "switch",
"z": "31d2354e.c7d47a",
"name": "",
"property": "payload.content",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "/torrents",
"vt": "str"
},
{
"t": "eq",
"v": "Listar dispositivos en red local",
"vt": "str"
},
{
"t": "eq",
"v": "Procesando ip publica...",
"vt": "str"
},
{
"t": "eq",
"v": "/vmhosts",
"vt": "str"
},
{
"t": "eq",
"v": "Chequeando versiones Tasmota en los sonoffs...",
"vt": "str"
},
{
"t": "eq",
"v": "Adios!",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 6,
"x": 350,
"y": 260,
"wires": [
[],
[
"51de7222f6db2ec3"
],
[
"0a99c7f2e11239e4"
],
[
"ad18cef9d91611dc"
],
[
"dd4a98e61e40e2b9"
],
[
"e7e65dd3fcb43324"
]
]
}
]
How can i improve this?.
Is there any way to make a Menu with inline keyboard?.
suggestions?.
Thanks a lot!.
Regards.