8
n8n 中文网amn8n.com

模板 - Google 评论分析

中级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 14 个节点。主要使用 If, Code, HttpRequest, GoogleSheets, ManualTrigger 等节点。 使用 SerpAPI、GPT-4 和 Google Sheets 分析与总结 Google 评论

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "pRW5xgECkynFHaUx",
  "meta": {
    "instanceId": "a9966e7d53853abbaaeed78ba2b9971c959f5792b2cccdff75eb461951503a7f",
    "templateCredsSetupCompleted": true
  },
  "name": "模板 - gmbr google 评论",
  "tags": [],
  "nodes": [
    {
      "id": "29631d28-1dbb-419b-979e-afd26420e020",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -960,
        -420
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "eeba4db4-59cf-4985-9331-67bfdef3b5cb",
      "name": "如果评论文本不为空",
      "type": "n8n-nodes-base.if",
      "position": [
        40,
        -420
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2b60b7e3-29e9-48a3-8b97-badb7dd247c3",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.reviewText }}",
              "rightValue": "={{ $json.restaurant }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "633b7ddf-416d-40cb-b3ec-bf5dd4ec50de",
      "name": "分析评论情感",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        460,
        -500
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-turbo",
          "cachedResultName": "GPT-4-TURBO"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Analyze the following restaurant review for the restaurant \"{{ $json.restaurant }}\".\n\n1. What is the sentiment (positive, neutral, or negative)?\n2. Extract 3–5 keywords or themes from the review.\n\nReview: {{ $json.reviewText }}\nInclude Restaraunt: {{ $json.restaurant }}\n\nRespond only in JSON format like:\n{\n  \"sentiment\": \"...\",\n  \"keywords\": [\"...\", \"...\", \"...\"]\n  \"restaraunt\": \"...\"\n}\n"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "niPVUMBH1mYOAFdj",
          "name": "OpenAi account 3"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "cef1af19-e7d0-4c50-8afd-dcb41547e5df",
      "name": "获取数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -460,
        -420
      ],
      "parameters": {
        "url": "https://serpapi.com/search.json",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "engine",
              "value": "google_maps"
            },
            {
              "name": "type",
              "value": "search"
            },
            {
              "name": "q",
              "value": "={{ $json['Restaraunt Name'] }}"
            },
            {
              "name": "api_key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7624572b-1abb-4dc9-958d-87648b09aead",
      "name": "清理数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -220,
        -420
      ],
      "parameters": {
        "jsCode": "return $input.all().flatMap(item => {\n  // Check if 'place_results' exists on the item.json object\n  const placeResults = item.json.place_results;\n\n  if (!placeResults) {\n    console.log(\"No 'place_results' found for item.\");\n    return [];\n  }\n\n  const restaurant = placeResults.title || \"Unknown\";\n  const reviews = placeResults.user_reviews?.most_relevant; // Accessing the correct path for reviews\n\n  // Check if 'reviews' is an array\n  if (!Array.isArray(reviews)) {\n    console.log(\"No 'most_relevant' reviews array found for:\", restaurant);\n    return [];\n  }\n\n  return reviews.slice(0, 10).map(review => ({\n    json: {\n      restaurant,\n      reviewText: review.description || \"\", // Changed from review.snippet to review.description\n      stars: review.rating || null,\n      postedAt: review.date || \"\"\n    }\n  }));\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "dedec6f9-535d-4832-81ea-de026d5b30d7",
      "name": "拉取示例餐厅",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -720,
        -420
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w/edit#gid=0",
          "cachedResultName": "sample restaraunts"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w/edit?usp=drivesdk",
          "cachedResultName": "GMBR: list of restaraunts "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "646p89nKZeX7dMwz",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "b67023fc-f21c-4871-8a26-03a43fe4b35c",
      "name": "导出数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        820,
        -500
      ],
      "parameters": {
        "columns": {
          "value": {
            "Stars": "={{ $('Cleans It Up').item.json.stars }}",
            "Analysis": "={{ $json.message.content }}",
            "Restaraunt": "={{ $('Cleans It Up').item.json.restaurant }}",
            "Review Text": "={{ $('Cleans It Up').item.json.reviewText }}"
          },
          "schema": [
            {
              "id": "Restaraunt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Restaraunt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Review Text",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Review Text",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Stars",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Stars",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Analysis",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Analysis",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1346480145,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w/edit#gid=1346480145",
          "cachedResultName": "table"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w/edit?usp=drivesdk",
          "cachedResultName": "GMBR: list of restaraunts "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "646p89nKZeX7dMwz",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "f8ad050b-99f8-4d4d-b42a-4dd2a76aeb97",
      "name": "失败的评论(例如,评论文本为空)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        -240
      ],
      "parameters": {
        "columns": {
          "value": {
            "Stars": "={{ $json.stars }}",
            "Keywords": "Skipped (no reviewText)",
            "Sentiment": "Skipped (no reviewText)",
            "Restaraunt": "={{ $json.restaurant }}",
            "Review Text": "={{ $json.reviewText }}"
          },
          "schema": [
            {
              "id": "Restaraunt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Restaraunt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Review Text",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Review Text",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Stars",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Stars",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Sentiment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Sentiment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Keywords",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Keywords",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1253412439,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w/edit#gid=1253412439",
          "cachedResultName": "skipped reviews"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mJRBu96urKkUAUMz1chcipgKlqw6UhKcSLzF0xp_D6w/edit?usp=drivesdk",
          "cachedResultName": "GMBR: list of restaraunts "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "646p89nKZeX7dMwz",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "281659ab-03e9-4ada-8f23-d35389f5909e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1560,
        -800
      ],
      "parameters": {
        "width": 460,
        "height": 980,
        "content": "## 试试看!"
      },
      "typeVersion": 1
    },
    {
      "id": "e3c1e3a8-905c-4fae-8ea7-b02a306d7139",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -700
      ],
      "parameters": {
        "width": 500,
        "height": 760,
        "content": "## 1. 抓取 Google Maps 商家列表"
      },
      "typeVersion": 1
    },
    {
      "id": "34ca561c-8b25-422c-bdca-c296ed1bdb30",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -700
      ],
      "parameters": {
        "width": 500,
        "height": 760,
        "content": "## 2. 清理数据并识别差距"
      },
      "typeVersion": 1
    },
    {
      "id": "e10d0516-893e-48e5-a864-faba09ea2381",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -700
      ],
      "parameters": {
        "width": 520,
        "height": 760,
        "content": "## 3. 分析与导出"
      },
      "typeVersion": 1
    },
    {
      "id": "17d4fe34-5930-4d5e-b7e0-0e57e86c8f82",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -1100
      ],
      "parameters": {
        "width": 580,
        "height": 320,
        "content": "## 步骤 1 -> 示例输入"
      },
      "typeVersion": 1
    },
    {
      "id": "ccdc7228-ba6c-4194-90e4-93273c4d4e4f",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1060,
        -700
      ],
      "parameters": {
        "width": 660,
        "height": 360,
        "content": "## 步骤 3 -> 示例输出"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1cb71d95-1b82-487d-97b5-12c38d4afb20",
  "connections": {
    "Get Data": {
      "main": [
        [
          {
            "node": "Cleans It Up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export Data": {
      "main": [
        []
      ]
    },
    "Cleans It Up": {
      "main": [
        [
          {
            "node": "If review text is NOT empty ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Review Sentiment": {
      "main": [
        [
          {
            "node": "Export Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Sample Restaurants ": {
      "main": [
        [
          {
            "node": "Get Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If review text is NOT empty ": {
      "main": [
        [
          {
            "node": "Analyze Review Sentiment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failed Reviews (e.g. review text = empty)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Pull Sample Restaurants ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研, AI 摘要总结

需要付费吗?

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

工作流信息
难度等级
中级
节点数量14
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流