8
n8n 中文网amn8n.com

使用AI智能体和Google表格自动化Twitter社交媒体发布

高级

这是一个Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 Code, Twitter, GoogleSheets, Agent, ScheduleTrigger 等节点。 通过GPT-4内容生成和Google表格跟踪自动化Twitter发布

前置要求
  • Twitter API 凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "i8ATrlawNnV9FGIV",
  "meta": {
    "instanceId": "1a54c41d9050a8f1fa6f74ca858828ad9fb97b9fafa3e9760e576171c531a787"
  },
  "name": "使用 AI 智能体和 Google Sheets 自动化 Twitter (x.com) 社交媒体发布",
  "tags": [],
  "nodes": [
    {
      "id": "185ffe75-df92-4137-a4a2-985e9d4c4359",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        640,
        832
      ],
      "parameters": {
        "text": "=You are an expert social media manager for Intuz's Twitter account. Generate engaging tweets for C-suite executives, CTOs, and engineering leaders.\n\n🚨 ABSOLUTE CHARACTER LIMIT: 250 CHARACTERS MAXIMUM (including ALL text, spaces, hashtags, URLs)\n\nMANDATORY PROCESS:\n1. Draft tweet\n2. Count EVERY character (letters, spaces, punctuation, hashtags, URLs)\n3. If >250 characters: Shorten immediately\n4. Recount until ≤250 characters\n5. Never exceed 250 under any circumstances\n6. Check for existing same tweets from the Google Sheet, so as to avoid duplicate tweets\n\nOUTPUT FORMAT:\n{\n\"tweet_content\": \"[Your tweet here - max 280 chars]\",\n\"character_count\": \"[X/280]\",\n\"status\": \"Published\"\n}\n\nCONTENT FOCUS: AI trends, automation, cloud tech, RAG, ML innovations, MCP, n8n, Software Development\n\nREQUIREMENTS:\n- Always include #Intuz\n- Add 4-7 relevant hashtags\n- Include URL for https://www.mlopscrew.com/ if the tweet is cloud related otherwise add https://www.intuz.com/\n- Ask questions or add CTAs\n- Make each tweet unique\n- Keep tone: innovative, authoritative, educational\n\nCHARACTER BUDGET:\n- Core message: ~150-180 chars\n- Hashtags: ~40-60 chars\n- URL: ~20-30 chars\n- TOTAL: ≤250 chars\n\nTARGET: Drive leads, engagement, \"Contact Us\" inquiries\n\nFINAL CHECK: Confirm character count ≤280 before submitting!",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "fc8d5d4f-bb1b-4645-8301-d9f08f2d00a6",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        400,
        1248
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "a768abfb-aa5a-4363-b942-eee38f5deeff",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        736,
        1728
      ],
      "parameters": {
        "sessionKey": "TWEETS",
        "sessionIdType": "customKey",
        "contextWindowLength": 15
      },
      "typeVersion": 1.3
    },
    {
      "id": "68527ad0-d27f-42aa-bf28-36a8e4f86b84",
      "name": "创建推文",
      "type": "n8n-nodes-base.twitter",
      "position": [
        2256,
        992
      ],
      "parameters": {
        "text": "={{ $json.tweet_content }}",
        "additionalFields": {}
      },
      "typeVersion": 2
    },
    {
      "id": "0efc1811-933f-4765-838d-48d48c4e231d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        1168
      ],
      "parameters": {
        "width": 464,
        "height": 272,
        "content": "### 步骤 1:调度器触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "1f98869b-5a49-4e0b-97c2-beac42127f00",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        672
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 352,
        "content": "### 步骤 2:AI 智能体节点"
      },
      "typeVersion": 1
    },
    {
      "id": "c855336e-907a-4d16-bcb1-d3f40d355ba9",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        1216
      ],
      "parameters": {
        "color": 3,
        "width": 384,
        "height": 368,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "44a5383e-df8d-4e20-8c5e-413d31a74bce",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        1712
      ],
      "parameters": {
        "color": 4,
        "width": 464,
        "height": 304,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "43269c90-3691-48dc-8c3a-aea53349206b",
      "name": "从 Google Sheets 获取数据",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1120,
        1248
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{YOUR_GOOGLE_SHEETS_DOCUMENT_ID}/edit#gid=0",
          "cachedResultName": "Tweets"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "{YOUR_GOOGLE_SHEETS_DOCUMENT_ID}",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{YOUR_GOOGLE_SHEETS_DOCUMENT_ID}/edit?usp=drivesdk",
          "cachedResultName": "Twitter"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "dcf857b1-9cf0-42aa-8b5c-651d6cc97118",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        1232
      ],
      "parameters": {
        "color": 6,
        "width": 496,
        "height": 304,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "410b5cb5-b4fb-4c00-9d06-464860334a43",
      "name": "解析 AI 响应",
      "type": "n8n-nodes-base.code",
      "position": [
        1616,
        1232
      ],
      "parameters": {
        "jsCode": "// Input: string with escaped or messy JSON\nconst inputString = $input.first().json.output;\n\nfunction safeParse(str) {\n  try {\n    // Try direct parse first\n    return JSON.parse(str);\n  } catch (e) {\n    // Try to extract JSON substring with regex\n    const match = str.match(/\\{[\\s\\S]*\\}/);\n    if (match) {\n      try {\n        return JSON.parse(match[0]);\n      } catch (err) {\n        return { error: \"Failed to parse extracted JSON\", raw: str };\n      }\n    }\n    return { error: \"Invalid JSON format\", raw: str };\n  }\n}\n\nconst parsed = safeParse(inputString);\n\n// Return cleaned output\nreturn [\n  {\n    json: parsed\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "ea5b0b4f-a8f2-41fb-9fa7-d11d89f8b9c1",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        1040
      ],
      "parameters": {
        "width": 400,
        "height": 352,
        "content": "### 步骤 3:代码节点"
      },
      "typeVersion": 1
    },
    {
      "id": "190e5bfe-99e6-4dbf-abc2-a56e633ef4a3",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        816
      ],
      "parameters": {
        "color": 3,
        "width": 432,
        "height": 352,
        "content": "### 步骤 4:X 创建推文节点"
      },
      "typeVersion": 1
    },
    {
      "id": "44d53ba9-ffdc-44dd-9414-65149f2b2449",
      "name": "将新推文添加到 Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3024,
        1200
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "={{ $('Parse AI Response').item.json.status }}",
            "Tweet Content": "={{ $('Parse AI Response').item.json.tweet_content }}"
          },
          "schema": [
            {
              "id": "Tweet Content",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Tweet Content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Tweet Content"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{YOUR_GOOGLE_SHEETS_DOCUMENT_ID}/edit#gid=0",
          "cachedResultName": "Tweets"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "{YOUR_GOOGLE_SHEETS_DOCUMENT_ID}",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{YOUR_GOOGLE_SHEETS_DOCUMENT_ID}/edit?usp=drivesdk",
          "cachedResultName": "Twitter"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "95ba4418-c676-425d-bdee-a756f1422bea",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2816,
        960
      ],
      "parameters": {
        "color": 4,
        "width": 496,
        "height": 432,
        "content": "### 步骤 5:将新推文添加到 Google Sheets 节点"
      },
      "typeVersion": 1
    },
    {
      "id": "e9779654-a51b-4c71-b356-9fd7e7d08ea4",
      "name": "启动工作流",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -96,
        1312
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "28fca0ca-9c2d-4b14-9c50-4b533bc7fac9",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        592
      ],
      "parameters": {
        "color": 3,
        "width": 528,
        "height": 432,
        "content": "### 先决条件"
      },
      "typeVersion": 1
    },
    {
      "id": "7d1f8ed7-e600-482f-b4b2-bae71fd337c2",
      "name": "便签 23",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1552,
        1584
      ],
      "parameters": {
        "color": 2,
        "width": 440,
        "height": 240,
        "content": "## 需要帮助?"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0d4ea7d6-69a6-40bc-a8f3-4fb1ce2c6315",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Tweet": {
      "main": [
        [
          {
            "node": "Add new Tweet to Google sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Start Workflow": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Create Tweet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data from Google Sheet": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 多模态 AI

需要付费吗?

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

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

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

作者
Intuz

Intuz

@intuz

Workflow automation can help automate your routine activities and help saves $$$, as well as hours of time. As a boutique tech consulting company, Intuz help businesses with custom AI/ML, AI Workflow Automations, and software development. Automate your business workflow for: Sales Marketing Accounting Finance Operations E-Commerce Customer Support Admin & Backoffice Logistics & Supply Chain

外部链接
在 n8n.io 查看

分享此工作流