8
n8n 中文网amn8n.com

自动将WhatsApp入站消息记录到Vtiger CRM WALog并与潜在客户关联

中级

这是一个CRM领域的自动化工作流,包含 10 个节点。主要使用 If, Set, Webhook, VtigerNode 等节点。 支持潜在客户关联的Vtiger CRM WhatsApp消息自动记录器

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "o9Vh63HwDIEzugjl",
  "meta": {
    "instanceId": "ea2b41532677d34614d95d13d7d2ccb694657be482144baf71e7140df3b2a853",
    "templateCredsSetupCompleted": true
  },
  "name": "自动将 WhatsApp 入站消息记录到 Vtiger CRM WALog 并与潜在客户关联",
  "tags": [],
  "nodes": [
    {
      "id": "a077146b-6cf8-403a-a7a9-660c96c669ca",
      "name": "按电话搜索潜在客户",
      "type": "n8n-nodes-vtiger-crm.vtigerNode",
      "position": [
        -880,
        16
      ],
      "parameters": {
        "query_field": "={{ `SELECT id FROM Leads WHERE phone='${$json.phone}' OR mobile='${$json.phone}' LIMIT 1;` }}"
      },
      "credentials": {
        "vtigerApi": {
          "id": "GDVMGSZb4YFb0cMz",
          "name": "SaadeddinTestCRM"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "79d838b4-5684-4b74-bc9d-abc323e93e04",
      "name": "创建潜在客户",
      "type": "n8n-nodes-vtiger-crm.vtigerNode",
      "position": [
        -496,
        176
      ],
      "parameters": {
        "operation": "create",
        "element_field": "={ \n\"firstname\": \"-\",\n\"lastname\": \"{{ $('Set: Extract Name, Phone & Message').item.json.custName }}\", \n\"phone\": \"{{ $('Set: Extract Name, Phone & Message').item.json.phone }}\", \n\"assigned_user_id\": \"19x1\"\n}",
        "elementType_field": "Leads"
      },
      "credentials": {
        "vtigerApi": {
          "id": "GDVMGSZb4YFb0cMz",
          "name": "SaadeddinTestCRM"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "56a114e7-0bb4-417e-b49b-58834f4a5d6a",
      "name": "记录到 WhatsAppLog(现有潜在客户)",
      "type": "n8n-nodes-vtiger-crm.vtigerNode",
      "position": [
        -256,
        0
      ],
      "parameters": {
        "operation": "create",
        "element_field": "={ \"cf_1100\": \"{{ $('Set: Extract Name, Phone & Message').item.json.message }}\",\n\"name\": \"{{ $('Set: Extract Name, Phone & Message').item.json.custName }}\",\n\"cf_1098\": \"Inbound\",\n\"cf_1102\": \"{{ $('Set: Extract Name, Phone & Message').item.json.phone }}\",\n\"leadid\": \"{{$json.result[0].id}}\",\n\"assigned_user_id\" : \"19x1\"\n}",
        "elementType_field": "WhatsaAppLog"
      },
      "credentials": {
        "vtigerApi": {
          "id": "GDVMGSZb4YFb0cMz",
          "name": "SaadeddinTestCRM"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "310ab4fd-bfb7-4e78-aa0a-a12b6aafbdf6",
      "name": "无操作,不执行任何动作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -656,
        -176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5af4db56-df2f-4a2a-be70-910748ae6181",
      "name": "Webhook:WhatsApp 监听",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1072,
        -192
      ],
      "webhookId": "cd9a6a33-421b-42d7-84b3-0107157aee30",
      "parameters": {
        "path": "whatsAppListen",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "5f59cb3a-bb09-4335-86d4-3d985729229a",
      "name": "如果消息不是来自群组且不是外发",
      "type": "n8n-nodes-base.if",
      "position": [
        -864,
        -192
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "419382f9-3a23-40ba-afa1-33d71252d2e7",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.data.key.fromMe }}",
              "rightValue": "={{false}}"
            },
            {
              "id": "df484897-bdd3-490f-9902-0b2b51906bd1",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.data.key.remoteJid.includes('@g.us') }}",
              "rightValue": "={{false}}"
            },
            {
              "id": "6d2be59c-30bd-4de3-a36b-720adaa5cbcf",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "fab20986-8189-4595-8dc6-e143456269ef",
      "name": "设置:提取姓名、电话和消息",
      "type": "n8n-nodes-base.set",
      "position": [
        -1056,
        16
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "custName",
              "value": "={{ $json.body.data.pushName }}"
            },
            {
              "name": "phone",
              "value": "={{ $json.body.data.key.remoteJid.replace('@s.whatsapp.net', '') }}"
            },
            {
              "name": "message",
              "value": "={{ $json.body.data.message.conversation }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 2
    },
    {
      "id": "9eb85375-ae60-4b3f-97ad-708fbadf76c2",
      "name": "如果潜在客户存在",
      "type": "n8n-nodes-base.if",
      "position": [
        -656,
        16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ee868d62-2dcd-4628-8cae-6ee6f673c5b3",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.result[0].id || '' }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6b49bc90-75ab-44bb-b204-7ec0e4e096ff",
      "name": "记录到 WhatsAppLog(新潜在客户)",
      "type": "n8n-nodes-vtiger-crm.vtigerNode",
      "position": [
        -256,
        176
      ],
      "parameters": {
        "operation": "create",
        "element_field": "={ \"cf_1100\": \"{{ $('Set: Extract Name, Phone & Message').item.json.message }}\",\n\"name\": \"{{ $('Set: Extract Name, Phone & Message').item.json.custName }}\",\n\"cf_1098\": \"Inbound\",\n\"cf_1102\": \"{{ $('Set: Extract Name, Phone & Message').item.json.phone }}\",\n\"leadid\": \"{{ $json.result.id }}\",\n\"assigned_user_id\" : \"19x1\"\n}",
        "elementType_field": "WhatsaAppLog"
      },
      "credentials": {
        "vtigerApi": {
          "id": "GDVMGSZb4YFb0cMz",
          "name": "SaadeddinTestCRM"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "77633b01-34f1-4abd-9183-f9d9a20c0eb5",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        -160
      ],
      "parameters": {
        "width": 336,
        "height": 448,
        "content": "## 摘要"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5d737057-8452-4fca-97bc-7685a15b14c7",
  "connections": {
    "Create Lead": {
      "main": [
        [
          {
            "node": "Log to WhatsAppLog (New Lead)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Lead existing": {
      "main": [
        [
          {
            "node": "Log to WhatsAppLog (Existing Lead)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Lead by Phone": {
      "main": [
        [
          {
            "node": "If Lead existing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook: WhatsApp Listen": {
      "main": [
        [
          {
            "node": "If message not from group and not outbound",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to WhatsAppLog (Existing Lead)": {
      "main": [
        []
      ]
    },
    "Set: Extract Name, Phone & Message": {
      "main": [
        [
          {
            "node": "Search Lead by Phone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If message not from group and not outbound": {
      "main": [
        [
          {
            "node": "Set: Extract Name, Phone & Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 客户关系管理

需要付费吗?

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

工作流信息
难度等级
中级
节点数量10
分类1
节点类型6
难度说明

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

作者
Ahmed Saadawi

Ahmed Saadawi

@ahmedsaadawi

CRM consultant and automation expert with 15+ years of experience building AI-powered, no-code workflows for sales, support, and operations. Open to collaboration or custom solutions — let’s connect!

外部链接
在 n8n.io 查看

分享此工作流