8
n8n 中文网amn8n.com

按名称查找Twitter个人资料,抓取帖子并使用AI分析内容,保存到Google Sheets

高级

这是一个AI, Marketing领域的自动化工作流,包含 22 个节点。主要使用 If, Set, Code, Form, Html 等节点,结合人工智能技术实现智能自动化。 使用Bright Data和Gemini按名称查找、抓取并分析Twitter帖子

前置要求
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "AbtPK2RrW116HBH3",
  "meta": {
    "instanceId": "71eb5622cf8abac565805540c0900dbae437dddbda45bf1b87bf3bfeea26393c",
    "templateCredsSetupCompleted": true
  },
  "name": "按名称查找 Twitter 个人资料,抓取帖子并使用 AI 分析内容,保存到 Google Sheets。",
  "tags": [],
  "nodes": [
    {
      "id": "3f37efb9-0ba6-474a-b5df-d453bb79d8e6",
      "name": "从网站提取正文和标题",
      "type": "n8n-nodes-base.html",
      "position": [
        660,
        0
      ],
      "parameters": {
        "options": {
          "trimValues": true
        },
        "operation": "extractHtmlContent",
        "dataPropertyName": "body",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            },
            {
              "key": "body",
              "cssSelector": "body"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "89d9a5af-f79a-44ad-87c3-99a410fe52eb",
      "name": "当用户完成表单时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "webhookId": "41d0bffa-f5ca-4df7-b757-ca5a1e472b8a",
      "parameters": {
        "options": {
          "path": "search-user",
          "ignoreBots": true,
          "buttonLabel": "Get References"
        },
        "formTitle": "Twitter (X) posts analyzer",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Person Fullname",
              "placeholder": "Complete the fullname",
              "requiredField": true
            },
            {
              "fieldLabel": "Analyze Posts From Date",
              "placeholder": "2025-05-01"
            },
            {
              "fieldLabel": "Analyze Posts To Date",
              "placeholder": "2025-05-20"
            }
          ]
        },
        "responseMode": "lastNode",
        "formDescription": "Complete the data of the person you want to analyze.\n\nA personalized follow-up email with insights and suggested outreach steps will be sent to you:"
      },
      "typeVersion": 2.2
    },
    {
      "id": "9cc99302-3a97-471b-8260-b2d0dda37be5",
      "name": "编辑 URL Google 搜索",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6b95685b-3286-4643-bfa1-6335d3f8cb39",
              "name": "google_search",
              "type": "string",
              "value": "=https://www.google.com/search?q=site%3Ax.com+{{ encodeURIComponent($json[\"Person Fullname\"].trim()) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ae25a27d-4631-4131-ac42-ab39ba423806",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        900,
        180
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "typeVersion": 1
    },
    {
      "id": "dca04cd0-4519-41ae-9b0f-3c202a72cac3",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1040,
        180
      ],
      "parameters": {
        "jsonSchemaExample": "[{\n  \"username\": \"string\",\n  \"name\": \"string\",\n  \"url\": \"string\",\n  \"description\": \"string\"\n}]\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "d26a1cf1-c131-4a78-b968-4d2280c7dd7d",
      "name": "表单未找到",
      "type": "n8n-nodes-base.form",
      "position": [
        1260,
        160
      ],
      "webhookId": "a509f577-231f-435f-b3c2-0fed718f0cc8",
      "parameters": {
        "operation": "completion",
        "respondWith": "showText",
        "responseText": "=We didn't found X Profile for \"{{ $('When User Completes Form').item.json[\"Person Fullname\"] }} \""
      },
      "typeVersion": 1
    },
    {
      "id": "d05c6134-02ba-4e75-b062-0994c1802ba1",
      "name": "找到 X 个人资料了吗?",
      "type": "n8n-nodes-base.if",
      "position": [
        1260,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "645d85d3-c5cc-4e51-a989-075c0a851449",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.output[0]['url'] }}",
              "rightValue": 1
            },
            {
              "id": "b44e6a86-9a9b-4d3e-b9c8-cf75bba8ed03",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d2f963d7-4bb9-41d6-b698-028d76e08bd5",
      "name": "检查错误",
      "type": "n8n-nodes-base.if",
      "position": [
        1320,
        440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "645d85d3-c5cc-4e51-a989-075c0a851449",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": 1
            },
            {
              "id": "b44e6a86-9a9b-4d3e-b9c8-cf75bba8ed03",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "34dfe012-f2b0-4921-aff7-2c97eafc206e",
      "name": "Google Gemini聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1780,
        660
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "typeVersion": 1
    },
    {
      "id": "223f4ef1-2ed0-48e3-a7b6-e2ecb762756f",
      "name": "表单错误",
      "type": "n8n-nodes-base.form",
      "position": [
        1320,
        680
      ],
      "webhookId": "a509f577-231f-435f-b3c2-0fed718f0cc8",
      "parameters": {
        "operation": "completion",
        "respondWith": "showText",
        "responseText": "=Bright Data error for \"{{ $('When User Completes Form').item.json[\"Person Fullname\"] }} \""
      },
      "typeVersion": 1
    },
    {
      "id": "28c124cd-dd4b-4a8d-888e-d39709425920",
      "name": "Google Sheets - 添加帖子和摘要",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2140,
        440
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('When User Completes Form').item.json['Person Fullname'] }}",
            "posts": "={{ $('Code').item.json.posts }}",
            "x_url": "={{ $('Parse X Url').item.json.output[0]['url'] }}",
            "end_date": "={{ $('When User Completes Form').item.json['Analyze Posts To Date'] }}",
            "ai_summary": "={{ $json.text }}",
            "start_date": "={{ $('When User Completes Form').item.json['Analyze Posts From Date'] }}"
          },
          "schema": [
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "start_date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "start_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "end_date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "end_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "x_url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "x_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "posts",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "posts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ai_summary",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ai_summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1V1J7E5EKofN9Uhjg_kItpK0Wjh3Ga_To2k_QYj7hcPA/edit#gid=0",
          "cachedResultName": "results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1V1J7E5EKofN9Uhjg_kItpK0Wjh3Ga_To2k_QYj7hcPA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1V1J7E5EKofN9Uhjg_kItpK0Wjh3Ga_To2k_QYj7hcPA/edit?usp=drivesdk",
          "cachedResultName": "X parsed posts"
        }
      },
      "typeVersion": 4.3,
      "alwaysOutputData": true
    },
    {
      "id": "abc5d30c-2d5c-4186-ac62-32129f33618e",
      "name": "分析帖子",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1760,
        440
      ],
      "parameters": {
        "text": "={{$json}}",
        "messages": {
          "messageValues": [
            {
              "message": "=Analyze these twitter posts - Detect interests, tone, sentiments, common topics, popularity and return summary"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "daee9dbd-c65a-40cf-a84e-b8b9eec4e108",
      "name": "解析 X URL",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        880,
        0
      ],
      "parameters": {
        "text": "={{$('Extract Body and Title from Website').item.json[\"body\"]}}",
        "messages": {
          "messageValues": [
            {
              "message": "=Extract x.com (Twitter) profile from google results. Return a result property with unique parsed result in JSON including a property \"match\" if user matches the data entry values \"{{ $('When User Completes Form').item.json[\"Person Fullname\"].trim() }}\""
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "b0ae5f34-dcd3-424e-b85b-6a339f701857",
      "name": "快照内容",
      "type": "n8n-nodes-brightdata.brightData",
      "position": [
        880,
        440
      ],
      "parameters": {
        "resource": "marketplaceDataset",
        "operation": "getSnapshotContent",
        "snapshot_id": "={{ $('Snapshot Request').item.json.snapshot_id }}"
      },
      "typeVersion": 1
    },
    {
      "id": "d697b7b2-3c50-414e-a4d4-8f5f6f582cf9",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        1540,
        440
      ],
      "parameters": {
        "jsCode": "const input = items[0].json;\nconst posts = input.items || [];\n\nconst extracted = posts.map(post => {\n  const quoted = post.quoted_post || {};\n  const taggedUsers = post.tagged_users || [];\n\n  return {\n    date_posted: post.date_posted || null,\n    description: post.description || null,\n    hashtags: post.hashtags || [],\n    likes: post.likes || null,\n\n    quoted_date_posted: quoted.date_posted || null,\n    quoted_description: quoted.description || null,\n\n    quotes: post.quotes || 0,\n    replies: post.replies || 0,\n    reposts: post.reposts || 0,\n\n    profile_names: taggedUsers.map(user => user.profile_name || null),\n\n    views: post.views || 0,\n  };\n});\n\nreturn [\n  {\n    json: {\n      posts: extracted\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "ba5770f0-db44-4032-bd45-1939b5f2740b",
      "name": "等待 30 秒 - 轮询 Bright Data",
      "type": "n8n-nodes-base.wait",
      "position": [
        220,
        440
      ],
      "webhookId": "8005a2b3-2195-479e-badb-d90e4240e699",
      "parameters": {
        "amount": 30
      },
      "executeOnce": false,
      "typeVersion": 1.1
    },
    {
      "id": "fe2adace-a369-44ef-b048-eb90f309ee92",
      "name": "如果 - 检查快照状态 - 数据是否就绪",
      "type": "n8n-nodes-base.if",
      "position": [
        660,
        440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7932282b-71bb-4bbb-ab73-4978e554de7e",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "ready"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "72326f8d-d381-4620-a3a7-1bed7389a146",
      "name": "快照请求",
      "type": "n8n-nodes-brightdata.brightData",
      "position": [
        0,
        440
      ],
      "parameters": {
        "resource": "marketplaceDataset",
        "operation": "filterDataset",
        "dataset_id": {
          "__rl": true,
          "mode": "list",
          "value": "gd_lwxkxvnf1cynvib9co",
          "cachedResultName": "X (formerly Twitter) - Posts"
        },
        "filter_type": "filters_group",
        "filters_group": "={\"operator\":\"and\",\"filters\":[{\"name\":\"url\",\"operator\":\"includes\",\"value\":\"{{ $json[\"output\"][0]['url'] }}\"},\n{\"name\":\"date_posted\",\"operator\":\">=\",\"value\":\"{{ $('When User Completes Form').item.json[\"Analyze Posts From Date\"] }}\"},\n{\"name\":\"date_posted\",\"operator\":\"<=\",\"value\":\"{{ $('When User Completes Form').item.json[\"Analyze Posts To Date\"] }}\"}]}"
      },
      "typeVersion": 1
    },
    {
      "id": "665656d5-78e4-480c-a472-ade64f43609c",
      "name": "快照进度",
      "type": "n8n-nodes-brightdata.brightData",
      "position": [
        440,
        440
      ],
      "parameters": {
        "resource": "marketplaceDataset",
        "operation": "getSnapshotMetadata",
        "snapshot_id": "={{ $json.snapshot_id }}"
      },
      "typeVersion": 1
    },
    {
      "id": "f346f9b0-f5f0-452e-932f-b27d956e3383",
      "name": "BrightData",
      "type": "n8n-nodes-brightdata.brightData",
      "position": [
        440,
        0
      ],
      "parameters": {
        "url": "={{ $json.google_search }}",
        "zone": {
          "__rl": true,
          "mode": "list",
          "value": "web_unlocker1"
        },
        "format": "json",
        "country": {
          "__rl": true,
          "mode": "list",
          "value": "us"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3fe4b2e8-4cc6-4e23-a2da-c8c668537036",
      "name": "检查错误1",
      "type": "n8n-nodes-base.if",
      "position": [
        1100,
        440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "645d85d3-c5cc-4e51-a989-075c0a851449",
              "operator": {
                "type": "array",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.items}}",
              "rightValue": "Snapshot is building."
            },
            {
              "id": "b44e6a86-9a9b-4d3e-b9c8-cf75bba8ed03",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4b5aa6d7-9328-46fa-b333-6b068c5ffa79",
      "name": "等待 30 秒 - 检查快照是否就绪",
      "type": "n8n-nodes-base.wait",
      "position": [
        880,
        680
      ],
      "webhookId": "8005a2b3-2195-479e-badb-d90e4240e699",
      "parameters": {
        "amount": 30
      },
      "executeOnce": false,
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a93d240e-59b4-49a9-84ce-60fdffc2b48f",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Analyze Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BrightData": {
      "main": [
        [
          {
            "node": "Extract Body and Title from Website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse X Url": {
      "main": [
        [
          {
            "node": "X Profile is Found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Posts": {
      "main": [
        [
          {
            "node": "Google Sheets - Adding Posts and Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Not Found": {
      "main": [
        []
      ]
    },
    "Check for errors": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Form Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Snapshot Content": {
      "main": [
        [
          {
            "node": "Check for errors1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Snapshot Request": {
      "main": [
        [
          {
            "node": "Wait 30s - Polling Bright Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for errors1": {
      "main": [
        [
          {
            "node": "Wait 30s - Check if the snapshot is ready",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check for errors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Snapshot Progress": {
      "main": [
        [
          {
            "node": "If - Checking status of Snapshot - if data is ready or not",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "X Profile is Found?": {
      "main": [
        [
          {
            "node": "Snapshot Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Form Not Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Url Google Search": {
      "main": [
        [
          {
            "node": "BrightData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Parse X Url",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Parse X Url",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When User Completes Form": {
      "main": [
        [
          {
            "node": "Edit Url Google Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Posts",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30s - Polling Bright Data": {
      "main": [
        [
          {
            "node": "Snapshot Progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Body and Title from Website": {
      "main": [
        [
          {
            "node": "Parse X Url",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30s - Check if the snapshot is ready": {
      "main": [
        [
          {
            "node": "Snapshot Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Checking status of Snapshot - if data is ready or not": {
      "main": [
        [
          {
            "node": "Snapshot Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30s - Polling Bright Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 人工智能, 营销

需要付费吗?

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

工作流信息
难度等级
高级
节点数量22
分类2
节点类型12
难度说明

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

外部链接
在 n8n.io 查看

分享此工作流