{
  "id": "steinheim-w03-reconciliation",
  "name": "W03 \u2014 Reconciliation sweep",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      },
      "id": "w03-cron",
      "name": "Hourly",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -220,
        0
      ]
    },
    {
      "parameters": {
        "url": "__APP_URL__/api/public/automation/approved?state=unknown&limit=25",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-automation-timestamp",
              "value": "={{ Date.now() }}"
            },
            {
              "name": "x-automation-nonce",
              "value": "={{ $execution.id }}-{{ Date.now() }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "fullResponse": true
            }
          }
        }
      },
      "id": "w03-list",
      "name": "List UNKNOWN posts",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $json.body.count }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "w03-any",
      "name": "Anything to reconcile?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        230,
        0
      ]
    },
    {
      "parameters": {
        "chatId": "__TELEGRAM_CHAT_ID__",
        "text": "=\u26a0\ufe0f <b>{{ $json.body.count }} post(s) need reconciliation</b>\n\nEach one was sent to a platform that never confirmed. They will NOT be retried automatically.\n\n{{ $json.body.posts.map(p => '\u2022 ' + p.platform + ' \u2014 ' + p.id).join('\n') }}\n\nCheck the platform, then report back with outcome <code>published</code> (found) or <code>not_found</code> (safe to retry).",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "id": "w03-alert",
      "name": "Alert human",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        470,
        -80
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Hourly": {
      "main": [
        [
          {
            "node": "List UNKNOWN posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List UNKNOWN posts": {
      "main": [
        [
          {
            "node": "Anything to reconcile?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anything to reconcile?": {
      "main": [
        [
          {
            "node": "Alert human",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Africa/Cairo"
  }
}