社交媒体自动发布器 (Google Sheets → Twitter 和 Instagram)

高级

这是一个Social Media领域的自动化工作流,包含 16 个节点。主要使用 Set、HttpRequest、GoogleSheets、ScheduleTrigger、FacebookGraphApi 等节点。 从 Google Sheets 安排社交媒体帖子发布到 Twitter 和 Instagram

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Facebook Graph API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "oAaE92ALCw2gDlGu",
  "meta": {
    "instanceId": "cc015731fc495809b886aea182b15bbd667eb8429470d9c57541b0221b87b7e0",
    "templateCredsSetupCompleted": true
  },
  "name": "社交媒体自动发布器 (Google Sheets → Twitter 和 Instagram)",
  "tags": [],
  "nodes": [
    {
      "id": "883262fd-4b71-4ad0-bcf8-86aa5a0186b8",
      "name": "定时触发器",
      "rule": {
        "interval": [
          {
            "field": "hours",
            "hoursInterval": 4
          }
        ]
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "notes": "This workflow is triggered automatically every 4 hours.",
      "position": [
        -260,
        -60
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "874c156e-d4ec-4c42-a958-c5ae7eff6ede",
      "name": "获取表格中的行",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Fetches the first row from the Google Sheet where the 'Status' column is marked as 'Pending'. This provides the content for the social media posts.",
      "position": [
        -80,
        -60
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "Pending",
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": "[YOUR_GOOGLE_SHEET_ID]"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pToMN52MhgPTizJB",
          "name": "Google Sheets account"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.6
    },
    {
      "id": "e8eb5bf7-8939-4af5-a935-38a30da70077",
      "name": "Instagram 帖子标题",
      "type": "n8n-nodes-base.set",
      "notes": "Prepares the data for the Instagram post. It combines the 'Caption', 'Description', and 'Hashtags' from the Google Sheet into a single `final_caption`. It also generates an HTML structure to be converted into the post image.",
      "position": [
        180,
        -160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6a5be148-4da5-48ab-acae-810ab0f2d825",
              "name": "final_caption",
              "type": "string",
              "value": "={{$json[\"Caption\"]+\"  ..................                     \" +\"[\" + $json[\"Desc\"] +\"]\" +\"  ..................                     \" + $json[\"Hashtags\"]}}"
            },
            {
              "id": "09830a57-d962-4992-aca7-5ddfad947594",
              "name": "HTML",
              "type": "string",
              "value": "=<div style=\"width: 1080px; height: 1080px; background: #0f1419; color: white; font-family: 'Segoe UI', sans-serif; padding: 80px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-start;\">\n  <div style=\"display: flex; align-items: center; margin-bottom: 60px;\">\n    <img src=\"https://your_URL\" style= width: 100px; height: 100px; border-radius: 50%; margin-right: 30px;\">\n    <div>\n      <div style=\"font-weight: bold; font-size: 36px;\">Cursed Canvas</div>\n      <div style=\"color: #8899a6; font-size: 28px;\">@insane_dvlpr</div>\n    </div>\n  </div>\n\n  <div style=\"font-size: 44px; line-height: 1.5; margin-bottom: 80px;\">{{ $json.Caption }}</div>\n\n  <div style=\"display: flex; gap: 40px;\">\n    <img src=\"https://cdn4.iconfinder.com/data/icons/twitter-29/512/166_Heart_Love_Like_Twitter-64.png\" style=\"width: 48px; height: 48px;\">\n    <img src=\"https://img.icons8.com/ios-glyphs/48/speech-bubble--v1.png\" style=\"width: 48px; height: 48px; filter: invert(1);\">\n  </div>\n</div>\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6e6540b9-e5b8-47b4-b806-93f82a3d6be0",
      "name": "HCTI 图片",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Sends the generated HTML to the HTML/CSS to Image API (hcti.io) to create a 1080x1080px image for the Instagram post.",
      "position": [
        400,
        -160
      ],
      "parameters": {
        "url": "https://hcti.io/v1/image",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "HTML",
              "value": "={{ $json.HTML }}"
            },
            {
              "name": "viewport_width",
              "value": "1080"
            },
            {
              "name": "viewport_height",
              "value": "1080"
            }
          ]
        },
        "genericAuthType": "httpBasicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "5QK0XuUDmKbVAjUN",
          "name": "Unnamed credential 2"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c924428-729d-49db-8ac0-d979ab585a31",
      "name": "在 Twitter 上发布",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Posts the content from the 'Caption' column of the Google Sheet as a new tweet on X (Twitter).",
      "position": [
        180,
        40
      ],
      "parameters": {
        "url": "https://api.x.com/2/tweets",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{ $json.Caption }}"
            }
          ]
        },
        "genericAuthType": "oAuth1Api"
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "b43788d0-447e-402d-a14c-f458ccaa0600",
      "name": "创建 Instagram 帖子",
      "type": "n8n-nodes-base.facebookGraphApi",
      "notes": "Step 1/2 for Instagram Posting. This node uploads the image generated in the previous step to the Instagram Content Publishing API. This creates a media container but does not publish it yet.",
      "position": [
        620,
        -160
      ],
      "parameters": {
        "edge": "media",
        "node": "[YOUR_INSTAGRAM_ACCOUNT_ID]",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "image_url",
                "value": "={{ $json.url }}"
              },
              {
                "name": "caption",
                "value": "={{ $('Insta post caption').item.json.final_caption }}"
              },
              {
                "name": "access_token",
                "value": "[YOUR_FACEBOOK_ACCESS_TOKEN]"
              }
            ]
          }
        },
        "graphApiVersion": "v19.0",
        "httpRequestMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "e5f1094d-4445-4ade-a19f-d82de803c572",
      "name": "在 Instagram 上发布",
      "type": "n8n-nodes-base.facebookGraphApi",
      "notes": "Step 2/2 for Instagram Posting. This node takes the container ID from the previous step ('Create Insta post') and publishes the media to the Instagram feed.",
      "position": [
        840,
        -160
      ],
      "parameters": {
        "edge": "media_publish",
        "node": "[YOUR_INSTAGRAM_ACCOUNT_ID]",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "creation_id",
                "value": "={{ $json.id }}"
              },
              {
                "name": "access_token",
                "value": "[YOUR_FACEBOOK_ACCESS_TOKEN]"
              }
            ]
          }
        },
        "graphApiVersion": "v19.0",
        "httpRequestMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "0261b9ff-d0de-44c8-a06f-bfa58cebd8c1",
      "name": "更新状态为已发布",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Updates the Google Sheet row that was just used. It changes the 'Status' column to 'Posted on [current date and time]' to prevent it from being posted again.",
      "position": [
        1060,
        -160
      ],
      "parameters": {
        "columns": {
          "value": {
            "RowID": "={{ $('Get row(s) in sheet').item.json.RowID }}",
            "Status": "={{ 'Posted on ' + $now.toLocaleString() }}\n"
          },
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "RowID"
          ]
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": "[YOUR_GOOGLE_SHEET_ID]"
      },
      "typeVersion": 4.6
    },
    {
      "id": "3e06fa87-1e19-4f06-b106-48bae0b5e0d6",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -100
      ],
      "parameters": {
        "content": "此工作流每 4 小时自动触发一次。"
      },
      "typeVersion": 1
    },
    {
      "id": "d4d5baf2-b4a1-4e39-b6ae-e38844e987c3",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -280
      ],
      "parameters": {
        "width": 220,
        "height": 180,
        "content": "## Google 表格"
      },
      "typeVersion": 1
    },
    {
      "id": "6c184428-9ea3-434a-8853-c50c616bf04e",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -500
      ],
      "parameters": {
        "height": 320,
        "content": "## 为 Instagram 帖子创建标题"
      },
      "typeVersion": 1
    },
    {
      "id": "21402df3-00f8-471a-877a-af51633c4d9d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -500
      ],
      "parameters": {
        "width": 260,
        "height": 320,
        "content": "## 使用 HTMLCSSIMAGE API 创建图片"
      },
      "typeVersion": 1
    },
    {
      "id": "f34942ad-7f26-4914-9a15-4d050b303622",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        220
      ],
      "parameters": {
        "height": 240,
        "content": "## 发布推文"
      },
      "typeVersion": 1
    },
    {
      "id": "65e786bc-b179-496a-8148-3ac2b2b2b416",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        -500
      ],
      "parameters": {
        "color": 3,
        "width": 440,
        "height": 500,
        "content": "## 在 Instagram 上发布"
      },
      "typeVersion": 1
    },
    {
      "id": "00a6e0d9-c32a-4353-bc21-6bc022edefdc",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        -440
      ],
      "parameters": {
        "height": 240,
        "content": "## 更新 Google 表格"
      },
      "typeVersion": 1
    },
    {
      "id": "f30a7954-99fa-4248-8a6f-a942b5ad80cb",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1220,
        -440
      ],
      "parameters": {
        "width": 640,
        "height": 980,
        "content": "## 社交媒体自动发布器 (Google Sheets → Twitter 和 Instagram)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9fcb74ec-477d-44e9-9148-a1dde8e2bea8",
  "connections": {
    "HCTI Image": {
      "main": [
        [
          {
            "node": "Create Insta post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Insta post": {
      "main": [
        [
          {
            "node": "Post On Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post On Instagram": {
      "main": [
        [
          {
            "node": "Update Status Posted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insta post caption": {
      "main": [
        [
          {
            "node": "HCTI Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Post on Twitter",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insta post caption",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个高级难度的工作流,适用于Social Media等场景。适合高级用户,包含 16+ 个节点的复杂工作流

需要付费吗?

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

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

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

作者
Parag Javale

Parag Javale

@pollar-beer

Tech driven creative who turns ideas into impact. I blend storytelling, product strategy, and automation whether it’s hooky audio promos, smart LMS platforms, or AI driven workflows. I help businesses grab attention, streamline ops, and scale fast. Big on data, experiments, and building digital solutions that actually work.

外部链接
在 n8n.io 上查看 →

分享此工作流