8
n8n 中文网amn8n.com

在您的 Facebook 页面发布视频故事

高级

这是一个Social Media领域的自动化工作流,包含 16 个节点。主要使用 If, Set, Code, GoogleDrive, HttpRequest 等节点。 使用 Google Drive 和 Sheets 自动化视频故事发布到 Facebook 页面

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Y0jw3nbvhkigsAeh",
  "meta": {
    "instanceId": "b5825084f383ba38862ba0b5b7e95c5107a40c4ed7afc78372d74501163a8e33",
    "templateCredsSetupCompleted": true
  },
  "name": "在您的 Facebook 页面发布视频故事",
  "tags": [
    {
      "id": "U9LHxJS6pH2YCEtj",
      "name": "Sheet",
      "createdAt": "2025-10-13T08:26:02.584Z",
      "updatedAt": "2025-10-13T08:26:02.584Z"
    },
    {
      "id": "TSDrPBKIHGgril48",
      "name": "Page",
      "createdAt": "2025-10-13T08:26:02.604Z",
      "updatedAt": "2025-10-13T08:26:02.604Z"
    },
    {
      "id": "ph1PMcg0s6aIzhHu",
      "name": "Stories",
      "createdAt": "2025-10-13T08:27:45.422Z",
      "updatedAt": "2025-10-13T08:27:45.422Z"
    }
  ],
  "nodes": [
    {
      "id": "6610905b-a452-4271-b201-c78efb25371c",
      "name": "定时触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1664,
        96
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 2,
              "triggerAtMinute": 30
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c0ba59ab-53b3-441a-a830-775dde0f4b41",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1344,
        416
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('If').first().json[\"File ID\"] }}"
        },
        "options": {
          "binaryPropertyName": "data"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "b1IgmLfVK7MkWuXO",
          "name": "Google Drive account"
        }
      },
      "executeOnce": true,
      "typeVersion": 3,
      "alwaysOutputData": false
    },
    {
      "id": "5e527ed0-ddc1-450a-b655-127954c89fbb",
      "name": "信息",
      "type": "n8n-nodes-base.set",
      "position": [
        -1440,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0fc539bd-e223-4f1a-86b2-15e4b2a34df6",
              "name": "ID Page",
              "type": "string",
              "value": "<id page>"
            },
            {
              "id": "5ca53588-a5fd-47fe-a9db-5e8b42e88a19",
              "name": "Token",
              "type": "string",
              "value": "<token>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d441d79f-4dcf-4142-8397-b433a5f8bf38",
      "name": "搜索文件和文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1376,
        -256
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "16tm-jSUaz4B4Xk8Dc0h-jxxKVydzwHKJ",
            "cachedResultUrl": "https://drive.google.com/drive/folders/16tm-jSUaz4B4Xk8Dc0h-jxxKVydzwHKJ",
            "cachedResultName": "n8n creator"
          }
        },
        "options": {
          "fields": [
            "id",
            "name"
          ]
        },
        "resource": "fileFolder",
        "returnAll": true,
        "queryString": "mimeType = 'video/mp4'",
        "searchMethod": "query"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "b1IgmLfVK7MkWuXO",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "6a4a9d0e-6e90-409e-9d75-2666edaad284",
      "name": "计划触发器1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1664,
        -256
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8242c54c-0100-40ab-9ef3-10eee0587e40",
      "name": "在表格中追加或更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1024,
        -256
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $json.name }}",
            "File ID": "={{ $json.id }}",
            "Link Share": "=https://drive.google.com/uc?id={{ $json.id }}&export=download"
          },
          "schema": [
            {
              "id": "Stories",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Stories",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "File ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link Share",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Link Share",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "File ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI/edit#gid=0",
          "cachedResultName": "Trang tính1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI/edit?usp=drivesdk",
          "cachedResultName": "Video stories facebook"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HfujyDOlKBcmEBrq",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0e173c5f-d33a-4b6e-ba29-89b815c1e26c",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        -1040,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e9464670-2642-4a70-9ec2-90211044bb72",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json[\"File ID\"] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "48727079-929a-49ec-9370-a327609c3d94",
      "name": "步骤 1:初始化会话",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -1648,
        416
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/{{ $('info').first().json['ID Page'] }}/video_stories",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "upload_phase",
              "value": "start"
            },
            {
              "name": "access_token",
              "value": "={{ $('info').first().json.Token }}"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "5a0bf363-f623-4010-be5c-430fb107d814",
      "name": "设置为总字节大小",
      "type": "n8n-nodes-base.code",
      "position": [
        -1040,
        416
      ],
      "parameters": {
        "jsCode": "return items.map(item => {\n  const size = item.binary.data.fileSize;\n  const contentLength = Buffer.from(item.binary.data.data, 'base64').length;\n\n  item.json = {\n    declaredSize: size,\n    actualSize: contentLength\n  };\n\n  return item;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "49bcfba4-e00b-4297-8ce8-92418531eb34",
      "name": "步骤 2:上传存储的文件",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -1680,
        656
      ],
      "parameters": {
        "url": "={{ $('Step 1: Initialize session').first().json.body.upload_url }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "offset",
              "value": "0"
            },
            {
              "name": "file_size",
              "value": "={{ $('Set to the total size in bytes').first().json.actualSize }}"
            },
            {
              "name": "Authorization",
              "value": "=OAuth {{ $('info').first().json.Token }}"
            }
          ]
        },
        "inputDataFieldName": "=data"
      },
      "typeVersion": 4.2
    },
    {
      "id": "d2e56376-e073-4a69-92be-002690c363c7",
      "name": "步骤 3:发布视频",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -1456,
        656
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/{{ $('info').first().json['Id Page'] }}/video_stories",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "video_id",
              "value": "={{ $('Step 1: Initialize session').item.json.body.video_id }}"
            },
            {
              "name": "upload_phase",
              "value": "finish"
            },
            {
              "name": "access_token",
              "value": "=EAAJQeT0qhu8BO7iHI2a7ZBNGmI2iLo1SJ6hUdhlyUoJe1dCZBAZC0wkVa9gyF6AUiG4fxfc36qvTyZBeJLR60EL0FRHBYdImZC6o6PZAvdj9ZAQUbGCNJfpEZC0MCuFYxU5XlHrVrTYaqcbjtkionualjCyPxHgAdBBVvsvTrKUcu8rh4Qb0yKe5JyfTCFqpyNstZBiPnSVw35wavyowusyh5rhMZD"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4e5360d8-184b-42c7-b21c-6179ede6f2ff",
      "name": "获取上传状态",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -1264,
        656
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/{{ $('Step 1: Initialize session').first().json.body.video_id }}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('info').first().json.Token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3d0876ac-b2e2-4813-862d-c1f544482787",
      "name": "在表格中更新上传状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1056,
        656
      ],
      "parameters": {
        "columns": {
          "value": {
            "row_number": "={{ $('If').first().json.row_number }}"
          },
          "schema": [
            {
              "id": "Stories",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Stories",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "File ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link Share",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Link Share",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI/edit#gid=0",
          "cachedResultName": "Trang tính1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI/edit?usp=drivesdk",
          "cachedResultName": "Video stories facebook"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HfujyDOlKBcmEBrq",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "139aa6d4-a7fb-49e8-afa4-2b83a1c2937d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2352,
        -304
      ],
      "parameters": {
        "width": 1536,
        "height": 272,
        "content": "## 自动将 Google Drive 视频列表更新到 Google Sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "6dd1a5f7-d7d1-45c0-8cc0-b93950d4df97",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2352,
        48
      ],
      "parameters": {
        "width": 1536,
        "height": 816,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "644cfefc-9786-4c56-96ac-4c9bcb7907bc",
      "name": "获取行表",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        -1248,
        96
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Stories"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI/edit#gid=0",
          "cachedResultName": "Trang tính1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RnE5O06l7W6TLCLKkwEH5Oyl-EZ3OE-Uc3OWFbDohYI/edit?usp=drivesdk",
          "cachedResultName": "Video stories facebook"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HfujyDOlKBcmEBrq",
          "name": "Google Sheets account"
        }
      },
      "executeOnce": false,
      "typeVersion": 4.5,
      "alwaysOutputData": true
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0ab02551-da14-4f2f-b378-396d3aa12812",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Step 1: Initialize session",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Row Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "info": {
      "main": [
        [
          {
            "node": "Get Row Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Set to the total size in bytes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Row Sheet": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get upload status": {
      "main": [
        [
          {
            "node": "Update upload status in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger1": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 3. Post video": {
      "main": [
        [
          {
            "node": "Get upload status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 1: Initialize session": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set to the total size in bytes": {
      "main": [
        [
          {
            "node": "Step 2: Upload the stored file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 2: Upload the stored file": {
      "main": [
        [
          {
            "node": "Step 3. Post video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 社交媒体

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类1
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
外部链接
在 n8n.io 查看

分享此工作流