{
  "name": "گالری ۱: پایش وب‌سایت با هشدار تلگرام",
  "nodes": [
    {
      "parameters": {
        "content": "## پایش وب‌سایت\n۱) هر ۵ دقیقه\n۲) درخواست به هر سایت (timeout، بدون توقف روی خطا)\n۳) سالم/خراب و مقایسه با وضعیت قبلی\n۴) فقط تغییر وضعیت ← هشدار\n\n⚠️ نمونه آموزشی loOkiYar؛ غیرفعال. گره‌های بنفش (سنجاق‌دار) داده نمایشی ساختگی دارند و در اجرای دستی به سرویس واقعی وصل نمی‌شوند.",
        "height": 266,
        "width": 460,
        "color": 4
      },
      "id": "02650e4d-4aa7-5b72-979a-e151864ca9a0",
      "name": "یادداشت 1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -316
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      },
      "id": "b106eb26-9280-5c38-9073-3b1ca03f6cd9",
      "name": "هر ۵ دقیقه",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        100
      ]
    },
    {
      "parameters": {
        "jsCode": "// Replace with your own sites. The demo addresses are the local Barg Sabz mock API.\nreturn [\n  { json: { name: 'site-home', url: 'http://127.0.0.1:8787/health' } },\n  { json: { name: 'site-down', url: 'http://127.0.0.1:9/' } },            // nothing listens here: connection refused\n  { json: { name: 'site-api', url: 'http://127.0.0.1:8787/orders/BS-1002' } },  // answers 401 without a token\n];"
      },
      "id": "ef24f122-0421-591a-a593-5d33dddf486a",
      "name": "فهرست سایت‌ها",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        100
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true
            }
          },
          "timeout": 4000
        }
      },
      "id": "8c1ed6f7-33b6-55ed-aa14-3e130da15daa",
      "name": "بررسی سایت",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        100
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "// Static data is saved only in production (published) runs; manual runs start from \"up\".\nconst state = $getWorkflowStaticData('global');\nstate.sites = state.sites || {};\nconst sites = $('فهرست سایت‌ها').all();\nreturn $input.all().map((item, i) => {\n  const site = sites[i].json;\n  const r = item.json;\n  const code = r.statusCode ?? null;\n  const ok = !r.error && code >= 200 && code < 400;\n  const now = ok ? 'up' : 'down';\n  const prev = state.sites[site.name] ?? 'up';\n  state.sites[site.name] = now;\n  return { json: { name: site.name, url: site.url, status: now, previous: prev, changed: prev !== now,\n                   http_status: code, error: r.error ? String(r.error.message || r.error).slice(0, 120) : null,\n                   checked_at: new Date().toISOString() } };\n});"
      },
      "id": "85241743-2e0f-53e4-b145-76521bfee335",
      "name": "سالم یا خراب؟ (مقایسه با قبل)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        100
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3f34b316-9aff-5ed8-8826-1056fb28b7ee",
              "leftValue": "={{ $json.changed }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "758f9690-d85a-5817-8149-d71fcd8d8fbd",
      "name": "فقط تغییر وضعیت",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        880,
        100
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $vars.TELEGRAM_CHAT_ID || 'REPLACE_WITH_CHAT_ID' }}",
        "text": "={{ $json.status === 'down' ? '🔴' : '🟢' }} {{ $json.name }} {{ $json.status }}\n{{ $json.url }}\nHTTP: {{ $json.http_status ?? '-' }} {{ $json.error ?? '' }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "f31ffa35-13c3-5ec7-80cb-a1e438a5d2c0",
      "name": "هشدار تلگرام",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1100,
        100
      ],
      "credentials": {
        "telegramApi": {
          "id": "536244d78d565cab",
          "name": "Telegram bot"
        }
      }
    }
  ],
  "connections": {
    "هر ۵ دقیقه": {
      "main": [
        [
          {
            "node": "فهرست سایت‌ها",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "فهرست سایت‌ها": {
      "main": [
        [
          {
            "node": "بررسی سایت",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "بررسی سایت": {
      "main": [
        [
          {
            "node": "سالم یا خراب؟ (مقایسه با قبل)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "سالم یا خراب؟ (مقایسه با قبل)": {
      "main": [
        [
          {
            "node": "فقط تغییر وضعیت",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "فقط تغییر وضعیت": {
      "main": [
        [
          {
            "node": "هشدار تلگرام",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "id": "LkyGal01SiteMon",
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "lookiyar-academy-demo"
  },
  "tags": [
    {
      "name": "loOkiYar Academy"
    },
    {
      "name": "gallery"
    }
  ],
  "pinData": {
    "هشدار تلگرام": [
      {
        "json": {
          "ok": true,
          "result": {
            "message_id": 501,
            "text": "🔴 site-slow down"
          },
          "_demo": "داده نمایشی ساختگی"
        }
      },
      {
        "json": {
          "ok": true,
          "result": {
            "message_id": 502,
            "text": "🔴 site-api down"
          },
          "_demo": "داده نمایشی ساختگی"
        }
      }
    ]
  }
}