{
  "name": "Vorlux AI | Social Media Content Calendar",
  "nodes": [
    {
      "id": "04b72cbc-731b-4524-b9b1-2507b91efff7",
      "name": "Hourly Check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        220,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      }
    },
    {
      "id": "3b9a74f1-1772-41ff-96c5-4b3886ac46d1",
      "name": "Check Calendar",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/social/calendar?due=now",
        "options": {
          "timeout": 15000
        }
      },
      "notes": "Gets scheduled social posts due for publication"
    },
    {
      "id": "b3560158-70b2-451a-afc5-e361ee9c1547",
      "name": "Filter Due Posts",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const posts = $input.first().json.data || [];const now = Date.now();const due = posts.filter(p => new Date(p.scheduledAt).getTime() <= now && p.status === 'scheduled');return [{json: {posts: due, count: due.length}}];"
      }
    },
    {
      "id": "f45df871-5a28-4ef9-9455-52d2ca34df07",
      "name": "Has Posts?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        940,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.count > 0 }}",
              "rightValue": "true",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "22e13389-eba8-4361-a6e7-4ec284aec3d9",
      "name": "Publish Posts",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1180,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/social/publish-batch",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({posts: $json.posts}) }}",
        "options": {
          "timeout": 30000
        }
      },
      "notes": "Publishes all due posts to their target platforms"
    },
    {
      "id": "73677897-05ef-466e-9db4-49d7a5233219",
      "name": "Log Activity",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1180,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/activity",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"type\":\"social_calendar\",\"action\":\"published\",\"count\":{{ $json.count }}}",
        "options": {
          "timeout": 10000
        }
      }
    }
  ],
  "connections": {
    "Hourly Check": {
      "main": [
        [
          {
            "node": "Check Calendar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Calendar": {
      "main": [
        [
          {
            "node": "Filter Due Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Due Posts": {
      "main": [
        [
          {
            "node": "Has Posts?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Posts?": {
      "main": [
        [
          {
            "node": "Publish Posts",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log Activity",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}