Automated Safe Instance Updater with Telegram Alerts - n8n Workflow

Use this comprehensive n8n workflow to automatically monitor and safely update your self-hosted n8n instance. It checks for running executions before updating and sends alerts via Telegram.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Individuals running self-hosted n8n instances (via Linux/NPM or Docker).

  • DevOps engineers needing reliable monitoring for their automation infrastructure.

  • Users who want to ensure their n8n instance is always running the latest, secure version without manual checks.

  • Anyone searching for practical n8n templates for maintenance and monitoring.

Overview

Keeping a self-hosted n8n instance updated is crucial for security and accessing new features, but manual updates risk triggering downtime while workflows are running. This robust n8n workflow solves this challenge by automating the version check and the update process. It starts daily or upon n8n initialization, determines if a newer version is available, and, critically, checks for active workflow executions. The update is only performed if the system is idle, ensuring zero interruption to running automation tasks. All events—updates available, instance is current, or update initiated—are reliably communicated via Telegram, making this a truly 'set-it-and-forget-it' maintenance n8n solution. This specific n8n template provides critical DevOps functionality.

How it Works

This automation begins via two potential n8n trigger points: either on a daily schedule (using the Daily Trigger n8n node) or immediately upon n8n startup (using the n8n Startup Trigger n8n node).


  1. Version Retrieval: The workflow simultaneously uses an Execute Command n8n node to run n8n -v to get the current installed version and an HTTP Request n8n node to query the GitHub API for the latest official release version.

  2. Version Comparison: The results are merged, and a Code n8n node executes custom logic. This logic strips prefixes (like 'v' or 'n8n@') and compares the two version strings, setting the updateAvailable flag to true if a discrepancy is found.

  3. Decision Point: An If n8n node checks the updateAvailable flag.

  4. No Update Path (False): If no update is necessary, a Telegram n8n node sends a notification confirming the current instance is running the latest version.

  5. Update Path (True): If an update is available, a Telegram n8n node notifies the user. The workflow then uses the dedicated n8n node to check for currently running workflow executions.

  6. Safety Check: A Function n8n node analyzes the execution list to determine if the runningCount is zero, setting the canUpdate flag.

  7. Safe Update Loop: A second If n8n node checks canUpdate. If false, the workflow enters a safety loop: it uses the Wait n8n node for one minute and retries the execution check. If true (it is safe to update), a final Telegram n8n node announces the update is commencing, followed by an Execute Command n8n node running the update script (sudo npm install -g n8n && sudo systemctl restart n8n). This robust n8n workflow structure ensures minimal operational risk.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and paste it into your n8n instance using the 'New' menu > 'Import from JSON'.

  2. Telegram Setup: Set up your Telegram Bot credentials. You will need a Chat ID and a Bot Token. Assign these credentials to the three Telegram n8n nodes (Notify Update Available, Notify Latest Version, and Notify Update Start).

  3. n8n Credentials: Ensure your n8n instance has a valid set of n8n API credentials configured. These are required for the 'Get Executions' n8n node to check the status of other workflows.

  4. Command Validation (Crucial): The Execute Update n8n node is configured for a Linux/NPM self-hosted environment (sudo npm install -g n8n && sudo systemctl restart n8n). If you are using Docker, Kubernetes, or another environment, you must replace this command with the appropriate update method (e.g., pulling a new Docker image).

  5. Activation: Once configured, activate the n8n workflow.

Node Details

This n8n workflow leverages several specialized n8n nodes:

Daily Trigger & n8n Startup Trigger: These act as the starting n8n trigger points, initiating the maintenance check daily and upon initialization.
Execute Command (Get Current Version): Runs the system command n8n -v. It is fundamental to retrieving the installed version needed for comparison in this n8n template.
HTTP Request (Get Latest Version): Queries https://api.github.com/repos/n8n-io/n8n/releases/latest to retrieve the latest version tag from the official n8n repository.
Code (Compare Versions): A core n8n node for logic. It cleans the version strings and compares them, outputting a clear boolean flag updateAvailable.
n8n Node (Get Executions): A self-referential n8n node that communicates with the local n8n API to pull a list of all current workflow executions. This is vital for the safety check.
Function (Check Running Workflows): Analyzes the list provided by the n8n node to count executions with a status of 'running', generating the canUpdate flag.
Execute Command (Execute Update): Contains the update and restart command. Key configuration is the command itself: sudo npm install -g n8n && sudo systemctl restart n8n (must be customized for non-NPM installations).
Wait: Used in the 'unsafe' path of the IF node to pause for 1 minute before retrying the running workflow check, creating a resilient wait-and-retry mechanism.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by
David Hernández Luján
David Hernández Luján

Featured*