{
  "name": "Scheduled Tweet from Content Queue",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [{ "field": "hours", "hoursInterval": 6 }]
        }
      },
      "id": "stfq0001-0001-4000-8000-000000000001",
      "name": "Schedule Every 6 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "={{ $env.TWEET_QUEUE_SHEET_ID }}",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Queue",
          "mode": "name"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "condition": "eq",
              "keyValue": "pending"
            }
          ]
        },
        "options": { "returnFirstMatch": true }
      },
      "id": "stfq0001-0002-4000-8000-000000000002",
      "name": "Read Next Queued Tweet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [460, 300]
    },
    {
      "parameters": {
        "condition": {
          "string": [
            {
              "value1": "={{ $json.tweet_text }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "id": "stfq0001-0003-4000-8000-000000000003",
      "name": "Has Pending Tweet?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "text": "={{ $json.tweet_text }}",
        "additionalFields": {}
      },
      "id": "stfq0001-0004-4000-8000-000000000004",
      "name": "Post Tweet",
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 2,
      "position": [900, 220]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "={{ $env.TWEET_QUEUE_SHEET_ID }}",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Queue",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "status": "posted",
            "posted_at": "={{ $now.toISO() }}"
          }
        },
        "where": {
          "values": [
            {
              "lookupColumn": "row_id",
              "lookupValue": "={{ $('Read Next Queued Tweet').item.json.row_id }}"
            }
          ]
        },
        "options": {}
      },
      "id": "stfq0001-0005-4000-8000-000000000005",
      "name": "Mark Tweet as Posted",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [1120, 220]
    }
  ],
  "connections": {
    "Schedule Every 6 Hours": {
      "main": [[{ "node": "Read Next Queued Tweet", "type": "main", "index": 0 }]]
    },
    "Read Next Queued Tweet": {
      "main": [[{ "node": "Has Pending Tweet?", "type": "main", "index": 0 }]]
    },
    "Has Pending Tweet?": {
      "main": [
        [{ "node": "Post Tweet", "type": "main", "index": 0 }],
        []
      ]
    },
    "Post Tweet": {
      "main": [[{ "node": "Mark Tweet as Posted", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
