8
n8n 中文网amn8n.com

Salesforce-Google Sheets 公司同步(智能重复预防)

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 If, Set, Merge, ItemLists, RenameKeys 等节点。 将公司数据从 Google Sheets 同步至 Salesforce,具备智能重复预防

前置要求
  • Salesforce OAuth 凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "ulMkyRjDpdND1gzn",
  "meta": {
    "instanceId": "f450cd0986d5bfb741d4d1b31068440b1642915c91f795fd72913ef923830e67",
    "templateId": "1792"
  },
  "name": "Salesforce-Google Sheets 公司同步(智能重复预防)",
  "tags": [
    {
      "id": "r7X6mNg8b6tE7HbJ",
      "name": "template",
      "createdAt": "2025-09-28T16:07:48.401Z",
      "updatedAt": "2025-09-28T16:07:48.401Z"
    }
  ],
  "nodes": [
    {
      "id": "29451054-fcd6-4054-b072-a87c716f6c67",
      "name": "点击\"执行\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -336,
        -320
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2c1ed019-85f1-4b0f-bcf5-ce59ff13ea49",
      "name": "搜索 Salesforce 客户",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        112,
        -384
      ],
      "parameters": {
        "query": "=SELECT id, Name FROM Account WHERE Name = '{{$json[\"Company Name\"].replace(/'/g, '\\\\\\'')}}'",
        "resource": "search"
      },
      "typeVersion": 1,
      "alwaysOutputData": false
    },
    {
      "id": "7da1de2f-2b37-4e33-b8d4-d1dc59e94bbe",
      "name": "是否找到客户?",
      "type": "n8n-nodes-base.if",
      "position": [
        1152,
        0
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"Id\"] }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "80890a2a-f6d3-4efd-92b1-6465f98f512b",
      "name": "移除重复公司",
      "type": "n8n-nodes-base.itemLists",
      "position": [
        1312,
        -448
      ],
      "parameters": {
        "compare": "selectedFields",
        "options": {},
        "operation": "removeDuplicates",
        "fieldsToCompare": {
          "fields": [
            {
              "fieldName": "Company Name"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ea9afa15-77be-4d7a-a287-35d4c1c6e6c1",
      "name": "为现有客户设置客户 ID",
      "type": "n8n-nodes-base.renameKeys",
      "position": [
        1520,
        -16
      ],
      "parameters": {
        "keys": {
          "key": [
            {
              "newKey": "Account ID",
              "currentKey": "Id"
            }
          ]
        },
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c10dea7c-96b0-4f3b-b859-af094ced51cc",
      "name": "设置新客户名称",
      "type": "n8n-nodes-base.set",
      "position": [
        1760,
        -448
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "id",
              "value": "={{ $json[\"id\"] }}"
            },
            {
              "name": "Name",
              "value": "={{ $node[\"Remove duplicate companies\"].json[\"Company Name\"] }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "id": "a4a2be2a-7bd9-4a70-b4d9-0df53834bdda",
      "name": "创建 Salesforce 客户",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        1536,
        -448
      ],
      "parameters": {
        "name": "={{ $json[\"Company Name\"] }}",
        "resource": "account",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "89f49e6f-62be-403f-9a4c-cd56e28141f3",
      "name": "创建 Salesforce 联系人",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        1840,
        -16
      ],
      "parameters": {
        "lastname": "={{ $json[\"Last Name\"] }}",
        "resource": "contact",
        "operation": "upsert",
        "externalId": "Email",
        "externalIdValue": "={{ $json[\"Email\"] }}",
        "additionalFields": {
          "email": "={{ $json[\"Email\"] }}",
          "firstName": "={{ $json[\"First Name\"] }}",
          "acconuntId": "={{ $json[\"Account ID\"] }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "da75088c-17de-4885-a557-ac2edc84a829",
      "name": "获取表格中的行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -112,
        -320
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "bNNrQVyG0f0LvHLl",
          "name": "xavtwl"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c6af3549-df84-4dcc-9db8-306648e614fe",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -816
      ],
      "parameters": {
        "color": 5,
        "width": 896,
        "height": 704,
        "content": "# 📊 第一部分:数据输入与准备"
      },
      "typeVersion": 1
    },
    {
      "id": "9db710b0-ef7a-4263-8d5e-71c513951835",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -816
      ],
      "parameters": {
        "color": 6,
        "width": 496,
        "height": 704,
        "content": "# 🔄 第二部分:智能路由与重复检测"
      },
      "typeVersion": 1
    },
    {
      "id": "b9d12003-62b6-427e-8cad-15690eb5593c",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        -816
      ],
      "parameters": {
        "color": 4,
        "width": 1168,
        "height": 704,
        "content": "# 🆕 第三部分:新公司处理"
      },
      "typeVersion": 1
    },
    {
      "id": "5c83fdab-2720-4ec2-8b58-70573b61332d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        -96
      ],
      "parameters": {
        "color": 2,
        "width": 1168,
        "height": 848,
        "content": "# ✅ 第四部分:现有公司处理"
      },
      "typeVersion": 1
    },
    {
      "id": "27f3269e-e2ff-4748-88fd-e2ff31fdece5",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -96
      ],
      "parameters": {
        "color": 3,
        "width": 1408,
        "height": 848,
        "content": "# 🎯 Salesforce-Google Sheets 公司同步(智能重复预防)"
      },
      "typeVersion": 1
    },
    {
      "id": "f5516431-c30a-4724-8304-655f718015ff",
      "name": "合并现有客户数据1",
      "type": "n8n-nodes-base.merge",
      "position": [
        336,
        -320
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "Company Name",
              "field2": "Name"
            }
          ]
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "877f4623-a915-4f7d-a5a9-22f2b595fb9d",
      "name": "保留新公司",
      "type": "n8n-nodes-base.merge",
      "position": [
        1088,
        -448
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "joinMode": "keepNonMatches",
        "mergeByFields": {
          "values": [
            {
              "field1": "Company Name",
              "field2": "Name"
            }
          ]
        },
        "outputDataFrom": "input1"
      },
      "typeVersion": 3.2
    },
    {
      "id": "9e0815e5-7bc5-4254-8030-c0527c665569",
      "name": "获取新公司联系人",
      "type": "n8n-nodes-base.merge",
      "position": [
        1984,
        -448
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "Company Name",
              "field2": "Name"
            }
          ]
        }
      },
      "typeVersion": 3.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9ee52df7-3400-445f-94a6-5b34de249b19",
  "connections": {
    "Account found?": {
      "main": [
        [
          {
            "node": "Set Account ID for existing accounts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep new companies": {
      "main": [
        [
          {
            "node": "Remove duplicate companies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Search Salesforce accounts",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge existing account data1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Account found?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Keep new companies",
            "type": "main",
            "index": 0
          },
          {
            "node": "Remove duplicate companies",
            "type": "main",
            "index": 0
          },
          {
            "node": "Retrieve new company contacts",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Salesforce contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set new account name": {
      "main": [
        [
          {
            "node": "Retrieve new company contacts",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "On clicking 'execute'": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Salesforce account": {
      "main": [
        [
          {
            "node": "Set new account name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove duplicate companies": {
      "main": [
        [
          {
            "node": "Create Salesforce account",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Salesforce accounts": {
      "main": [
        [
          {
            "node": "Merge existing account data1",
            "type": "main",
            "index": 1
          },
          {
            "node": "Keep new companies",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge existing account data1": {
      "main": [
        [
          {
            "node": "Account found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve new company contacts": {
      "main": [
        [
          {
            "node": "Create Salesforce contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Account ID for existing accounts": {
      "main": [
        [
          {
            "node": "Create Salesforce contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流