{
  "name": "06 - Anniversary (یادبود تولد و وفات)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 12,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "a6000000-0000-4000-8000-000000000001",
      "name": "Schedule 12:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -280,
        0
      ],
      "notes": "هر روز ظهر بررسی می‌کند آیا امروز سالگرد تولد/وفات کسی است."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "api_base",
              "value": "https://YOUR-PROJECT.pages.dev",
              "type": "string"
            },
            {
              "id": "f2",
              "name": "api_key",
              "value": "PASTE_YOUR_API_KEY",
              "type": "string"
            },
            {
              "id": "f3",
              "name": "bot_token",
              "value": "PASTE_YOUR_BOT_TOKEN",
              "type": "string"
            },
            {
              "id": "f4",
              "name": "chat_id",
              "value": "@your_channel",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000002",
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -60,
        0
      ],
      "notes": "فقط این نود را پر کنید."
    },
    {
      "parameters": {
        "url": "={{ $json.api_base }}/api/content/anniversary",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $('Config').item.json.api_key }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000003",
      "name": "Get Anniversary",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        160,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.has }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000004",
      "name": "Anniversary Today?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        380,
        0
      ],
      "notes": "اگر امروز سالگردی نباشد، هیچ پستی ارسال نمی‌شود (شاخهٔ false خالی است)."
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c2",
              "leftValue": "={{ $json.has_audio }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000005",
      "name": "Has Audio?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        600,
        -80
      ],
      "notes": "اگر آهنگی از خودِ آن هنرمند در آرشیو باشد، یادبود با صدا می‌رود؛ وگرنه فقط متن+شعر."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $('Config').item.json.bot_token }}/sendAudio",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ chat_id: $('Config').item.json.chat_id, audio: $json.file_id || $json.audio_url, title: $json.name, caption: $json.caption, parse_mode: 'HTML' }) }}",
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000006",
      "name": "Send Memorial Audio",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        820,
        -180
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $('Config').item.json.bot_token }}/sendMessage",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ chat_id: $('Config').item.json.chat_id, text: $json.text, parse_mode: 'HTML', disable_web_page_preview: true }) }}",
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000007",
      "name": "Send Memorial Text",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        820,
        20
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $('Config').item.json.bot_token }}/pinChatMessage",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ chat_id: $('Config').item.json.chat_id, message_id: $json.result.message_id, disable_notification: true }) }}",
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000008",
      "name": "Pin Memorial",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1040,
        -80
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Config').item.json.api_base }}/api/log",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $('Config').item.json.api_key }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ kind: 'anniversary', ref_id: $('Get Anniversary').item.json.anniversary_id, poem_id: $('Get Anniversary').item.json.poem_id, song_id: $('Get Anniversary').item.json.song_id, chat_id: $('Config').item.json.chat_id, caption: $('Get Anniversary').item.json.text }) }}",
        "options": {}
      },
      "id": "a6000000-0000-4000-8000-000000000009",
      "name": "Log Memorial",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1260,
        -80
      ],
      "notes": "ثبت پست + علامت‌گذاری شعر و آهنگ به عنوان استفاده‌شده (چرخش عادلانه)."
    }
  ],
  "connections": {
    "Schedule 12:00": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Get Anniversary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Anniversary": {
      "main": [
        [
          {
            "node": "Anniversary Today?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anniversary Today?": {
      "main": [
        [
          {
            "node": "Has Audio?",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Has Audio?": {
      "main": [
        [
          {
            "node": "Send Memorial Audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Memorial Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Memorial Audio": {
      "main": [
        [
          {
            "node": "Pin Memorial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Memorial Text": {
      "main": [
        [
          {
            "node": "Pin Memorial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pin Memorial": {
      "main": [
        [
          {
            "node": "Log Memorial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Tehran",
    "saveExecutionProgress": true
  },
  "pinData": {},
  "tags": []
}