{ "name": "自動出 Post · 多平台(IG+FB+Threads)", "nodes": [ { "parameters": { "rule": { "interval": [ { "field": "hours", "hoursInterval": 4 } ] } }, "id": "6bddb663-bfde-409f-81af-4a2758415bba", "name": "排程觸發(每 4 小時)", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.3, "position": [ -160, 208 ] }, { "parameters": { "resource": "databasePage", "operation": "getAll", "databaseId": { "__rl": true, "value": "YOUR_NOTION_DATABASE_ID", "mode": "id", "cachedResultName": "Content Ideas" }, "returnAll": true, "simple": false, "filterType": "json", "options": {}, "filterJson": "={\"property\":\"Status\",\"select\":{\"equals\":\"準備發佈\"}}" }, "id": "c6c8ab0e-1bd9-4fa4-beec-363ece70e6fa", "name": "讀取 Notion 貼文", "type": "n8n-nodes-base.notion", "typeVersion": 2.2, "position": [ 160, 208 ], "credentials": { "notionApi": { "name": "KEA" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "a1", "name": "pageId", "type": "string", "value": "={{ $json.id }}" }, { "id": "a2", "name": "contentIG", "type": "string", "value": "={{ ($json.properties['Draft_IG'].rich_text || []).map(t => t.plain_text).join('') }}" }, { "id": "a3", "name": "contentFB", "type": "string", "value": "={{ ($json.properties['Draft_FB'].rich_text || []).map(t => t.plain_text).join('') }}" }, { "id": "a4", "name": "contentThreads", "type": "string", "value": "={{ ($json.properties['Draft_Threads'].rich_text || []).map(t => t.plain_text).join('') }}" }, { "id": "a5", "name": "images", "type": "array", "value": "={{ ($json.properties['Card_Carousel'].files || []).map(f => (f.external && f.external.url) || (f.file && f.file.url)).filter(Boolean) }}" } ] }, "options": {} }, "id": "07610eb0-1cac-4f7a-b46a-164a01a254a6", "name": "整理欄位", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 320, 208 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [ { "id": "e79b1190-1cad-458c-91fa-175f876abc55", "leftValue": "={{ $json.contentIG }}", "operator": { "type": "string", "operation": "notEmpty" } }, { "id": "4e362005-3944-4bc9-9d77-4887e1b8ff7d", "leftValue": "={{ ($json.images || []).length }}", "rightValue": 0, "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "options": {} }, "id": "0bbe0078-10ce-468d-9e59-03cedfb9d0fc", "name": "IG?(需文案+圖片)", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ 672, -128 ] }, { "parameters": { "amount": 3 }, "id": "5c062e92-7845-42c3-801f-c85e06e9b2a7", "name": "等待 3 秒(IG 處理圖片)", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 1088, -144 ], "webhookId": "1e419380-df4b-4a40-accc-19723029927b" }, { "parameters": { "method": "POST", "url": "=https://graph.facebook.com/v21.0/{{ $('設定:帳號 ID').first().json.igBusinessId }}/media_publish", "authentication": "predefinedCredentialType", "nodeCredentialType": "facebookGraphApi", "sendBody": true, "contentType": "form-urlencoded", "bodyParameters": { "parameters": [ { "name": "creation_id", "value": "={{ $json.id }}" } ] }, "options": {} }, "id": "f98f01ab-1392-4ced-830b-518cf40c7acf", "name": "IG 步驟 2:發佈媒體", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1312, -144 ], "credentials": { "facebookGraphApi": { "name": "Octoflow FB/IG" } }, "onError": "continueRegularOutput" }, { "parameters": { "numberInputs": 3 }, "id": "2dcfc1d2-e82f-4d1c-ae71-d2f95105c324", "name": "合併三平台結果", "type": "n8n-nodes-base.merge", "typeVersion": 3.2, "position": [ 1696, 176 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose", "version": 1 }, "conditions": [ { "leftValue": "={{ $json.contentFB }}", "operator": { "type": "string", "operation": "notEmpty" } } ], "combinator": "and" }, "options": {} }, "id": "a7702d88-1a8a-462f-b9fb-343c6a0867c4", "name": "FB?(有文字)", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ 640, 208 ] }, { "parameters": { "url": "=https://graph.facebook.com/v21.0/{{ $('設定:帳號 ID').first().json.fbPageId }}?fields=access_token", "authentication": "predefinedCredentialType", "nodeCredentialType": "facebookGraphApi", "options": {} }, "id": "01f40226-9382-4826-bf58-41c442571945", "name": "FB 步驟 1:取得專頁權杖", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 864, 192 ], "credentials": { "facebookGraphApi": { "name": "Octoflow FB/IG" } }, "onError": "continueRegularOutput" }, { "parameters": { "mode": "runOnceForEachItem", "jsCode": "return { pageToken: $json.access_token || '', contentFB: $('整理欄位').item.json.contentFB, pageId: $('整理欄位').item.json.pageId };" }, "id": "30ff6b4f-4879-4604-8996-2a235bf19b56", "name": "FB 步驟 2:擷取專頁權杖", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1072, 192 ] }, { "parameters": { "method": "POST", "url": "=https://graph.facebook.com/v21.0/{{ $('設定:帳號 ID').first().json.fbPageId }}/feed", "sendBody": true, "contentType": "form-urlencoded", "bodyParameters": { "parameters": [ { "name": "message", "value": "={{ $json.contentFB }}" }, { "name": "access_token", "value": "={{ $json.pageToken }}" } ] }, "options": {} }, "id": "41477291-cc1f-432e-ab2e-33ae0f2fd777", "name": "FB 步驟 3:發佈到專頁", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1264, 192 ], "onError": "continueRegularOutput" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose", "version": 1 }, "conditions": [ { "leftValue": "={{ $json.contentThreads }}", "operator": { "type": "string", "operation": "notEmpty" } } ], "combinator": "and" }, "options": {} }, "id": "098c8b05-34c3-475e-a88c-b858735883ba", "name": "Threads?(有文字)", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ 672, 608 ] }, { "parameters": { "method": "POST", "url": "=https://graph.threads.net/v1.0/{{ $('設定:帳號 ID').first().json.threadsUserId }}/threads", "authentication": "genericCredentialType", "genericAuthType": "httpQueryAuth", "sendBody": true, "contentType": "form-urlencoded", "bodyParameters": { "parameters": [ { "name": "media_type", "value": "TEXT" }, { "name": "text", "value": "={{ $json.contentThreads }}" } ] }, "options": {} }, "id": "96ccc7d7-52d8-430a-b6b8-5200996cccbf", "name": "Threads 步驟 1:建立容器", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 864, 592 ], "credentials": { "httpQueryAuth": { "name": "Query Auth account" } }, "onError": "continueRegularOutput" }, { "parameters": { "method": "POST", "url": "=https://graph.threads.net/v1.0/{{ $('設定:帳號 ID').first().json.threadsUserId }}/threads_publish", "authentication": "genericCredentialType", "genericAuthType": "httpQueryAuth", "sendBody": true, "contentType": "form-urlencoded", "bodyParameters": { "parameters": [ { "name": "creation_id", "value": "={{ $json.id }}" } ] }, "options": {} }, "id": "2f0ec3a9-0b96-4eaa-9c2f-16dc382f467d", "name": "Threads 步驟 2:發佈", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1136, 592 ], "credentials": { "httpQueryAuth": { "name": "Query Auth account" } }, "onError": "continueRegularOutput" }, { "parameters": { "content": "## 設定步驟(先填好佔位符,再執行)\n1. 連接認證:Notion(你的工作區)+ Meta Graph API(IG / FB)+ Threads API。\n2. 帳號 ID 集中在「設定:帳號 ID」節點:只需在這一個節點填【IG商業帳號ID】【FB專頁ID】【Threads用戶ID】,三個平台的網址會自動引用。\n3.「讀取 Notion 貼文」:連接你的資料庫(選【Notion資料庫ID】)。欄位需為:IG文案 / FB文案 / Threads文案 / 圖片網址 / 狀態(select)/ 發佈時間(date)/ 錯誤紀錄(text)。\n4.「狀態」選項建議:草稿 / 已核准 / 已發佈 / 部分成功 / 失敗。工作流只發佈狀態 =「已核准」的列。\n5.「回寫狀態到 Notion」:發佈後寫回 狀態(已發佈/部分成功/失敗)、發佈時間、錯誤紀錄。", "height": 500, "width": 676, "color": 4 }, "id": "26e5e194-d809-4117-a468-ac3f8e9867c8", "name": "說明-設定步驟", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -240, -16 ] }, { "parameters": { "content": "## 穩健分流 + 各平台獨立狀態\n每個平台都是從「整理欄位」分出的獨立分支,各自有 IF 條件閘 + 容錯(continue-on-error)。任何一個平台失敗或留空,都不會影響其餘兩個。\n- IG:只在「文案 + 圖片」都有時才執行(IG 無法只發純文字)。沒有圖片 → IG 略過 → 狀態「部分成功」。\n- FB / Threads:各自有文字才執行。\n- 每個分支以「結果」節點收尾(記錄 平台 / 成功與否 / 錯誤)。「合併三平台結果」收集後,「彙整狀態」依頁面分組,計算 已發佈/部分成功/失敗 並寫入「錯誤紀錄」;「回寫狀態到 Notion」每頁只寫一次。\n已知邊界:只有 IG 內容但無圖片的頁面不會進入任何分支 → 維持「已核准」。請補圖片或加入其他平台內容。", "height": 274, "width": 616, "color": 3 }, "id": "0ee8ce10-17a9-4042-89d2-b72f8db30454", "name": "說明-架構", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -240, -304 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "r1", "name": "pageId", "value": "={{ $('整理欄位').item.json.pageId }}", "type": "string" }, { "id": "r2", "name": "platform", "value": "IG", "type": "string" }, { "id": "r3", "name": "ok", "value": "={{ $json.id != null }}", "type": "boolean" }, { "id": "r4", "name": "error", "value": "={{ $json.id != null ? '' : JSON.stringify($json.error || $json) }}", "type": "string" } ] }, "options": {} }, "id": "5ac2026b-58d1-4839-bdb7-63fc593e884f", "name": "IG 結果", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1488, -144 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "r1", "name": "pageId", "value": "={{ $('整理欄位').item.json.pageId }}", "type": "string" }, { "id": "r2", "name": "platform", "value": "FB", "type": "string" }, { "id": "r3", "name": "ok", "value": "={{ $json.id != null }}", "type": "boolean" }, { "id": "r4", "name": "error", "value": "={{ $json.id != null ? '' : JSON.stringify($json.error || $json) }}", "type": "string" } ] }, "options": {} }, "id": "105cdadf-62aa-42e1-b2ce-552165444c43", "name": "FB 結果", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1440, 192 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "r1", "name": "pageId", "value": "={{ $('整理欄位').item.json.pageId }}", "type": "string" }, { "id": "r2", "name": "platform", "value": "Threads", "type": "string" }, { "id": "r3", "name": "ok", "value": "={{ $json.id != null }}", "type": "boolean" }, { "id": "r4", "name": "error", "value": "={{ $json.id != null ? '' : JSON.stringify($json.error || $json) }}", "type": "string" } ] }, "options": {} }, "id": "29abb611-bc45-417e-bce0-5cba1fa8ded5", "name": "Threads 結果", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1296, 592 ] }, { "parameters": { "jsCode": "const norm = {};\nfor (const n of $('整理欄位').all()) { norm[n.json.pageId] = n.json; }\nconst groups = {};\nfor (const it of $input.all()) {\n const { pageId, platform, ok, error } = it.json;\n if (!pageId) continue;\n if (!groups[pageId]) groups[pageId] = [];\n groups[pageId].push({ platform, ok, error });\n}\nconst out = [];\nfor (const pageId of Object.keys(groups)) {\n const res = groups[pageId];\n const okCount = res.filter(r => r.ok).length;\n const failCount = res.filter(r => !r.ok).length;\n const nf = norm[pageId] || {};\n const igSkipped = !!(nf.contentIG && !nf.imageUrl);\n let status;\n if (failCount === 0 && !igSkipped) status = '已發佈';\n else if (okCount === 0) status = '失敗';\n else status = '部分成功';\n const parts = res.filter(r => !r.ok).map(r => r.platform + ': ' + r.error);\n if (igSkipped) parts.push('IG:略過(沒有圖片網址)');\n out.push({ json: { pageId, status, errorLog: parts.join(' | ').slice(0, 1900) } });\n}\nreturn out;" }, "id": "3b99fb3f-d641-4758-8c6a-48f21f46b6f5", "name": "彙整狀態(成功/部分/失敗)", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1888, 192 ] }, { "parameters": { "content": "### IG 分支(需「文案 + 圖片」)\nIG 規定:貼文一定要有圖片,無法只發純文字。\n1.「IG 步驟 1:建立媒體」:把圖片 URL + 文案上傳 Meta,建立 media container。\n2.「等待 3 秒」:留時間給 Meta 處理圖片(大圖可調長)。\n3.「IG 步驟 2:發佈媒體」:正式出帖。\n4.「IG 結果」:記錄成功與否;若沒有圖片,此分支略過 → 整體狀態「部分成功」。", "height": 304, "width": 1012, "color": 6 }, "id": "9784307e-5ba3-4d64-85d3-a5ca2660b4d0", "name": "說明-IG 分支", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 608, -304 ] }, { "parameters": { "content": "### FB 分支(有文字即可)\n1.「FB 步驟 1:取得專頁權杖」:用使用者權杖換取「專頁權杖」(發專頁帖需專頁層級權杖)。\n2.「FB 步驟 2:擷取專頁權杖」:從回應抽出 access_token 傳給下一步。\n3.「FB 步驟 3:發佈到專頁」:把文字貼到 Facebook 專頁動態。\n4.「FB 結果」:記錄成功與否。", "height": 354, "width": 1044, "color": 5 }, "id": "d2bf6327-21f2-47fc-a348-c8ae256f57aa", "name": "說明-FB 分支", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 544, 64 ] }, { "parameters": { "content": "### Threads 分支(有文字即可)\nThreads 採兩段式發佈(與 IG 類似)。\n1.「Threads 步驟 1:建立容器」:用文字建立 container(media_type = TEXT)。\n2.「Threads 步驟 2:發佈」:把 container 正式出帖。\n3.「Threads 結果」:記錄成功與否。", "height": 300, "width": 820, "color": 7 }, "id": "fb2e9e3b-3a23-49ad-952f-b3d402040d8e", "name": "說明-Threads 分支", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 608, 464 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "s1", "name": "igBusinessId", "value": "YOUR_IG_BUSINESS_ID", "type": "string" }, { "id": "s2", "name": "fbPageId", "value": "YOUR_FB_PAGE_ID", "type": "string" }, { "id": "s3", "name": "threadsUserId", "value": "YOUR_THREADS_USER_ID", "type": "string" } ] }, "options": {} }, "id": "1e4e3fef-fee9-498f-b1f7-d06c2e585871", "name": "設定:帳號 ID", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 0, 208 ], "notes": "在這裡填三個平台的帳號 ID,下游網址會自動引用。" }, { "parameters": { "resource": "databasePage", "operation": "update", "pageId": { "__rl": true, "mode": "id", "value": "={{ $json.pageId }}" }, "propertiesUi": { "propertyValues": [ { "key": "Status|select", "selectValue": "已發佈" } ] }, "options": {} }, "id": "3cd75372-6b40-4c7e-92c4-57c7cb4eb044", "name": "回寫狀態到 Notion", "type": "n8n-nodes-base.notion", "typeVersion": 2.2, "position": [ 2080, 192 ], "credentials": { "notionApi": { "name": "KEA" } } }, { "parameters": { "amount": 15 }, "id": "0abb29fe-aeda-43e6-827f-429ee7adb835", "name": "等待 15 秒(Threads 處理)", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 1008, 592 ], "webhookId": "b75c1c08-c680-4ff9-8f44-fd5e9f2eb4b1" }, { "parameters": { "fieldToSplitOut": "images", "include": "noOtherFields", "options": {} }, "type": "n8n-nodes-base.splitOut", "typeVersion": 1, "position": [ 820, -40 ], "name": "拆 IG 圖", "id": "c8cdd809-278b-49e2-a1f7-af85fdc9480b" }, { "parameters": { "method": "POST", "url": "=https://graph.facebook.com/v21.0/{{ $('設定:帳號 ID').first().json.igBusinessId }}/media", "authentication": "predefinedCredentialType", "nodeCredentialType": "facebookGraphApi", "sendBody": true, "contentType": "form-urlencoded", "bodyParameters": { "parameters": [ { "name": "is_carousel_item", "value": "true" }, { "name": "image_url", "value": "={{ $json.images }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1000, -40 ], "name": "IG 建 item", "id": "2e6ca76f-bad2-491a-a977-10ccb4987c40", "credentials": { "facebookGraphApi": { "name": "Octoflow FB/IG" } } }, { "parameters": { "fieldsToAggregate": { "fieldToAggregate": [ { "fieldToAggregate": "id", "renameField": false } ] }, "options": {} }, "type": "n8n-nodes-base.aggregate", "typeVersion": 1, "position": [ 1180, -40 ], "name": "集 IG item", "id": "60cbfd5a-abf4-4744-8566-dcc306371b6f" }, { "parameters": { "method": "POST", "url": "=https://graph.facebook.com/v21.0/{{ $('設定:帳號 ID').first().json.igBusinessId }}/media", "authentication": "predefinedCredentialType", "nodeCredentialType": "facebookGraphApi", "sendBody": true, "contentType": "form-urlencoded", "bodyParameters": { "parameters": [ { "name": "media_type", "value": "CAROUSEL" }, { "name": "children", "value": "={{ $json.id.join(',') }}" }, { "name": "caption", "value": "={{ $('整理欄位').first().json.contentIG }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1360, -40 ], "name": "IG 建 carousel", "id": "a59ef06e-48d6-4c74-b322-191218c747b5", "credentials": { "facebookGraphApi": { "name": "Octoflow FB/IG" } } } ], "connections": { "讀取 Notion 貼文": { "main": [ [ { "node": "整理欄位", "type": "main", "index": 0 } ] ] }, "整理欄位": { "main": [ [ { "node": "Threads?(有文字)", "type": "main", "index": 0 }, { "node": "IG?(需文案+圖片)", "type": "main", "index": 0 }, { "node": "FB?(有文字)", "type": "main", "index": 0 } ] ] }, "IG?(需文案+圖片)": { "main": [ [ { "node": "拆 IG 圖", "type": "main", "index": 0 } ] ] }, "等待 3 秒(IG 處理圖片)": { "main": [ [ { "node": "IG 步驟 2:發佈媒體", "type": "main", "index": 0 } ] ] }, "IG 步驟 2:發佈媒體": { "main": [ [ { "node": "IG 結果", "type": "main", "index": 0 } ] ] }, "IG 結果": { "main": [ [ { "node": "合併三平台結果", "type": "main", "index": 0 } ] ] }, "FB?(有文字)": { "main": [ [ { "node": "FB 步驟 1:取得專頁權杖", "type": "main", "index": 0 } ] ] }, "FB 步驟 1:取得專頁權杖": { "main": [ [ { "node": "FB 步驟 2:擷取專頁權杖", "type": "main", "index": 0 } ] ] }, "FB 步驟 2:擷取專頁權杖": { "main": [ [ { "node": "FB 步驟 3:發佈到專頁", "type": "main", "index": 0 } ] ] }, "FB 步驟 3:發佈到專頁": { "main": [ [ { "node": "FB 結果", "type": "main", "index": 0 } ] ] }, "FB 結果": { "main": [ [ { "node": "合併三平台結果", "type": "main", "index": 1 } ] ] }, "Threads?(有文字)": { "main": [ [ { "node": "Threads 步驟 1:建立容器", "type": "main", "index": 0 } ] ] }, "Threads 步驟 2:發佈": { "main": [ [ { "node": "Threads 結果", "type": "main", "index": 0 } ] ] }, "Threads 結果": { "main": [ [ { "node": "合併三平台結果", "type": "main", "index": 2 } ] ] }, "合併三平台結果": { "main": [ [ { "node": "彙整狀態(成功/部分/失敗)", "type": "main", "index": 0 } ] ] }, "彙整狀態(成功/部分/失敗)": { "main": [ [ { "node": "回寫狀態到 Notion", "type": "main", "index": 0 } ] ] }, "排程觸發(每 4 小時)": { "main": [ [ { "node": "設定:帳號 ID", "type": "main", "index": 0 } ] ] }, "設定:帳號 ID": { "main": [ [ { "node": "讀取 Notion 貼文", "type": "main", "index": 0 } ] ] }, "Threads 步驟 1:建立容器": { "main": [ [ { "node": "等待 15 秒(Threads 處理)", "type": "main", "index": 0 } ] ] }, "等待 15 秒(Threads 處理)": { "main": [ [ { "node": "Threads 步驟 2:發佈", "type": "main", "index": 0 } ] ] }, "拆 IG 圖": { "main": [ [ { "node": "IG 建 item", "type": "main", "index": 0 } ] ] }, "IG 建 item": { "main": [ [ { "node": "集 IG item", "type": "main", "index": 0 } ] ] }, "集 IG item": { "main": [ [ { "node": "IG 建 carousel", "type": "main", "index": 0 } ] ] }, "IG 建 carousel": { "main": [ [ { "node": "等待 3 秒(IG 處理圖片)", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1", "availableInMCP": true, "binaryMode": "separate" }, "meta": { "exportedFrom": "lbnkivFUn5CqEVQ2", "exportedAt": "2026-08-21" } }