{
  "name": "Webhook: Shop- oder Formularanfrage als Social-Poster-Entwurf, optional vorgeplant",
  "nodes": [
    {
      "id": "2eb15126-31e7-57f5-960c-0d6e18d36181",
      "name": "Übersicht",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -320,
        -60
      ],
      "parameters": {
        "content": "### So funktioniert's\nDer Workflow nimmt einen HTTP-POST von einem Shop, Formular oder einer anderen Anwendung an. Fehlt ein Text in `caption`, `text` oder `message`, antwortet er mit Status 400. Sonst übernimmt er Link, Titel und öffentlich erreichbare Medien-URLs, speichert den Beitrag mit „Entwurf anlegen“ als Entwurf und antwortet mit der Entwurf-Nummer.\n\n### Entwurf oder vorgeplant\nStandard ist `modus` = `entwurf`: Es entsteht nur ein Entwurf, nichts wird geplant oder veröffentlicht. Den Link zur Ansicht findest Du in der Ausgabe von „Entwurf anlegen“ unter `draft.app_draft_url`. Für vorgeplante Beiträge setzt Du `modus` auf `planen`. Dann plant „Entwurf planen“ den Entwurf `minutesFromNow` Minuten später (mindestens 5) und bestätigt ihn. Braucht Dein Team eine Freigabe, wartet er unter „Wartet auf Dich“. Eine Sofort-Veröffentlichung gibt es nicht. Schickt die Anfrage `\"schedule\": false`, bleibt es auch dann beim Entwurf.\n\n### Einrichtung\nInstalliere den Community-Node `n8n-nodes-social-poster` in selbst gehostetem n8n (nicht in n8n Cloud; der Node ist noch nicht verifiziert), getestet mit Version 0.1.1: Einstellungen → Community Nodes → Installieren. Anleitung: https://docs.n8n.io/integrations/community-nodes/installation/\nLege die Anmeldedaten „Social Poster API“ an. Den Schlüssel holst Du in Social Poster unter Konto-Menü → KI-Zugriffe → API-Schlüssel für n8n, die Basis-URL ist `https://app.social-poster.io` ohne `/mcp`.\nTrage in „Einstellungen und Felder“ die Konto-Referenz (`acc_…`) ein. Speichere den Workflow, kopiere die Produktions-URL des Webhooks und sende `{\"caption\":\"Testbeitrag\"}`. Ist n8n aus dem Internet erreichbar, schütze den Webhook, zum Beispiel mit Header Auth. Lege den API-Schlüssel nie in die Anfrage.\n\n### Anpassen\nDu kannst die Feldnamen an Dein Formular anpassen.",
        "height": 820,
        "width": 680,
        "color": 1
      }
    },
    {
      "id": "bfa9a741-6911-5098-a8ed-e9480009740c",
      "name": "Anfrage annehmen",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        60
      ],
      "parameters": {
        "content": "## Webhook und Prüfung\nNur Anfragen mit Text laufen weiter. Ohne Text antwortet der Workflow mit Status 400.",
        "height": 240,
        "width": 520,
        "color": 7
      }
    },
    {
      "id": "3275f6b8-4e54-51f4-b098-16689285a508",
      "name": "Felder zuordnen",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1020,
        60
      ],
      "parameters": {
        "content": "## Konto und Inhalt\nKonto-Referenz, `modus` (Standard `entwurf`) und `minutesFromNow` stehen hier. Der Text kommt aus der Anfrage.",
        "height": 240,
        "width": 480,
        "color": 7
      }
    },
    {
      "id": "18d2594f-3332-57ce-8d41-77103c119d6a",
      "name": "Entwurf oder Plan",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1560,
        60
      ],
      "parameters": {
        "content": "## Entwurf, optional planen\nJede Anfrage wird ein Entwurf. Nur bei `modus` = `planen` und ohne `schedule` falsch plant „Entwurf planen“ ihn. Die Antwort enthält die Entwurf-Nummer.",
        "height": 240,
        "width": 820,
        "color": 7
      }
    },
    {
      "id": "f59f3b3c-a16c-54ff-ad73-c4e1df232f90",
      "name": "Webhook schützen",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        800
      ],
      "parameters": {
        "content": "Wenn n8n aus dem Internet erreichbar ist, setze im Webhook eine Authentifizierung. Schicke niemals den Social-Poster-Schlüssel in der Anfrage mit.",
        "height": 150,
        "width": 560,
        "color": 3
      }
    },
    {
      "id": "ab1afc8c-8c94-4d03-a58f-e9dc8b7a33e1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        520,
        400
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "social-poster-beitrag",
        "responseMode": "responseNode",
        "options": {}
      },
      "webhookId": "cc5c7e09-eead-458c-8c14-25b0bfd9c5ef"
    },
    {
      "id": "d5addfb8-5115-4e7c-94bc-b524d2274a7c",
      "name": "Text vorhanden?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        800,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "3ce3d450-3f59-40bd-abbe-70f675d5f45b",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.caption || $json.caption }}",
              "rightValue": ""
            },
            {
              "id": "e023fd44-f4eb-4954-9e30-bec6e9ff9360",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.text || $json.text }}",
              "rightValue": ""
            },
            {
              "id": "4bf6f07c-17d9-4595-9d39-7c8290fdac19",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.message || $json.message }}",
              "rightValue": ""
            }
          ]
        }
      }
    },
    {
      "id": "fe05436e-07c7-480d-88d5-7a3b2752fc99",
      "name": "Ungültige Anfrage beantworten",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1080,
        640
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: false, error: \"Es fehlt ein Beitragstext. Sende caption, text oder message.\" } }}",
        "options": {
          "responseCode": 400
        }
      }
    },
    {
      "id": "7aaebf0e-e09a-4b11-a4c0-95faf040205d",
      "name": "Einstellungen und Felder",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1080,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b03f2215-39ff-42a9-8b22-c6d8e3adffce",
              "name": "accountRef",
              "type": "string",
              "value": "acc_DEINE_KONTO_REFERENZ"
            },
            {
              "id": "52f8f1c2-b552-5d42-957b-ac25bc55d6b5",
              "name": "modus",
              "type": "string",
              "value": "entwurf"
            },
            {
              "id": "9816534a-13e2-4484-9e9f-e932abd4a41b",
              "name": "minutesFromNow",
              "type": "number",
              "value": 15
            },
            {
              "id": "d30cdbc3-9f39-4a43-bb38-f0f39d5c37c5",
              "name": "caption",
              "type": "string",
              "value": "={{ $json.body.caption || $json.caption || $json.body.text || $json.text || $json.body.message || $json.message }}"
            },
            {
              "id": "376be6f3-5427-48e5-a49f-0e2f3398ddf4",
              "name": "link",
              "type": "string",
              "value": "={{ $json.body.link || $json.link || $json.body.url || $json.url || \"\" }}"
            },
            {
              "id": "c33d641f-94bf-4c63-a571-03282defd194",
              "name": "mediaUrls",
              "type": "string",
              "value": "={{ $json.body.media_urls || $json.body.mediaUrls || $json.media_urls || $json.mediaUrls || $json.body.image || $json.image || \"\" }}"
            },
            {
              "id": "d97b19c2-b075-4d2a-a7a1-b4981b8aaafe",
              "name": "title",
              "type": "string",
              "value": "={{ $json.body.title || $json.title || \"\" }}"
            },
            {
              "id": "f04b28a6-44aa-4844-b1b9-5ad5b97ec770",
              "name": "requestAllowsSchedule",
              "type": "boolean",
              "value": "={{ ![\"false\", false, \"0\", 0].includes(($json.body && $json.body.schedule !== undefined) ? $json.body.schedule : ($json.schedule === undefined ? true : $json.schedule)) }}"
            }
          ]
        }
      }
    },
    {
      "id": "70c61338-eb8c-5bf1-b353-a39f13c50169",
      "name": "Entwurf anlegen",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        1360,
        320
      ],
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "workspace": "",
        "account": "={{ $json.accountRef }}",
        "caption": "={{ $json.caption }}",
        "additionalFields": {
          "link": "={{ $json.link }}",
          "mediaUrls": "={{ $json.mediaUrls }}",
          "title": "={{ $json.title }}"
        }
      },
      "credentials": {
        "socialPosterApi": {
          "id": "YOUR_SOCIAL_POSTER_CREDENTIAL",
          "name": "Social Poster API"
        }
      }
    },
    {
      "id": "1d719a9c-3228-50a5-a1a5-672476373007",
      "name": "Soll geplant werden?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1640,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e3d8abfa-9599-5a09-9d54-60d9bcf60f6e",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ String($('Einstellungen und Felder').item.json.modus || \"\").trim().toLowerCase() }}",
              "rightValue": "planen"
            },
            {
              "id": "9e49ca07-6c29-5411-ae77-5140eeebe070",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('Einstellungen und Felder').item.json.requestAllowsSchedule }}",
              "rightValue": ""
            }
          ]
        }
      }
    },
    {
      "id": "341b7c57-6a7f-5d93-87e9-5b48dcb8f2bc",
      "name": "Entwurf planen",
      "type": "n8n-nodes-social-poster.socialPoster",
      "typeVersion": 1,
      "position": [
        1920,
        200
      ],
      "parameters": {
        "resource": "post",
        "operation": "scheduleDraft",
        "workspace": "",
        "draftRef": "={{ $('Entwurf anlegen').item.json.draft.draft_ref }}",
        "scheduleMode": "minutes",
        "minutesFromNow": "={{ $('Einstellungen und Felder').item.json.minutesFromNow }}",
        "xContentReviewed": false
      },
      "credentials": {
        "socialPosterApi": {
          "id": "YOUR_SOCIAL_POSTER_CREDENTIAL",
          "name": "Social Poster API"
        }
      }
    },
    {
      "id": "d6fc0c1d-60ae-4eb1-b86e-0d734f7ccb96",
      "name": "Erfolg beantworten",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2200,
        320
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: true, draft_ref: $('Entwurf anlegen').item.json.draft.draft_ref, status_class: $json.status_class || ($json.draft && $json.draft.status_class) || \"draft\", scheduled_at_utc: $json.scheduled_at_utc || null, approval_class: $json.approval_class || null } }}",
        "options": {
          "responseCode": 200
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Text vorhanden?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text vorhanden?": {
      "main": [
        [
          {
            "node": "Einstellungen und Felder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ungültige Anfrage beantworten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Einstellungen und Felder": {
      "main": [
        [
          {
            "node": "Entwurf anlegen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Entwurf anlegen": {
      "main": [
        [
          {
            "node": "Soll geplant werden?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Soll geplant werden?": {
      "main": [
        [
          {
            "node": "Entwurf planen",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Erfolg beantworten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Entwurf planen": {
      "main": [
        [
          {
            "node": "Erfolg beantworten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
