{
  "nodes": [
    {
      "id": "bf86c33a-dc2b-4eee-8ebd-72c94f318d71",
      "name": "Extract ID and URL",
      "type": "n8n-nodes-base.code",
      "position": [
        -800,
        100
      ],
      "parameters": {
        "jsCode": "const regex = /\\[(https:\\/\\/dashboard\\.uptimerobot\\.com\\/monitors\\/(\\d{9})\\?[^\\]]*)\\]/;\nconst statusMap = {\n  0: \"paused\",\n  1: \"not checked yet\",\n  2: \"up\",\n  8: \"seems down\",\n  9: \"down\"\n};\n\n// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.monitorUrl = $input.first().json.text.match(regex)?.[1];\n  item.json.monitorId = $input.first().json.text.match(regex)?.[2];\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "7ec4d205-fc84-480b-9442-d018840ebdab",
      "name": "Extract Status Details",
      "type": "n8n-nodes-base.code",
      "onError": "continueErrorOutput",
      "position": [
        -20,
        100
      ],
      "parameters": {
        "jsCode": "const statusMap = {\n  0: \"paused\",\n  1: \"not checked yet\",\n  2: \"up\",\n  8: \"seems down\",\n  9: \"down\"\n};\n\n// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\nitem.json.monitorStatus = statusMap[$input.first().json.status] || \"unknown\"; // Fallback to \"unknown\" if invalid\nitem.json.lastStatusChange = $input.first().json.logs[0].datetime || \"unknown\";\nitem.json.lastStatusChangeReason = $input.first().json.logs[0].reason.detail || \"unknown\";\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "99fe7d7a-7482-4210-a649-cbdf8d16148d",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1420,
        240
      ],
      "parameters": {
        "text": "=\ud83d\udea6 Monitor Status Update\n\n\ud83d\udcdb Monitor: {{ $('Extract Status Details').item.json.friendly_name }}\n\n\ud83d\udd04 Status: {{ \n  $('Extract Status Details').item.json.monitorStatus === 'up' \n    ? '\u2705 UP' \n    : $('Extract Status Details').item.json.monitorStatus === 'down' \n      ? '\ud83d\udd34 DOWN' \n      : $('Extract Status Details').item.json.monitorStatus === 'paused' \n        ? '\u23f8\ufe0f PAUSED' \n        : '\u26a0\ufe0f ' + $('Extract Status Details').item.json.monitorStatus\n}}\n\n\u23f0 Last Changed: {{ new Date($('Extract Status Details').item.json.lastStatusChange * 1000).toLocaleString() }}\n\n\ud83d\udcdd Reason: `{{ $('Extract Status Details').item.json.lastStatusChangeReason || 'N/A' }}`\n\n\ud83d\udd17 Monitor: {{ \"https://dashboard.uptimerobot.com/monitors/\"+ $('Extract Status Details').item.json.id }}",
        "chatId": "your-chat-id-goes-here",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "81039eb1-d1f8-47d1-9c85-aa3af0cc5efd",
      "name": "Send a photo message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1420,
        -80
      ],
      "parameters": {
        "chatId": "your-chat-id-goes-here",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {
          "caption": "=\ud83d\udea6 Monitor Status Update\n\n\ud83d\udcdb Monitor: {{ $('Extract Status Details').item.json.friendly_name }}\n\n\ud83d\udd04 Status: {{ \n  $('Extract Status Details').item.json.monitorStatus === 'up' \n    ? '\u2705 UP' \n    : $('Extract Status Details').item.json.monitorStatus === 'down' \n      ? '\ud83d\udd34 DOWN' \n      : $('Extract Status Details').item.json.monitorStatus === 'paused' \n        ? '\u23f8\ufe0f PAUSED' \n        : '\u26a0\ufe0f ' + $('Extract Status Details').item.json.monitorStatus\n}}\n\n\u23f0 Last Changed: {{ new Date($('Extract Status Details').item.json.lastStatusChange * 1000).toLocaleString() }}\n\n\ud83d\udcdd Reason: `{{ $('Extract Status Details').item.json.lastStatusChangeReason || 'N/A' }}`\n\n\ud83d\udd17 Monitor: {{ \"https://dashboard.uptimerobot.com/monitors/\"+ $('Extract Status Details').item.json.id }}",
          "fileName": "screenshot.png"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6b9f61b7-4743-49c6-9297-e947571592c6",
      "name": "Screenshotmachine-secret",
      "type": "n8n-nodes-base.crypto",
      "position": [
        500,
        -60
      ],
      "parameters": {
        "value": "={{$('Extract Status Details').item.json.url + $('Conf').item.json.screenshotmachine_secret}}",
        "dataPropertyName": "hash"
      },
      "typeVersion": 1
    },
    {
      "id": "954f7be4-239b-417b-a99e-c3a6c6aefc9a",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        860,
        -60
      ],
      "parameters": {
        "url": "https://api.screenshotmachine.com",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $('Extract Status Details').item.json.url }}"
            },
            {
              "name": "dimension",
              "value": "={{ $('Conf').item.json.screenshotmachine_dimension }}"
            },
            {
              "name": "device",
              "value": "={{$('Conf').item.json.screenshotmachine_device}}"
            },
            {
              "name": "format",
              "value": "={{$('Conf').item.json.screenshotmachine_format}}"
            },
            {
              "name": "hash",
              "value": "={{ $json.hash }}"
            }
          ]
        }
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fb11bb7b-0413-483e-a3b5-309814c31978",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1700,
        100
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "sender": "user@example.com"
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 5
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "114961d1-786e-47bb-bd3c-71749be825aa",
      "name": "Get many monitors",
      "type": "n8n-nodes-base.uptimeRobot",
      "position": [
        -400,
        100
      ],
      "parameters": {
        "filters": {
          "logs": true,
          "mwindow": true,
          "monitors": "={{ $('Extract ID and URL').first().json.monitorId }}",
          "alert_contacts": true
        },
        "resource": "monitor"
      },
      "credentials": {
        "uptimeRobotApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "30b16a00-edbf-427e-a222-fa2f69ed47a5",
      "name": "Conf",
      "type": "n8n-nodes-base.set",
      "position": [
        -1220,
        100
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0439ef08-5f5d-4462-8d26-461553c19a8f",
              "name": "take_screenshot",
              "type": "boolean",
              "value": true
            },
            {
              "id": "9bb41b66-e203-44d7-9b47-a871820f9dfb",
              "name": "screenshotmachine_secret",
              "type": "string",
              "value": "your-secret-goes-here"
            },
            {
              "id": "82ffd79c-fd61-443e-94d4-1234a6279ca8",
              "name": "screenshotmachine_device",
              "type": "string",
              "value": "desktop"
            },
            {
              "id": "5817b498-bf20-43fc-9d02-db6683457f4f",
              "name": "screenshotmachine_dimension",
              "type": "string",
              "value": "1366xfull"
            },
            {
              "id": "8f15e188-2a9f-4b6e-a0d7-c36bfeac9c8c",
              "name": "screenshotmachine_format",
              "type": "string",
              "value": "png"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fece81e3-af89-4a01-816d-7c875613233c",
      "name": "If Screenshot Required",
      "type": "n8n-nodes-base.if",
      "position": [
        240,
        80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "49483f42-43d4-4a27-87a1-07fd2009b001",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{$('Conf').item.json.take_screenshot}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f53b5a16-a13f-444b-96d6-daf37cc5b242",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 880,
        "content": "# 1. Gmail Trigger\n\n## How it works:\nGmail Trigger runs on regular intervals and checks for new emails from sender: alert@uptimerobot.com\n\n## Configuration:\n\n1. Choose/Create **Credentials to connect with** for the Gmail account that will receive email notifications from UptimeRobot\n2. Configure **Poll times** (default is every 5 minutes)\n3. _(Optional)_ Adjust the sender filter if the email doesn't match the one you are receiving emails from."
      },
      "typeVersion": 1
    },
    {
      "id": "90db3579-0108-497c-8e78-e3678a32db33",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 840,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Extract ID and URL\n\n## How it works:\nThis node parses UptimeRobot alert emails to extract:\n- Monitor dashboard URL\n- Monitor ID (9-digit number)\n\n## Key Functions:\n1. Uses regex to find UptimeRobot monitor links in email text\n2. Extracts two key pieces of information:\n   - `monitorUrl`: Full dashboard URL\n   - `monitorId`: The 9-digit monitor ID\n\n## Technical Details:\n```javascript\nconst regex = /\\[(https:\\/\\/dashboard\\.uptimerobot\\.com\\/monitors\\/(\\d{9})\\?[^\\]]*)\\]/;\n// Matches URLs in the email body like: \n// [https://dashboard.uptimerobot.com/monitors/798811078?...]\n```\n## Troubleshooting:\n- If extraction fails, verify UptimeRobot email format hasn't changed\n- Check the regex pattern matches current alert emails"
      },
      "typeVersion": 1
    },
    {
      "id": "71904568-3452-4e5e-b77e-e4469c397bda",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 880,
        "content": "# 2. Workflow settings\n\n## How it works:\nCentral hub for all workflow settings. Controls screenshot behavior and parameters when enabled.\n\n## Configuration:\n\n1. **Basic Settings**:\n   - `take_screenshot`: Set `true`/`false` to enable/disable screenshots\n   \n2. **Screenshot Parameters** (if enabled):\n   - `screenshotmachine_secret`: Your secret phrase from ScreenshotMachine\n   - `screenshotmachine_device`: `desktop` or `mobile`\n   - `screenshotmachine_dimension`: Recommended `1366xfull` for full-page\n   - `screenshotmachine_format`: `png` (recommended) or `jpg`\n\n## Pro Tip:\nTest different dimensions/devices to find the optimal screenshot configuration for your monitored websites."
      },
      "typeVersion": 1
    },
    {
      "id": "88cb2f0b-604a-401d-9119-2070b8e9056a",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 900,
        "content": "# 3. UptimeRobot Settings\n\n## How it works:\nFetches detailed monitor status using the extracted monitor ID from email alerts.\n\n## Configuration:\n1. **Credentials Setup**:\n   - Get API key from UptimeRobot dashboard\n   - Requires \"Monitor Read\" permissions\n   - [Follow n8n documentation](https://docs.n8n.io/integrations/builtin/credentials/uptimerobot/) for setup\n\n2. **Email Integration**:\n   - Ensure your UptimeRobot monitor is configured to send alerts to your Gmail\n   - Configure in UptimeRobot: \n     `Dashboard \u2192 Monitor \u2192 Alert Settings \u2192 Add Email Alert`\n\n\n## Pro Tip:\nTest API connection using UptimeRobot's API tester before configuring in n8n."
      },
      "typeVersion": 1
    },
    {
      "id": "2cbbd484-5320-463b-8fb1-baa1efcc335a",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 760,
        "content": "# 4. ScreenshotMachine (Optional)\n\n**Only needed if `take_screenshot=true` in Config**\n\n## Credential Setup:\n1. Create free account at [screenshotmachine.com](https://www.screenshotmachine.com/)\n2. Configure credentials as:\n   - **Type**: Generic Credential Type\n   - **Auth Type**: Query Auth\n   - **Name**: `key`\n   - **Value**: [Your Customer Key]\n\n## Plan Limits:\n\u2757 Free plan includes limited amount of screenshots/month. If you monitor a lot of websites or receive notifications often consider a paid plan."
      },
      "typeVersion": 1
    },
    {
      "id": "88324346-583c-4731-b0fa-ce242a575b96",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 1020,
        "content": "# 5. Telegram Setup\n\n## Essentials:\n1. Create bot via [@BotFather](https://t.me/BotFather)\n2. Get your Chat ID using [@getidsbot](https://t.me/getidsbot)\n3. Configure credentials:\n   - **Bot Token**: From @BotFather\n   - **Chat ID**: Your target channel/group\n\n## Notification Types:\n- Always sends text alerts\n- Includes screenshots when enabled in Config\n\n[Official n8n Guide](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.telegram/)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Conf": {
      "main": [
        [
          {
            "node": "Extract ID and URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Send a photo message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Conf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many monitors": {
      "main": [
        [
          {
            "node": "Extract Status Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract ID and URL": {
      "main": [
        [
          {
            "node": "Get many monitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Status Details": {
      "main": [
        [
          {
            "node": "If Screenshot Required",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Screenshot Required": {
      "main": [
        [
          {
            "node": "Screenshotmachine-secret",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Screenshotmachine-secret": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}