{ "name": "Webhook: create a Social Poster draft from a shop or form request, optionally scheduled", "nodes": [ { "id": "d962dd4e-ace7-5e0a-baaf-c5b0a71f3d25", "name": "Overview", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -320, -60 ], "parameters": { "content": "### How it works\nThe workflow accepts an HTTP POST from a shop, form or other app. If there is no text in `caption`, `text` or `message`, it answers with status 400. Otherwise it takes the link, title and public media URLs, saves the post with “Create the draft” and answers with the draft id.\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. If the request sends `\"schedule\": false`, it stays a draft even then.\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`.\nEnter your account reference (`acc_…`) in “Settings and fields”. Save the workflow, copy the production webhook URL and send `{\"caption\":\"Test post\"}`. If n8n is reachable from the internet, protect the webhook, for example with Header Auth. Never put the API key in the request.\n\n### Customization\nYou can rename the fields to match your form.", "height": 820, "width": 680, "color": 1 } }, { "id": "69584216-4f27-5d9f-ba94-f9166ee6eda6", "name": "Receive the request", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 460, 60 ], "parameters": { "content": "## Webhook and checks\nOnly requests with a caption continue. Requests without text receive status 400.", "height": 240, "width": 520, "color": 7 } }, { "id": "2bde1094-aa59-56dd-9ad3-2a300360faac", "name": "Map the fields", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1020, 60 ], "parameters": { "content": "## Account and content\nAccount reference, `mode` (default `draft`) and `minutesFromNow` live here. The caption comes from the request.", "height": 240, "width": 480, "color": 7 } }, { "id": "05b245ce-2093-5951-804f-7d108bbce0d2", "name": "Draft or schedule", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1560, 60 ], "parameters": { "content": "## Draft, optionally scheduled\nEvery request becomes a draft. Only with `mode` = `schedule` and no `schedule` false does “Schedule the draft” schedule it. The answer contains the draft id.", "height": 240, "width": 820, "color": 7 } }, { "id": "c83dc518-e393-5b26-8c9c-ca63006b67a4", "name": "Protect the webhook", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 460, 800 ], "parameters": { "content": "If n8n is reachable from the internet, add authentication on the Webhook node. Never send the Social Poster key in the request.", "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-post", "responseMode": "responseNode", "options": {} }, "webhookId": "cc5c7e09-eead-458c-8c14-25b0bfd9c5ef" }, { "id": "d5addfb8-5115-4e7c-94bc-b524d2274a7c", "name": "Caption present?", "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": "Respond with invalid request", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.1, "position": [ 1080, 640 ], "parameters": { "respondWith": "json", "responseBody": "={{ { ok: false, error: \"A post text is missing. Send caption, text or message.\" } }}", "options": { "responseCode": 400 } } }, { "id": "7aaebf0e-e09a-4b11-a4c0-95faf040205d", "name": "Settings and fields", "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_YOUR_ACCOUNT_REF" }, { "id": "ad1e4277-449a-5be6-808a-949d9db52e5e", "name": "mode", "type": "string", "value": "draft" }, { "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": "316a530b-2b66-5a7f-9bea-6b439258eeeb", "name": "Create the draft", "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": "46f644eb-9c37-5e32-a494-dff2774a72fc", "name": "Should it be scheduled?", "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": "7515db33-5b37-5176-8b3b-fd05c669590c", "operator": { "type": "string", "operation": "equals" }, "leftValue": "={{ String($('Settings and fields').item.json.mode || \"\").trim().toLowerCase() }}", "rightValue": "schedule" }, { "id": "e05d7c3d-eb0b-51d5-b26d-5a7859db7484", "operator": { "type": "boolean", "operation": "true", "singleValue": true }, "leftValue": "={{ $('Settings and fields').item.json.requestAllowsSchedule }}", "rightValue": "" } ] } } }, { "id": "2e829d30-92f0-5b31-9ece-c49447ac5b30", "name": "Schedule the draft", "type": "n8n-nodes-social-poster.socialPoster", "typeVersion": 1, "position": [ 1920, 200 ], "parameters": { "resource": "post", "operation": "scheduleDraft", "workspace": "", "draftRef": "={{ $('Create the draft').item.json.draft.draft_ref }}", "scheduleMode": "minutes", "minutesFromNow": "={{ $('Settings and fields').item.json.minutesFromNow }}", "xContentReviewed": false }, "credentials": { "socialPosterApi": { "id": "YOUR_SOCIAL_POSTER_CREDENTIAL", "name": "Social Poster API" } } }, { "id": "d6fc0c1d-60ae-4eb1-b86e-0d734f7ccb96", "name": "Respond with success", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.1, "position": [ 2200, 320 ], "parameters": { "respondWith": "json", "responseBody": "={{ { ok: true, draft_ref: $('Create the draft').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": "Caption present?", "type": "main", "index": 0 } ] ] }, "Caption present?": { "main": [ [ { "node": "Settings and fields", "type": "main", "index": 0 } ], [ { "node": "Respond with invalid request", "type": "main", "index": 0 } ] ] }, "Settings and fields": { "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": "Respond with success", "type": "main", "index": 0 } ] ] }, "Schedule the draft": { "main": [ [ { "node": "Respond with success", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1", "availableInMCP": false }, "meta": { "templateCredsSetupCompleted": false }, "tags": [] }