8
n8n 中文网amn8n.com

通过WhatsApp向客户发送WooCommerce订单状态更新

中级

这是一个Support Chatbot领域的自动化工作流,包含 14 个节点。主要使用 If, Code, Wait, Webhook, HttpRequest 等节点。 使用Rapiwa API通过WhatsApp向客户发送WooCommerce订单更新

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "weZ2L2zuYZi2oWKR",
  "meta": {
    "instanceId": "cb9a1e5321767b6316634728341237e564b2587ab15b74ca0a89eb02a53484d6"
  },
  "name": "使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 订单状态更新",
  "tags": [],
  "nodes": [
    {
      "id": "6754e15c-7fa5-402a-b425-9fc9e12ee764",
      "name": "Rapiwa 发送器",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        720,
        848
      ],
      "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\n🛍️ *{{ $('Clean WhatsApp Number').item.json.data.products[0].name }}*  \n• Size: {{ $('Clean WhatsApp Number').item.json.data.products[0].size }}\n• Qty: {{ $('Clean WhatsApp Number').item.json.data.products[0].quantity }}\n• Price: {{ $('Clean WhatsApp Number').item.json.data.products[0].price }}\n• Total: {{ $('Clean WhatsApp Number').item.json.data.products[0].total }}\n*Shipping to:*{{ $('Clean WhatsApp Number').item.json.data.customer.address.address_1 }}*\n\n🖼️ Product Preview: {{ $('Clean WhatsApp Number').item.json.data.products[0].image }}\n🧾 View Invoice: {{ $('Clean WhatsApp Number').item.json.data.invoice_link }}\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
    },
    {
      "id": "8fa0a1db-d6d4-420e-a7d3-e7eab8b050fd",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        480,
        960
      ],
      "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": "d5efa97f-454d-4661-865c-8432481c0627",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        960,
        1056
      ],
      "webhookId": "6c474e54-eb3c-4fcd-b455-948322cd0121",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "10f7dc66-1e40-4b8a-aa0b-8a2f38a4c44b",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -384,
        944
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0d1fa192-0b73-4960-b2a7-048516d7a4ac",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -816,
        944
      ],
      "webhookId": "4746f380-002d-494d-90fe-7c963bd7a67b",
      "parameters": {
        "path": "4746f380-002d-494d-90fe-7c963bd7a67b",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "7238793c-df4c-496a-8c7f-b3c98dd0c5f6",
      "name": "使用 Rapiwa 检查有效的 WhatsApp 号码",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        112,
        960
      ],
      "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": "28386518-8878-4821-bd56-8ccf8c4acc00",
      "name": "格式化 Webhook 响应数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -624,
        944
      ],
      "parameters": {
        "jsCode": "return $input.all().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": "d852312f-b45c-4ce5-9671-e4c8c7cabc36",
      "name": "清理 WhatsApp 号码",
      "type": "n8n-nodes-base.code",
      "position": [
        -96,
        960
      ],
      "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": "b492da98-bae3-4140-bced-c7efe4b06f7f",
      "name": "在已验证和已发送中存储行状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        944,
        848
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Clean WhatsApp Number').item.json.data.customer.first_name }} {{ $('Clean WhatsApp Number').item.json.data.customer.last_name }}",
            "size": "={{ $('Clean WhatsApp Number').item.json.data.products[0].size }}",
            "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 }}",
            "quantity": "={{ $('Clean WhatsApp Number').item.json.data.products[0].quantity }}",
            "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 }}",
            "productImage": "={{ $('Clean WhatsApp Number').item.json.data.products[0].image }}",
            "productTitle": "={{ $('Clean WhatsApp Number').item.json.data.products[0].name }}",
            "product 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": "size",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "size",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "quantity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "quantity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "totalPrice",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "totalPrice",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "productImage",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "productImage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoiceLink",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "invoiceLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "product status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "product 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/1WKOFqFdF3tqfes5KKO1WGAp20SpO3jJl9GsE9CmtfLI/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1WKOFqFdF3tqfes5KKO1WGAp20SpO3jJl9GsE9CmtfLI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1WKOFqFdF3tqfes5KKO1WGAp20SpO3jJl9GsE9CmtfLI/edit?usp=drivesdk",
          "cachedResultName": "WooCommerce - Send WhatsApp update to customer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gFH3Wjq6yYqSEAei",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a286ee00-45ea-4fff-83ff-c1fd72f79778",
      "name": "在未验证和未发送中存储行状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        720,
        1056
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Clean WhatsApp Number').item.json.data.customer.first_name }} {{ $('Clean WhatsApp Number').item.json.data.customer.last_name }}",
            "size": "={{ $('Clean WhatsApp Number').item.json.data.products[0].size }}",
            "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 }}",
            "quantity": "={{ $('Clean WhatsApp Number').item.json.data.products[0].quantity }}",
            "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 }}",
            "productImage": "={{ $('Clean WhatsApp Number').item.json.data.products[0].image }}",
            "productTitle": "={{ $('Clean WhatsApp Number').item.json.data.products[0].name }}",
            "product 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": "size",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "size",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "quantity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "quantity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "totalPrice",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "totalPrice",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "productImage",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "productImage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoiceLink",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoiceLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "product status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "product 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/1WKOFqFdF3tqfes5KKO1WGAp20SpO3jJl9GsE9CmtfLI/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1WKOFqFdF3tqfes5KKO1WGAp20SpO3jJl9GsE9CmtfLI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1WKOFqFdF3tqfes5KKO1WGAp20SpO3jJl9GsE9CmtfLI/edit?usp=drivesdk",
          "cachedResultName": "WooCommerce - Send WhatsApp update to customer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gFH3Wjq6yYqSEAei",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "b16d300c-0e2a-4a25-af34-ae2db0f1b201",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1904,
        496
      ],
      "parameters": {
        "width": 896,
        "height": 1360,
        "content": "# 使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 订单状态更新"
      },
      "typeVersion": 1
    },
    {
      "id": "b5196501-b7a3-403b-8608-32051a41c1b1",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        496
      ],
      "parameters": {
        "width": 496,
        "height": 784,
        "content": "## 1. Webhook"
      },
      "typeVersion": 1
    },
    {
      "id": "7e7d4967-f95e-4f84-b778-7d37bb4d78c1",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        640
      ],
      "parameters": {
        "width": 464,
        "height": 640,
        "content": "## 1. 清理 WhatsApp 号码"
      },
      "typeVersion": 1
    },
    {
      "id": "4a8334f3-6dc4-4cf5-9357-f649986a6e0b",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        400
      ],
      "parameters": {
        "width": 912,
        "height": 880,
        "content": "## 1. If"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4b437753-160f-4aae-8288-805da2312e89",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Rapiwa Sender",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Store State of Rows in Unverified & Not Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Format Webhook Response Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rapiwa Sender": {
      "main": [
        [
          {
            "node": "Store State of Rows in Verified & Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Clean WhatsApp Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean WhatsApp Number": {
      "main": [
        [
          {
            "node": "Check valid whatsapp number Using Rapiwa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Webhook Response Data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store 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
          }
        ]
      ]
    },
    "Store State of Rows in Unverified & Not Sent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 客服机器人

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流