Cloudron Notifications in Telegram
-
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}/getUpdatesYou 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.
-
M manngobaum referenced this topic on
-
Did you explore this any further?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login