{
  "name": "Google Sheets: create Social Poster drafts from ready rows, optionally scheduled",
  "nodes": [
    {
      "id": "7be40242-5e80-58ea-9b6e-32e05c4ffc17",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -320,
        -60
      ],
      "parameters": {
        "content": "### How it works\nA schedule reads your Google Sheet and takes only rows with status `ready` and a caption. For each row, “Create the draft” saves a draft in Social Poster. “Write the status” then writes `draft`, `scheduled` or `error` and the draft id back to the row. An error on one row does not stop the others.\n\n### Draft or scheduled\nThe default is `mode` = `draft`: the workflow only creates a draft and schedules or publishes nothing. The link to view it is in the output of “Create the draft” under `draft.app_draft_url`. To schedule posts, set `mode` to `schedule`. “Schedule the draft” then schedules it `minutesFromNow` minutes later (at least 5) and confirms it. If your team requires approval, it waits under “Waiting for you”. There is no immediate publishing.\n\n### Setup\nThis template uses the unverified community node `n8n-nodes-social-poster` (tested with version 0.1.1). It runs on self-hosted n8n only, not on n8n Cloud. Install it under Settings → Community Nodes → Install. Guide: https://docs.n8n.io/integrations/community-nodes/installation/\nCreate “Social Poster API” credentials. You get the key in Social Poster under the account menu → AI access → API key for n8n. The base URL is `https://app.social-poster.io` without `/mcp`.\nCreate Google Sheets credentials and a sheet with these headers in row 1: `Caption`, `Link`, `MediaURLs`, `Title`, `Status`, `DraftRef`, `ScheduledAt`. In “Settings”, enter the sheet ID, sheet name and account reference (`acc_…`). Set one test row to `ready` and run the workflow once.\n\n### Customization\nDo not set too many rows to `ready` at once: the key allows 10 draft changes and 3 publishing steps per minute.",
        "height": 820,
        "width": 680,
        "color": 1
      }
    },
    {
      "id": "adfc24f6-871e-52b0-ae1d-f6abfb4fefac",
      "name": "Schedule and settings",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        60
      ],
      "parameters": {
        "content": "## What you need to change\nInterval, sheet ID, sheet name, account reference, `mode` (default `draft`) and `minutesFromNow`.",
        "height": 260,
        "width": 520,
        "color": 7
      }
    },
    {
      "id": "14205488-cb40-560d-8d52-00cb8c4c790e",
      "name": "Find ready rows",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1040,
        60
      ],
      "parameters": {
        "content": "## Only status ready\nOnly rows with status `ready` and a caption continue.",
        "height": 260,
        "width": 520,
        "color": 7
      }
    },
    {
      "id": "c4c96276-90fc-512d-b8b4-33461ea7d460",
      "name": "Draft, schedule, write back",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1600,
        60
      ],
      "parameters": {
        "content": "## Draft, optionally scheduled\nEach row becomes a draft. With `mode` = `schedule`, “Schedule the draft” schedules it. “Write the status” sets `draft`, `scheduled` or `error`.",
        "height": 260,
        "width": 1060,
        "color": 7
      }
    },
    {
      "id": "258c918d-d0b5-5876-81e6-59d6690348e4",
      "name": "Note about X",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1880,
        640
      ],
      "parameters": {
        "content": "Review X (Twitter) posts yourself. Leave “X Content Reviewed” off in “Schedule the draft” until a person has checked the exact text and media.",
        "height": 150,
        "width": 520,
        "color": 3
      }
    },
    {
      "id": "4970ca50-4dcf-486a-943c-d2a2dc330254",
      "name": "Every 15 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        520,
        400
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      }
    },
    {
      "id": "45cf6481-6d6b-4e21-8bc7-5d1101b4c3ed",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        800,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "35eb24ee-3945-45ee-a220-f4181cd9973c",
              "name": "sheetId",
              "type": "string",
              "value": "YOUR_GOOGLE_SHEET_ID"
            },
            {
              "id": "d97dab2b-8b3c-4ec2-a987-47928dd5a633",
              "name": "sheetName",
              "type": "string",
              "value": "Posts"
            },
            {
              "id": "caa1246b-33bb-47a1-b2af-0b10d45a9800",
              "name": "accountRef",
              "type": "string",
              "value": "acc_YOUR_ACCOUNT_REF"
            },
            {
              "id": "87f1cae2-01cf-591d-89dd-dffeab930844",
              "name": "mode",
              "type": "string",
              "value": "draft"
            },
            {
              "id": "f245d5d3-e407-4ded-97c6-73d6c51b38a4",
              "name": "minutesFromNow",
              "type": "number",
              "value": 15
            }
          ]
        }
      }
    },
    {
      "id": "168b1567-7637-4f4b-abe3-c4525c836241",
      "name": "Read ready rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1080,
        400
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').item.json.sheetId }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').item.json.sheetName }}"
        },
        "options": {}
      }
    },
    {
      "id": "db4b6a91-257a-442d-82df-93eb968c5377",
      "name": "Only status ready",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        1360,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f352bf1d-6062-4bd6-b9d3-b150550e2fed",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Status }}",
              "rightValue": "ready"
            },
            {
              "id": "802cccb0-0001-433a-a34a-8908952bcff9",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Caption }}",
              "rightValue": ""
            }
          ]
        }
      }
    },
    {
      "id": "051e2f81-0849-5ce3-8bd8-1ac3756f3602",
      "name": "Create the draft",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        1640,
        400
      ],
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "workspace": "",
        "account": "={{ $('Settings').item.json.accountRef }}",
        "caption": "={{ $json.Caption }}",
        "additionalFields": {
          "link": "={{ $json.Link }}",
          "mediaUrls": "={{ $json.MediaURLs }}",
          "title": "={{ $json.Title }}"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "9567547a-a588-5cc0-9f06-75655ccc6524",
      "name": "Should it be scheduled?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1920,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cbe9f00a-6490-5fb7-b99d-41dbeebfbd68",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ String($('Settings').item.json.mode || \"\").trim().toLowerCase() }}",
              "rightValue": "schedule"
            },
            {
              "id": "740ee29b-7aee-59a6-a02c-df4c9690c885",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.draft && $json.draft.draft_ref ? $json.draft.draft_ref : \"\" }}",
              "rightValue": ""
            }
          ]
        }
      }
    },
    {
      "id": "eb277e2b-1f3a-5300-89f7-9899aaf7bd13",
      "name": "Schedule the draft",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        2200,
        280
      ],
      "parameters": {
        "resource": "post",
        "operation": "scheduleDraft",
        "workspace": "",
        "draftRef": "={{ $('Create the draft').item.json.draft.draft_ref }}",
        "scheduleMode": "minutes",
        "minutesFromNow": "={{ $('Settings').item.json.minutesFromNow }}",
        "xContentReviewed": false
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "4ea5642d-ac7c-5fc1-ba5d-3db47a1d83ad",
      "name": "Write the status",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2480,
        400
      ],
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').item.json.sheetId }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').item.json.sheetName }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "value": {
            "row_number": "={{ $('Only status ready').item.json.row_number }}",
            "Status": "={{ $json.error ? \"error\" : ($json.scheduled_at_utc ? \"scheduled\" : \"draft\") }}",
            "DraftRef": "={{ $('Create the draft').item.json.draft && $('Create the draft').item.json.draft.draft_ref ? $('Create the draft').item.json.draft.draft_ref + ($json.error ? \" – \" + $json.error : \"\") : ($json.error || \"error\") }}",
            "ScheduledAt": "={{ $json.scheduled_at_utc || \"\" }}"
          },
          "schema": [
            {
              "id": "Caption",
              "displayName": "Caption",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Link",
              "displayName": "Link",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "MediaURLs",
              "displayName": "MediaURLs",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Title",
              "displayName": "Title",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "DraftRef",
              "displayName": "DraftRef",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "ScheduledAt",
              "displayName": "ScheduledAt",
              "type": "string",
              "display": true,
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "type": "string",
              "display": true,
              "required": false,
              "readOnly": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Every 15 minutes": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Read ready rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read ready rows": {
      "main": [
        [
          {
            "node": "Only status ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only status ready": {
      "main": [
        [
          {
            "node": "Create the draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create the draft": {
      "main": [
        [
          {
            "node": "Should it be scheduled?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Should it be scheduled?": {
      "main": [
        [
          {
            "node": "Schedule the draft",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write the status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule the draft": {
      "main": [
        [
          {
            "node": "Write the status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false,
    "timezone": "Europe/Berlin"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
