AutomationFlowsSlack & Telegram › Monitor Stale Tasks with MySQL & Telegram

Monitor Stale Tasks with MySQL & Telegram

Original n8n title: Ttl Monitor - Stale Task Watchdog

TTL Monitor - Stale Task Watchdog. Uses mySql, telegram. Scheduled trigger; 7 nodes.

Cron / scheduled trigger★★★★☆ complexity7 nodesMySQLTelegram
Slack & Telegram Trigger: Cron / scheduled Nodes: 7 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "wf-ttl-monitor",
  "name": "TTL Monitor - Stale Task Watchdog",
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [
    {
      "id": "4",
      "name": "monitoring"
    }
  ],
  "nodes": [
    {
      "id": "node-schedule-trigger",
      "name": "Schedule: Every 60 Seconds",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "seconds",
              "secondsInterval": 60
            }
          ]
        }
      }
    },
    {
      "id": "node-select-stale",
      "name": "MySQL: SELECT Stale Tasks",
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.4,
      "position": [
        480,
        300
      ],
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT * FROM stale_tasks;",
        "options": {}
      },
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "node-if-has-stale",
      "name": "IF: Has Stale Tasks?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        720,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition-count",
              "leftValue": "={{ $input.all().length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "node-loop-items",
      "name": "Loop Over Stale Tasks",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        960,
        200
      ],
      "parameters": {
        "batchSize": 1,
        "options": {}
      }
    },
    {
      "id": "node-update-blocked",
      "name": "MySQL: UPDATE Status Blocked",
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.4,
      "position": [
        1200,
        200
      ],
      "parameters": {
        "operation": "executeQuery",
        "query": "UPDATE tasks SET status = 'blocked', last_heartbeat = NOW() WHERE id = '{{ $json.id }}';",
        "options": {}
      },
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "node-telegram-alert",
      "name": "Telegram: Alert Stale Task",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1440,
        200
      ],
      "parameters": {
        "operation": "sendMessage",
        "chatId": "={{ $env.TELEGRAM_CHAT_ID }}",
        "text": "=ALERTA: Tarea estancada detectada\n\nTask ID: {{ $('Loop Over Stale Tasks').item.json.id }}\nAgente: {{ $('Loop Over Stale Tasks').item.json.agent_id }}\nEstado anterior: {{ $('Loop Over Stale Tasks').item.json.status }}\nCreada: {{ $('Loop Over Stale Tasks').item.json.created_at }}\nUltimo heartbeat: {{ $('Loop Over Stale Tasks').item.json.last_heartbeat }}\n\nLa tarea ha sido marcada como BLOCKED automaticamente.",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "node-no-stale",
      "name": "No Stale Tasks",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        960,
        420
      ]
    }
  ],
  "connections": {
    "Schedule: Every 60 Seconds": {
      "main": [
        [
          {
            "node": "MySQL: SELECT Stale Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MySQL: SELECT Stale Tasks": {
      "main": [
        [
          {
            "node": "IF: Has Stale Tasks?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: Has Stale Tasks?": {
      "main": [
        [
          {
            "node": "Loop Over Stale Tasks",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Stale Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Stale Tasks": {
      "main": [
        [
          {
            "node": "MySQL: UPDATE Status Blocked",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "MySQL: UPDATE Status Blocked",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MySQL: UPDATE Status Blocked": {
      "main": [
        [
          {
            "node": "Telegram: Alert Stale Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram: Alert Stale Task": {
      "main": [
        [
          {
            "node": "Loop Over Stale Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

TTL Monitor - Stale Task Watchdog. Uses mySql, telegram. Scheduled trigger; 7 nodes.

Source: https://github.com/ceshorma/IA-Orchestator/blob/1281ff80a7fece1544815e63620ffef0d4c4e88a/workflows/ttl-monitor.json — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

Solo founders and spreadsheet gremlins who track everything in Notion and want crisp Telegram pings without opening a single page.

Telegram, Notion
Slack & Telegram

A robust workflow to back up and synchronize your n8n workflows to a GitHub repository, with intelligent change detection and support for file renames.

GitHub, n8n, Telegram +1
Slack & Telegram

With the increasing popularity of stablecoins like USDC, its becoming easier to pay for everyday items with crypto thanks to debit cards from issuers like MetaMask. These solutions work by processing

Telegram, N8N Nodes 1Shot
Slack & Telegram

This workflow continuously monitors the TikTok Ads Library for new creatives from specific advertisers or keyword searches, scrapes them via Apify, logs them into Google Sheets, and sends concise noti

Google Sheets, Slack, Telegram +1
Slack & Telegram

GNCA AI News Pipeline. Uses rssFeedRead, httpRequest, telegram, errorTrigger. Scheduled trigger; 29 nodes.

RSS Feed Read, HTTP Request, Telegram +1