{
  "name": "AI: draft a Social Poster post from a topic, optionally scheduled",
  "nodes": [
    {
      "id": "8f586f32-cb2a-5f19-8a6e-5b88b21711b0",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -300,
        -40
      ],
      "parameters": {
        "content": "### How it works\nYou enter a topic and optional notes in the form. The workflow loads your team’s brand and network context from Social Poster, and OpenAI writes only the caption. “Create the draft” saves it as an AI-generated draft, and “Validate the draft” checks it against the network rules.\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. Only a draft that “Validate the draft” reports as valid is scheduled.\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`.\nAlso create OpenAI credentials. In “Settings”, enter your account reference (`acc_…`). Open the form with “Test workflow” and submit a topic.\n\n### Customization\nYou can change the model, language or prompt on the OpenAI node, or start from a schedule instead of the form. AI text can contain mistakes: read every draft before you switch to `schedule`.",
        "height": 820,
        "width": 660,
        "color": 1
      }
    },
    {
      "id": "3eee0846-cc58-5524-80eb-bd639d8dd9d9",
      "name": "Collect the topic",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        80
      ],
      "parameters": {
        "content": "## Start from the form\nTopic and notes come from the form. “Settings” holds the account reference, `mode` (default `draft`) and `minutesFromNow`.",
        "height": 260,
        "width": 520,
        "color": 7
      }
    },
    {
      "id": "00d7bffb-7f8a-567e-ac92-4294f10b5f47",
      "name": "Write the text with AI",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1020,
        80
      ],
      "parameters": {
        "content": "## Context and text\nFirst the brand context comes from Social Poster, then OpenAI writes the caption.",
        "height": 260,
        "width": 520,
        "color": 7
      }
    },
    {
      "id": "17d78998-bc90-54b8-b951-0e2aac0106f9",
      "name": "Draft, optionally scheduled",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1620,
        80
      ],
      "parameters": {
        "content": "## Draft, optionally scheduled\nThe caption is saved as a draft and validated. Only with `mode` = `schedule` and a valid draft does “Schedule the draft” schedule it.",
        "height": 260,
        "width": 1100,
        "color": 7
      }
    },
    {
      "id": "a9350649-4468-492f-9b7b-a9ae3b3f3113",
      "name": "Enter a topic",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        520,
        400
      ],
      "parameters": {
        "formTitle": "Draft a post from a topic",
        "formDescription": "Writes a caption with AI and saves it in Social Poster as a draft.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Topic",
              "placeholder": "For example: spring offers in the farm shop",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Notes",
              "placeholder": "Tone, language, things to include or avoid"
            }
          ]
        },
        "options": {
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "Thanks. The draft is being created in Social Poster."
            }
          }
        }
      },
      "webhookId": "15d1fe68-5eca-4f6c-8119-07ea524417d7"
    },
    {
      "id": "95f58f08-2117-4f8a-9d27-cf1f5982c677",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        800,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "50d9fe37-9689-41c6-9713-34da4dfff09f",
              "name": "accountRef",
              "type": "string",
              "value": "acc_YOUR_ACCOUNT_REF"
            },
            {
              "id": "3471a7e2-c666-5fe5-8e9f-b03c4ead3788",
              "name": "mode",
              "type": "string",
              "value": "draft"
            },
            {
              "id": "bc22412a-ce12-52d1-8783-661ff107c376",
              "name": "minutesFromNow",
              "type": "number",
              "value": 15
            },
            {
              "id": "6e8e024f-d97e-4425-a8c9-bf92b505fec4",
              "name": "Topic",
              "type": "string",
              "value": "={{ $json.Topic }}"
            },
            {
              "id": "f8e4f7de-7fac-42b3-89a7-406a83a41602",
              "name": "Notes",
              "type": "string",
              "value": "={{ $json.Notes }}"
            }
          ]
        }
      }
    },
    {
      "id": "94753dfb-af1f-401e-85ec-537d71f01908",
      "name": "Get brand context",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        1080,
        400
      ],
      "parameters": {
        "resource": "workspace",
        "operation": "getAiContext",
        "workspace": ""
      }
    },
    {
      "id": "fc856472-4805-4a3f-9c97-4cfd5a84e889",
      "name": "Write the post text",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1360,
        400
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=You write a social media post for Social Poster. Return only the finished post text, with no quotation marks, no heading such as “Post:”, and no explanation.\n\nUse the following brand and network context from Social Poster where it is available:\n{{ JSON.stringify($json) }}\n\nTopic:\n{{ $('Settings').item.json.Topic }}\n\nAdditional notes from the person using this workflow:\n{{ $('Settings').item.json.Notes || 'No further notes.' }}\n\nRules:\n- Write in the language of the topic, typically German, in a clear, natural “Du” tone if the topic is German.\n- Keep the text short enough for common networks, usually under 1,800 characters.\n- Do not invent facts, offers or numbers that are not in the topic or the notes.\n- Do not add a list of hashtags unless the notes ask for them."
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "7f766289-33fe-4987-a4ac-350d617f02f6",
      "name": "Create the draft",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        1680,
        400
      ],
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "workspace": "",
        "account": "={{ $('Settings').item.json.accountRef }}",
        "caption": "={{ $json.message && $json.message.content ? $json.message.content : ($json.output || $json.text || \"\") }}",
        "additionalFields": {
          "aiGenerated": true
        }
      }
    },
    {
      "id": "625cf45d-0644-4a1a-8c42-c86d2be0f2e5",
      "name": "Validate the draft",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        1960,
        400
      ],
      "parameters": {
        "resource": "draft",
        "operation": "validate",
        "workspace": "",
        "draftRef": "={{ $('Create the draft').item.json.draft.draft_ref }}"
      }
    },
    {
      "id": "2d78303d-07ab-5a89-8d2e-7998129096d8",
      "name": "Should it be scheduled?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2240,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8bd62188-9130-59a8-9bae-27e0b207742b",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ String($('Settings').item.json.mode || \"\").trim().toLowerCase() }}",
              "rightValue": "schedule"
            },
            {
              "id": "278a6560-1a80-594a-82c5-2ddfec45b957",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.validation && $json.validation.ok === true }}",
              "rightValue": ""
            }
          ]
        }
      }
    },
    {
      "id": "cabb07aa-58e2-50de-9ab3-b34f241cc53b",
      "name": "Schedule the draft",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        2520,
        300
      ],
      "parameters": {
        "resource": "post",
        "operation": "scheduleDraft",
        "workspace": "",
        "draftRef": "={{ $('Create the draft').item.json.draft.draft_ref }}",
        "scheduleMode": "minutes",
        "minutesFromNow": "={{ $('Settings').item.json.minutesFromNow }}",
        "xContentReviewed": false
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Enter a topic": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Get brand context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get brand context": {
      "main": [
        [
          {
            "node": "Write the post text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the post text": {
      "main": [
        [
          {
            "node": "Create the draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create the draft": {
      "main": [
        [
          {
            "node": "Validate the draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate 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
          }
        ],
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
