Good day,
Very recently I embarked on finding a way to ping network devices from a database or list. While pinging and a device appears offline, i then wanted to post that "offline" device to Telegram.
A member on the group was brilliant at assisting me and I was able to achieve exactly what was described above. Truly magic member.
Getting to the point: Each failed device will send a separate message and the Bot does not like being bombarded with messages and at some point give up and does not report all failures.
So now I am looking for a way to join or wait a certain time and then send as one combined message.
An example of the offline devices attached picture and the bottom part is the result that I am after, one combined message.
Thank you for looking.
[
    {
        "id": "337047ad.fcb858",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "d901eeaa.d0d01",
        "type": "debug",
        "z": "337047ad.fcb858",
        "name": "Query DB",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 180,
        "wires": []
    },
    {
        "id": "dc501b75.0d31d8",
        "type": "ping",
        "z": "337047ad.fcb858",
        "mode": "triggered",
        "name": "",
        "host": "",
        "timer": "1",
        "inputs": 1,
        "x": 590,
        "y": 220,
        "wires": [
            [
                "d901eeaa.d0d01",
                "2e4bb18e.82e07e"
            ]
        ]
    },
    {
        "id": "db694dbc.960ca",
        "type": "function",
        "z": "337047ad.fcb858",
        "name": "Prepare telegram message (if offline)",
        "func": "if(msg.payload===false)\n{\n    msg.payload = {};\n    msg.payload.type = 'message';\n    msg.payload.content = `${msg.ping.name} (${msg.ping.host}) seems to be OFFLINE`;\n    msg.payload.chatId = xxxxxxx\n    return msg;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1010,
        "y": 400,
        "wires": [
            [
                "37286037.e03f9"
            ]
        ]
    },
    {
        "id": "33fa1e6a.529bf2",
        "type": "debug",
        "z": "337047ad.fcb858",
        "name": "Query DB",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 360,
        "wires": []
    },
    {
        "id": "2e4bb18e.82e07e",
        "type": "function",
        "z": "337047ad.fcb858",
        "name": "Prepare telegram message",
        "func": "const chatId = xxxxxxxx; // << update this\n\nif (!msg.ping.host) return null; //ensure host has a value\n\nvar pingMonitor = flow.get(\"pingMonitor\") || {};//get lookup object ||or|| a new empty object\nvar pingPrev = pingMonitor[msg.ping.host] || {};//this ping monitor object ||or|| a new empty object\nvar sendTelegram = false;\n\n//if ping is good, you get a number in payload...\nif (typeof msg.payload == \"number\" && pingPrev.status === \"bad\" ) {\n    pingPrev.status = \"good\";\n    msg.payload = {};\n    msg.payload.type = 'message';\n    msg.payload.content = `${msg.ping.name} (${msg.ping.host}) is now back online & operational!`;\n    msg.payload.chatId = chatId;\n    sendTelegram = true;\n} else if (msg.payload === false && (pingPrev.status === \"good\" || !pingPrev.status)) {\n    pingPrev.status = \"bad\";\n    msg.payload = {};\n    msg.payload.type = 'message';\n    msg.payload.content = `${msg.ping.name} (${msg.ping.host}) seems to be OFFLINE`;\n    msg.payload.chatId = chatId;\n    sendTelegram = true;\n}\n\n//update context\npingPrev.datetime = new Date();\npingPrev.host = msg.ping.host;\npingPrev.name = msg.ping.name;\npingMonitor[msg.ping.host] = pingPrev;\nflow.set(\"pingMonitor\", pingMonitor);\n\nif (sendTelegram) return msg;\n\nreturn null;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 900,
        "y": 220,
        "wires": [
            [
                "37286037.e03f9"
            ]
        ]
    },
    {
        "id": "fb4b47cd.fa82a8",
        "type": "ping",
        "z": "337047ad.fcb858",
        "mode": "triggered",
        "name": "",
        "host": "",
        "timer": "20",
        "inputs": 1,
        "x": 750,
        "y": 400,
        "wires": [
            [
                "db694dbc.960ca"
            ]
        ]
    },
    {
        "id": "7e6ffb57.605f54",
        "type": "telegram command",
        "z": "337047ad.fcb858",
        "name": "",
        "command": "/ping",
        "bot": "d918e20d.f9968",
        "strict": false,
        "hasresponse": true,
        "useregex": true,
        "removeregexcommand": false,
        "outputs": 2,
        "x": 210,
        "y": 400,
        "wires": [
            [
                "f52ae2a8.a3715"
            ],
            []
        ]
    },
    {
        "id": "4b93459e.23e3cc",
        "type": "comment",
        "z": "337047ad.fcb858",
        "name": "Network Offline Devices",
        "info": "",
        "x": 260,
        "y": 320,
        "wires": []
    },
    {
        "id": "8e959977.43e508",
        "type": "Stackhero-MySQL",
        "z": "337047ad.fcb858",
        "server": "2fad9f54.9ef47",
        "name": "",
        "x": 450,
        "y": 220,
        "wires": [
            [
                "dc501b75.0d31d8"
            ]
        ]
    },
    {
        "id": "721b196e.c93328",
        "type": "function",
        "z": "337047ad.fcb858",
        "name": "",
        "func": "msg.topic = 'SELECT * FROM host WHERE active = 1';\nmsg.payload = {\"action\": \"Q\", \"query\" : \"SELECT * FROM host WHERE active = 1\"};\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 280,
        "y": 220,
        "wires": [
            [
                "8e959977.43e508"
            ]
        ]
    },
    {
        "id": "13abd7df.36a758",
        "type": "inject",
        "z": "337047ad.fcb858",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 250,
        "y": 140,
        "wires": [
            [
                "721b196e.c93328"
            ]
        ]
    },
    {
        "id": "f52ae2a8.a3715",
        "type": "function",
        "z": "337047ad.fcb858",
        "name": "",
        "func": "msg.topic = 'SELECT * FROM host WHERE active = 1';\nmsg.payload = {\"action\": \"Q\", \"query\" : \"SELECT * FROM host WHERE active = 1\"};\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 420,
        "y": 400,
        "wires": [
            [
                "296abbe8.a435d4"
            ]
        ]
    },
    {
        "id": "296abbe8.a435d4",
        "type": "Stackhero-MySQL",
        "z": "337047ad.fcb858",
        "server": "2fad9f54.9ef47",
        "name": "",
        "x": 570,
        "y": 400,
        "wires": [
            [
                "fb4b47cd.fa82a8",
                "33fa1e6a.529bf2"
            ]
        ]
    },
    {
        "id": "595da70a.e1c328",
        "type": "inject",
        "z": "337047ad.fcb858",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 250,
        "y": 360,
        "wires": [
            [
                "f52ae2a8.a3715"
            ]
        ]
    },
    {
        "id": "679da82f.ed7be8",
        "type": "comment",
        "z": "337047ad.fcb858",
        "name": "Set ping timer",
        "info": "",
        "x": 230,
        "y": 100,
        "wires": []
    },
    {
        "id": "37286037.e03f9",
        "type": "telegram sender",
        "z": "337047ad.fcb858",
        "name": "",
        "bot": "",
        "haserroroutput": false,
        "outputs": 1,
        "x": 1420,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "d918e20d.f9968",
        "type": "telegram bot",
        "botname": "@xxxxxxbot",
        "usernames": "",
        "chatids": "xxxxxxxxxx",
        "baseapiurl": "",
        "updatemode": "polling",
        "pollinterval": "300",
        "usesocks": false,
        "sockshost": "",
        "socksport": "",
        "socksusername": "",
        "sockspassword": "",
        "bothost": "",
        "botpath": "",
        "localbotport": "",
        "publicbotport": "",
        "privatekey": "",
        "certificate": "",
        "useselfsignedcertificate": false,
        "sslterminated": false,
        "verboselogging": false
    },
    {
        "id": "2fad9f54.9ef47",
        "type": "Stackhero-MySQL-Server",
        "name": "",
        "host": "192.168.1.250",
        "port": "3308",
        "tls": false,
        "database": "pinger"
    }
]



