8
n8n 中文网amn8n.com

WooCommerce订单完成的WhatsApp评价请求自动化

中级

这是一个Lead Nurturing领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Wait, HttpRequest, GoogleSheets 等节点。 使用Rapiwa通过WhatsApp为完成的WooCommerce订单自动化评价请求

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Js65R7HMdXB4DZf7",
  "meta": {
    "instanceId": "cb9a1e5321767b6316634728341237e564b2587ab15b74ca0a89eb02a53484d6",
    "templateCredsSetupCompleted": true
  },
  "name": "WooCommerce 订单完成的 WhatsApp 评价请求自动化",
  "tags": [],
  "nodes": [
    {
      "id": "4a8c635d-bd1c-45da-acea-ea28e8a691b0",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        240,
        880
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3ab8725a-9268-45fd-b91c-0e055fe6fa7c",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.exists }}",
              "rightValue": "=\"true\""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a88cec50-2e45-41b0-bcbb-01bcb92a7f79",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        720,
        976
      ],
      "webhookId": "6c474e54-eb3c-4fcd-b455-948322cd0121",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "2e326749-0efb-4968-9ee9-776a9a94ccf2",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -752,
        864
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "32af40bb-fee1-495a-9ff0-290837b24acd",
      "name": "清理 WhatsApp 号码",
      "type": "n8n-nodes-base.code",
      "position": [
        -464,
        880
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst updatedItems = items.map((item) => {\n  let rawNumber = item?.json[\"number\"];\n  rawNumber = rawNumber ? String(rawNumber) : \"\";\n  const cleanedNumber = rawNumber.replace(/\\D/g, \"\");\n  item.json[\"number\"] = cleanedNumber;\n  return item;\n});\nreturn updatedItems;"
      },
      "typeVersion": 2
    },
    {
      "id": "81018417-302a-49a8-a7c6-4d11be0de2b0",
      "name": "订单完成检查",
      "type": "n8n-nodes-base.code",
      "position": [
        -1008,
        864
      ],
      "parameters": {
        "jsCode": "return $input.all()\n  .filter(item => item.json && item.json.body && item.json.body.status === \"completed\")\n  .map(item => {\n    const body = item.json.body;\n\n    const customer = {\n      first_name: body.billing.first_name,\n      last_name: body.billing.last_name,\n      email: body.billing.email,\n      phone: body.billing.phone,\n      address: {\n        address_1: body.billing.address_1,\n        address_2: body.billing.address_2,\n        city: body.billing.city,\n        state: body.billing.state,\n        postcode: body.billing.postcode,\n        country: body.billing.country\n      }\n    };\n\n    const products = body.line_items.map(product => ({\n      status: body.status,\n      name: product.name,\n      size: product.meta_data?.find(meta => meta.key === \"size\")?.value,\n      product_id: product.product_id,\n      variation_id: product.variation_id,\n      quantity: product.quantity,\n      price: `${body.currency} ${product.price}`,\n      total: `${body.currency} ${product.total}`,\n      image: product.image?.src || null\n    }));\n\n    return {\n      json: {\n        data: {\n          customer,\n          products,\n          invoice_link: body.payment_url\n        }\n      }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "db7f5615-1981-4e62-a47b-e338eaed8eb5",
      "name": "使用 Rapiwa 检查有效的 WhatsApp 号码",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -224,
        880
      ],
      "parameters": {
        "url": "=https://app.rapiwa.com/api/verify-whatsapp",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $json.data.customer.phone }}"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "jnaHCyYia9OAFozh",
          "name": "Rapiwa Bearer YOUR_TOKEN_HERE"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2cb4272f-3315-4767-9f7c-626d4d9b62aa",
      "name": "在已验证和已发送中保存行状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        704,
        768
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Clean WhatsApp Number').item.json.data.customer.first_name }} {{ $('Clean WhatsApp Number').item.json.data.customer.last_name }}",
            "email": "={{ $('Clean WhatsApp Number').item.json.data.customer.email }}",
            "number": "={{ $json.to }}",
            "status": "sent",
            "address1": "={{ $('Clean WhatsApp Number').item.json.data.customer.address.address_1 }}",
            "validity": "verified",
            "productId": "={{ $('Clean WhatsApp Number').item.json.data.products[0].product_id }}",
            "totalPrice": "={{ $('Clean WhatsApp Number').item.json.data.products[0].total }}",
            "invoiceLink": "={{ $('Clean WhatsApp Number').item.json.data.invoice_link }}",
            "productTitle": "={{ $('Clean WhatsApp Number').item.json.data.products[0].name }}",
            "delivery status": "={{ $('Clean WhatsApp Number').item.json.data.products[0].status }}"
          },
          "schema": [
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "productTitle",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "productTitle",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "productId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "productId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "totalPrice",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "totalPrice",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoiceLink",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "invoiceLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "delivery status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "delivery status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "validity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "validity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "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/1S3RtGt5tGk2sLLm9XQTI9C1C0bq2jx3TNuGQnXmQi_s/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1S3RtGt5tGk2sLLm9XQTI9C1C0bq2jx3TNuGQnXmQi_s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1S3RtGt5tGk2sLLm9XQTI9C1C0bq2jx3TNuGQnXmQi_s/edit?usp=drivesdk",
          "cachedResultName": "WooCommerce - Send WhatsApp review request"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gFH3Wjq6yYqSEAei",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "8f9428de-1801-4c1f-8925-ff551f867e86",
      "name": "在未验证和未发送中保存行状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        976
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Clean WhatsApp Number').item.json.data.customer.first_name }} {{ $('Clean WhatsApp Number').item.json.data.customer.last_name }}",
            "email": "={{ $('Clean WhatsApp Number').item.json.data.customer.email }}",
            "number": "={{ $json.data.number }}",
            "status": "not sent",
            "address1": "={{ $('Clean WhatsApp Number').item.json.data.customer.address.address_1 }}",
            "validity": "unverified",
            "productId": "={{ $('Clean WhatsApp Number').item.json.data.products[0].product_id }}",
            "totalPrice": "={{ $('Clean WhatsApp Number').item.json.data.products[0].total }}",
            "invoiceLink": "={{ $('Clean WhatsApp Number').item.json.data.invoice_link }}",
            "productTitle": "={{ $('Clean WhatsApp Number').item.json.data.products[0].name }}",
            "delivery status": "={{ $('Clean WhatsApp Number').item.json.data.products[0].status }}"
          },
          "schema": [
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "productTitle",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "productTitle",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "productId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "productId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "totalPrice",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "totalPrice",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoiceLink",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoiceLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "delivery status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "delivery status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "validity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "validity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "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/1S3RtGt5tGk2sLLm9XQTI9C1C0bq2jx3TNuGQnXmQi_s/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1S3RtGt5tGk2sLLm9XQTI9C1C0bq2jx3TNuGQnXmQi_s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1S3RtGt5tGk2sLLm9XQTI9C1C0bq2jx3TNuGQnXmQi_s/edit?usp=drivesdk",
          "cachedResultName": "WooCommerce - Send WhatsApp review request"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gFH3Wjq6yYqSEAei",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "9eca8980-0e80-4320-be26-3d0dbfa38b80",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2848,
        144
      ],
      "parameters": {
        "width": 1504,
        "height": 1456,
        "content": "# WooCommerce 订单完成的 WhatsApp 评价请求自动化"
      },
      "typeVersion": 1
    },
    {
      "id": "643d4ac7-f4bc-41ed-9c99-6187c780abdb",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        592
      ],
      "parameters": {
        "width": 448,
        "height": 608,
        "content": "## WooCommerce 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "0bddd8a0-c5a9-45d8-ac3b-2a7f636244d3",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        464
      ],
      "parameters": {
        "width": 544,
        "height": 736,
        "content": "## 清理 WhatsApp 号码(代码)"
      },
      "typeVersion": 1
    },
    {
      "id": "fc9e8191-cdbd-479d-aae2-c28bf6012920",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        176
      ],
      "parameters": {
        "width": 1184,
        "height": 1024,
        "content": "## IF"
      },
      "typeVersion": 1
    },
    {
      "id": "c7ada026-0c4f-43f3-9409-174e6be7ae57",
      "name": "WooCommerce 触发器",
      "type": "n8n-nodes-base.wooCommerceTrigger",
      "position": [
        -1200,
        864
      ],
      "webhookId": "5530612b-221d-4418-9a9a-ffbe24957be7",
      "parameters": {
        "event": "order.updated"
      },
      "credentials": {
        "wooCommerceApi": {
          "id": "BZ5Lp9IB4Phney4R",
          "name": "WooCommerce (get customer)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6fa57d94-c9f3-4393-9bb0-7eaafda21dd6",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1296,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 1232,
        "height": 288,
        "content": "# 此工作流摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "04ae8f98-278b-4a99-a0d4-5324d63e1874",
      "name": "使用 Rapiwa API 发送消息",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        480,
        768
      ],
      "parameters": {
        "url": "=https://app.rapiwa.com/api/send-message",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $json.data.number }}"
            },
            {
              "name": "message_type",
              "value": "text"
            },
            {
              "name": "message",
              "value": "=Hi *{{ $('Clean WhatsApp Number').item.json.data.customer.first_name }} {{ $('Clean WhatsApp Number').item.json.data.customer.last_name }}*,\n\nYour order is currently: *{{ $('Clean WhatsApp Number').item.json.data.products[0].status }}*\n\nYour order has been successfully delivered!\n\nWe’d love to hear your thoughts.\nPlease take a moment to leave a review — your feedback helps us grow and improve!\n\nThanks for shopping with *SpaGreen Creative*!  \nLet us know if you need anything."
            }
          ]
        },
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "jnaHCyYia9OAFozh",
          "name": "Rapiwa Bearer YOUR_TOKEN_HERE"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3d8c3548-dd9c-4db9-b46a-5b7a537fbe40",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send Message Using Rapiwa API",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save State of Rows in Unerified & Not sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Clean WhatsApp Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WooCommerce Trigger": {
      "main": [
        [
          {
            "node": "Order Completed check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean WhatsApp Number": {
      "main": [
        [
          {
            "node": "Check valid whatsapp number Using Rapiwa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Completed check": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Message Using Rapiwa API": {
      "main": [
        [
          {
            "node": "Save State of Rows in Verified & Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save State of Rows in Verified & Sent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check valid whatsapp number Using Rapiwa": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save State of Rows in Unerified & Not sent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 客户培育

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流