8
n8n 中文网amn8n.com

将Google Maps评论同步到Google表格

高级

这是一个Market Research, Miscellaneous, Multimodal AI领域的自动化工作流,包含 22 个节点。主要使用 If, Set, Code, Switch, SplitOut 等节点。 使用SerpApi的Google Maps评论到Google表格同步

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "SyvBl5gLjnsRxFno",
  "meta": {
    "instanceId": "886f6aad18962318bf6e0e61dcc99fe4272655356eb72558c67fde0caf721bc9",
    "templateCredsSetupCompleted": true
  },
  "name": "将 Google 地图评论同步到 Google 表格,适用于任何 Google 地图查询",
  "tags": [],
  "nodes": [
    {
      "id": "0deb227f-1199-4aef-ac8e-a4db53985e77",
      "name": "If - 本地或地点结果",
      "type": "n8n-nodes-base.if",
      "position": [
        4060,
        1540
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f6df7b90-96e1-4e80-8539-cf4bbab719db",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.place_results }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "867b0ef5-cb51-468e-a4a9-957b2809a589",
      "name": "拆分本地结果",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        4340,
        1780
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "local_results"
      },
      "typeVersion": 1
    },
    {
      "id": "cdd460e6-2fbc-446f-bae5-2759e31ce68f",
      "name": "循环处理地点",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        4600,
        1780
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "2dfe9fa5-981c-4842-b100-d8e163961baa",
      "name": "搜索 Google 地图",
      "type": "n8n-nodes-serpapi.serpApi",
      "position": [
        3820,
        1540
      ],
      "parameters": {
        "q": "italian restaurants in austin tx",
        "operation": "google_maps",
        "requestOptions": {},
        "additionalFields": {
          "json_restrictor": "local_results,place_results"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "72e14880-b142-4afc-bb2d-faa88584c915",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4300,
        1780
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 320,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "7221f8cd-722a-4036-9431-8528268ce6fb",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3780,
        1140
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 560,
        "content": "## 在 Google 地图上查找地点"
      },
      "typeVersion": 1
    },
    {
      "id": "a3554de2-cf47-4364-9e01-48c80cdf09ca",
      "name": "更新评论计数和下一页令牌",
      "type": "n8n-nodes-base.code",
      "position": [
        5600,
        1440
      ],
      "parameters": {
        "jsCode": "// Get the global static data object\nconst data = $getWorkflowStaticData('global');\n\ndata.count += $('Get Reviews').first().json.reviews.length;\n\nif (!!$('Get Reviews').first().json.serpapi_pagination) {\n  data.next_page_token = $('Get Reviews').first().json.serpapi_pagination.next_page_token\n}\n\nreturn data;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9c1b7cd3-b528-4163-a686-f3ad4dd96373",
      "name": "设置分页编号",
      "type": "n8n-nodes-base.code",
      "position": [
        6140,
        1240
      ],
      "parameters": {
        "jsCode": "// Get the global static data object\nconst data = $getWorkflowStaticData('global');\n\ndata.num = 20;\n\nreturn data;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "45bfe23c-41f0-4596-8295-9ce4bc42c27e",
      "name": "路由下一步",
      "type": "n8n-nodes-base.switch",
      "position": [
        5860,
        1440
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Get More Pages",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d128590f-c232-494d-b379-607736dc31c1",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !!$json.next_page_token && ($json.review_limit > $json.count + 20)}}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "End Workflow",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3d4d7947-ca15-4409-8629-45bc0af39fe8",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.is_single_business && (!$json.next_page_token || $json.review_limit < $json.count + 20 ) }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Get Next Place",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f6f60b0f-55dc-480f-ad07-77bd617b7334",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !$json.is_single_business && (!$json.next_page_token || $json.review_limit < $json.count + 20 ) }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "30a54c94-1826-4412-a2cb-5e07b0eeeee7",
      "name": "追加评论",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        5320,
        1440
      ],
      "parameters": {
        "columns": {
          "value": {
            "rating": "={{ $json.reviews.rating }}",
            "snippet": "={{ $json.reviews.extracted_snippet.original }}",
            "iso_date": "={{ $json.reviews.iso_date }}",
            "place_name": "={{ $('Initialize Vars').first().json.place_name }}"
          },
          "schema": [
            {
              "id": "place_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "place_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "iso_date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "iso_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "snippet",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "snippet",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "useAppend": true
        },
        "operation": "append",
        "sheetName": {},
        "documentId": {}
      },
      "typeVersion": 4.5
    },
    {
      "id": "5e1afade-a5ef-4232-a8dc-3afb7a971f28",
      "name": "拆分评论",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        5080,
        1440
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "reviews",
        "fieldsToInclude": "place_info.title"
      },
      "typeVersion": 1
    },
    {
      "id": "4e1aedd8-c4e5-44a0-a28a-7752f16cfb0e",
      "name": "如果存在评论",
      "type": "n8n-nodes-base.if",
      "position": [
        4840,
        1460
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a303ad79-5e85-4782-a328-1eb2b3a42f35",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ !!$json.reviews || $('Initialize Vars').item.json.is_single_business}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d4ab1a92-1492-4a89-8c9b-86edcbd3ea72",
      "name": "获取评论",
      "type": "n8n-nodes-serpapi.serpApi",
      "position": [
        4580,
        1460
      ],
      "parameters": {
        "place_id": "={{ $json.place_id }}",
        "operation": "google_maps_reviews",
        "requestOptions": {},
        "additionalFields": {
          "num": "={{ $json.num }}",
          "next_page_token": "={{ $json.next_page_token }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5926cd59-f490-4d42-9832-c2f05a3ea4c5",
      "name": "执行工作流",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        3360,
        1540
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3eff82f5-e399-40f8-8b46-b383f22287d3",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4240,
        1140
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 560,
        "content": "## 初始化变量"
      },
      "typeVersion": 1
    },
    {
      "id": "751033b8-2f34-4f57-be82-c91633ed143b",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4540,
        1140
      ],
      "parameters": {
        "color": 7,
        "width": 440,
        "height": 480,
        "content": "## 获取评论"
      },
      "typeVersion": 1
    },
    {
      "id": "0ded93ff-5973-42d8-a1d1-0e4132c47ac8",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5020,
        1140
      ],
      "parameters": {
        "color": 7,
        "width": 440,
        "height": 480,
        "content": "## 将评论添加到 Google 表格"
      },
      "typeVersion": 1
    },
    {
      "id": "1ed58029-fec3-496d-bc0b-3444ff1fea29",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5500,
        1140
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 480,
        "content": "## 路由下一步"
      },
      "typeVersion": 1
    },
    {
      "id": "b413476d-dd5a-46b4-aa80-ebbf1e094b79",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2660,
        1080
      ],
      "parameters": {
        "width": 660,
        "height": 1100,
        "content": "## 将 Google 地图评论同步到 Google 表格,适用于任何 Google 地图查询"
      },
      "typeVersion": 1
    },
    {
      "id": "a1de7c43-2b8d-48bb-8554-30d76dfe3207",
      "name": "Set Review Limit",
      "type": "n8n-nodes-base.set",
      "position": [
        3580,
        1540
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b8a2d158-d09e-41e4-9ce0-55096e55a840",
              "name": "review_limit",
              "type": "number",
              "value": 50
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e13ab771-0cce-427c-826b-2e8a83bbfd9a",
      "name": "Initialize Vars",
      "type": "n8n-nodes-base.code",
      "position": [
        4320,
        1460
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\ndata.review_limit = $('Set Review Limit').first().json.review_limit;\ndata.place_id = $input.first().json.place_id ||$input.first().json.place_results.place_id;\ndata.place_name = $input.first().json.title || $input.first().json.place_results.title;\ndata.is_single_business = !!$input.first().json.place_results ? true : false;\ndata.num = null;\ndata.count = 0;\ndata.next_page_token = null;\n\nreturn data;"
      },
      "typeVersion": 2
    },
    {
      "id": "7291f010-f211-474c-a5be-c7b2f55f9486",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3500,
        1140
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 560,
        "content": "## Update Review Limit\n\nYou can update the review limit here to customize the maximum reviews to fetch per place. Default limit is 50 reviews per place."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0da2918a-3686-47b2-8468-c67375215a78",
  "connections": {
    "Get Reviews": {
      "main": [
        [
          {
            "node": "If Reviews Present",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Reviews": {
      "main": [
        [
          {
            "node": "Append Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Reviews": {
      "main": [
        [
          {
            "node": "Update Review Count & Next Page Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initialize Vars": {
      "main": [
        [
          {
            "node": "Get Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Next Step": {
      "main": [
        [
          {
            "node": "Set num for Pagination",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [
          {
            "node": "Loop Over Places",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow": {
      "main": [
        [
          {
            "node": "Set Review Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Places": {
      "main": [
        [],
        [
          {
            "node": "Initialize Vars",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Review Limit": {
      "main": [
        [
          {
            "node": "Search Google Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Reviews Present": {
      "main": [
        [
          {
            "node": "Split Reviews",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Places",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Google Maps": {
      "main": [
        [
          {
            "node": "If - Local or Place Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Local Results": {
      "main": [
        [
          {
            "node": "Loop Over Places",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set num for Pagination": {
      "main": [
        [
          {
            "node": "Get Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Local or Place Results": {
      "main": [
        [
          {
            "node": "Initialize Vars",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Split Local Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Review Count & Next Page Token": {
      "main": [
        [
          {
            "node": "Route Next Step",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 市场调研, 杂项, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流