{
  "name": "FB Content Upload (Latest)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        -700,
        0
      ],
      "id": "schedule-1",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "content": "Replace with your input source. Expected fields: caption, image_url, upload_date, upload_time, page_id, access_token.",
        "height": 170,
        "width": 520,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -440,
        -180
      ],
      "id": "note-1",
      "name": "Sticky Note - Input Rows"
    },
    {
      "parameters": {
        "jsCode": "const post = $json;\nconst uploadDate = post.upload_date || '2026-08-07';\nconst uploadTime = post.upload_time || '09:00:00';\nconst [h, m, s] = String(uploadTime).split(':').map(Number);\nconst normalized = [h, m, s].map(n => String(n || 0).padStart(2, '0')).join(':');\nconst scheduledDate = new Date(`${uploadDate}T${normalized}+07:00`);\nreturn [{ json: { ...post, scheduled_publish_time: Math.floor(scheduledDate.getTime() / 1000) } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -120,
        0
      ],
      "id": "code-1",
      "name": "Prepare Schedule"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v23.0/{{ $json.page_id }}/photos",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "message",
              "value": "={{ $json.caption }}"
            },
            {
              "name": "access_token",
              "value": "={{ $json.access_token || 'YOUR_FACEBOOK_PAGE_ACCESS_TOKEN' }}"
            },
            {
              "name": "url",
              "value": "={{ $json.image_url }}"
            },
            {
              "name": "published",
              "value": "false"
            },
            {
              "name": "scheduled_publish_time",
              "value": "={{ $json.scheduled_publish_time }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        160,
        0
      ],
      "id": "http-1",
      "name": "Schedule Facebook Photo Post"
    },
    {
      "parameters": {
        "content": "Replace with your save-history and status-update nodes.",
        "height": 150,
        "width": 420,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        -160
      ],
      "id": "note-2",
      "name": "Sticky Note - Save Result"
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Prepare Schedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Schedule": {
      "main": [
        [
          {
            "node": "Schedule Facebook Photo Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}