Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Cloudron Notifications in Telegram

    N8N
    1
    1
    148
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      manngobaum last edited by manngobaum

      My goal is to interact with my Cloudron Instance via Telegram or other Chat protocols. I know there are already implementations for Uptime Kuma but I wanted to have more flexibilty and for the future also response endpoints in my messages (restarting an app or even Cloudron (it's not impleted yet)).

      What it basically does is to fetch the Cloudron notifications of a certain status and to send a message to a Telegram Chat.
      Therefore I set up a Telegram Bot (https://core.telegram.org/bots). Started a chat with this bot and used the following HTTP request to receive the chat ID which is needed for n8n:

      https://api.telegram.org/bot{TELEGRAMBOT_API_KEY}/getUpdates
      

      You also need an API Key to access your Cloudron (https://my.xxx.tld.de/#/profile) -> under API Tokens

      And here is the code for the notifications to build the workflow in n8n:

      {
        "nodes": [
          {
            "parameters": {
              "interval": 60
            },
            "name": "Interval",
            "type": "n8n-nodes-base.interval",
            "typeVersion": 1,
            "position": [
              460,
              300
            ]
          },
          {
            "parameters": {
              "url": "https://my.xxx.tld/api/v1/notifications?acknowledged=false&page=1&per_page=100",
              "options": {
                "splitIntoItems": false
              },
              "headerParametersUi": {
                "parameter": [
                  {
                    "name": "authorization",
                    "value": "Bearer {Cloudron_API_KEY}"
                  }
                ]
              }
            },
            "name": "HTTP Request",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 2,
            "position": [
              620,
              300
            ]
          },
          {
            "parameters": {
              "chatId": "{TELEGRAM_CHAT_ID}",
              "text": "=<b>What?</b>\n{{$node[\"Item Lists\"].json[\"title\"]}}\n\n<b>When?</b>\n{{$node[\"Item Lists\"].json[\"creationTime\"]}}\n\n<b>Message</b>\n{{$node[\"Item Lists\"].json[\"message\"]}}",
              "additionalFields": {
                "parse_mode": "HTML"
              }
            },
            "name": "Telegram",
            "type": "n8n-nodes-base.telegram",
            "typeVersion": 1,
            "position": [
              940,
              300
            ],
            "credentials": {
              "telegramApi": {
                "id": "7",
                "name": "Telegram account"
              }
            }
          },
          {
            "parameters": {
              "fieldToSplitOut": "notifications",
              "options": {}
            },
            "name": "Item Lists",
            "type": "n8n-nodes-base.itemLists",
            "typeVersion": 1,
            "position": [
              780,
              300
            ]
          },
          {
            "parameters": {
              "requestMethod": "POST",
              "url": "=https://my.xxx.tld/api/v1/notifications/{{$node[\"Item Lists\"].json[\"id\"]}}",
              "options": {},
              "headerParametersUi": {
                "parameter": [
                  {
                    "name": "authorization",
                    "value": "Bearer XXX"
                  }
                ]
              }
            },
            "name": "HTTP Request1",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 2,
            "position": [
              1100,
              300
            ]
          }
        ],
        "connections": {
          "Interval": {
            "main": [
              [
                {
                  "node": "HTTP Request",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          },
          "HTTP Request": {
            "main": [
              [
                {
                  "node": "Item Lists",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          },
          "Telegram": {
            "main": [
              [
                {
                  "node": "HTTP Request1",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          },
          "Item Lists": {
            "main": [
              [
                {
                  "node": "Telegram",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          }
        }
      }
      

      I'll update this soon to include App downtimes with the possibilty to restart the App right away.

      1 Reply Last reply Reply Quote 4
      • Referenced by  M manngobaum 
      • First post
        Last post
      Powered by NodeBB