8
n8n 中文网amn8n.com

Shopify自动发送WhatsApp感谢消息和忠诚度优惠券(使用Rapiwa API)

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 If, Code, Wait, HttpRequest, GoogleSheets 等节点。 使用Rapiwa从Shopify自动发送WhatsApp感谢消息和忠诚度优惠券

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "TZh5DGrhbMLuufLR",
  "meta": {
    "instanceId": "cb9a1e5321767b6316634728341237e564b2587ab15b74ca0a89eb02a53484d6",
    "templateCredsSetupCompleted": true
  },
  "name": "Shopify 自动发送 WhatsApp 感谢消息和忠诚度优惠券(使用 Rapiwa API)",
  "tags": [],
  "nodes": [
    {
      "id": "b520df6b-3acf-4fb0-929e-77446e6eaefc",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -448,
        672
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "652b65b5-f5f0-4d15-99e4-41c0976ad8e2",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        224,
        928
      ],
      "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": "f187821c-cd12-455f-b41e-91a851d62d78",
      "name": "清理 WhatsApp 号码",
      "type": "n8n-nodes-base.code",
      "position": [
        -176,
        800
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nconst updatedItems = items.map((item) => {\n  const waNo = item?.json?.[\"phone\"];\n  const waNoStr = typeof waNo === 'string'\n    ? waNo\n    : (waNo !== undefined && waNo !== null ? String(waNo) : \"\");\n\n  const cleanedNumber = waNoStr.replace(/\\D/g, \"\"); // Remove non-digit characters\n\n  item.json[\"phone\"] = cleanedNumber;\n\n  return item;\n});\n\nreturn updatedItems;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "1f5eefb7-8c49-4f53-a621-1f6628856964",
      "name": "使用Rapiwa检查有效的WhatsApp号码",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        16,
        800
      ],
      "parameters": {
        "url": "=https://app.rapiwa.com/api/verify-whatsapp",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $json.phone }}"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "jnaHCyYia9OAFozh",
          "name": "Rapiwa Bearer Auth"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3700e098-7168-4752-99e8-1656d8689ab7",
      "name": "在已验证和已发送表格中追加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        672,
        800
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Clean WhatsApp Number').item.json.customerName }}",
            "number": "={{ $json.to }}",
            "status": "sent",
            "validity": "verified"
          },
          "schema": [
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "validity",
              "type": "string",
              "display": true,
              "removed": false,
              "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/1Zx_WXQW29NsITFPJ-SnjHgOlouvzG_sBNGzSA_B8cSA/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1q5mO2pRCdO-v51OyUZt-56UprsGpmn0PMGhnglgg2ls",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1q5mO2pRCdO-v51OyUZt-56UprsGpmn0PMGhnglgg2ls/edit?usp=drivesdk",
          "cachedResultName": "Shopify - Send WhatsApp thank-you + loyalty coupon"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gFH3Wjq6yYqSEAei",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "1eda2f14-4088-4ced-9304-23868a0763e3",
      "name": "在未验证和未发送表格中追加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        464,
        1024
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Clean WhatsApp Number').item.json.customerName }}",
            "number": "={{ $json.data.number }}",
            "status": "not sent",
            "validity": "unverified"
          },
          "schema": [
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "validity",
              "type": "string",
              "display": true,
              "removed": false,
              "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/1Zx_WXQW29NsITFPJ-SnjHgOlouvzG_sBNGzSA_B8cSA/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1q5mO2pRCdO-v51OyUZt-56UprsGpmn0PMGhnglgg2ls",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1q5mO2pRCdO-v51OyUZt-56UprsGpmn0PMGhnglgg2ls/edit?usp=drivesdk",
          "cachedResultName": "Shopify - Send WhatsApp thank-you + loyalty coupon"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gFH3Wjq6yYqSEAei",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "4e8f8880-393d-4148-a43a-6b45dedae0fd",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        704,
        1024
      ],
      "webhookId": "6c474e54-eb3c-4fcd-b455-948322cd0121",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "e6b244a0-9082-4dd9-979d-123c76b3d2b4",
      "name": "使用 Rapiwa 发送消息",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        464,
        800
      ],
      "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": "=Hey {{ $('Clean WhatsApp Number').item.json.customerName }},\n\nYou're one of our favorite customers! 💚\nHere’s a *50% OFF* coupon just for you *SG-50*🎁\n\nHurry — it won’t last long! \n– Team *SpaGreen Creative*"
            },
            {
              "name": "status"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "jnaHCyYia9OAFozh",
          "name": "Rapiwa Bearer Auth"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c964d973-17c1-4da3-903c-2ce26d8074ea",
      "name": "获取商店中的所有客户数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -896,
        608
      ],
      "parameters": {
        "url": "https://your_shop_domain/admin/api/2025-07/customers.json",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Shopify-Access-Token",
              "value": "your_shopify_accesstoken like this➡️shpat_57xx78xxxxx90fxxx67"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "30f9176f-6e91-4990-ac1b-fa8333ef09db",
      "name": "清理 HTTP 请求数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -672,
        608
      ],
      "parameters": {
        "jsCode": "const customers = items[0].json.customers;\n\nif (!Array.isArray(customers)) {\n  throw new Error(\"Customers not found or not an array\");\n}\n\nreturn customers\n  .filter((customer) => {\n    const totalSpent = parseFloat(customer.total_spent || '0.00');\n    return totalSpent > 5000;\n  })\n  .map((customer) => {\n    const address = customer.default_address || {};\n\n    return {\n      json: {\n        customerId: customer.id || null,\n        customerName: `${customer.first_name || ''} ${customer.last_name || ''}`.trim(),\n        email: customer.email || 'N/A',\n        phone: customer.phone || address.phone || 'N/A',\n        totalSpent: customer.total_spent || '0.00',\n        ordersCount: customer.orders_count || 0,\n        address: address.address1 || 'N/A',\n        city: address.city || 'N/A',\n        country: address.country || 'N/A',\n        createdAt: customer.created_at || null,\n        updatedAt: customer.updated_at || null,\n        state: customer.state || 'N/A'\n      }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7616b409-a957-4e18-9247-88b6e8181dfb",
      "name": "Clicki",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1104,
        608
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ffe3dd46-960c-42a1-90ea-5bc5b69ae8cb",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        208
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 608,
        "content": "## 节点:Clicki(手动触发器)"
      },
      "typeVersion": 1
    },
    {
      "id": "fffcb6eb-2a09-4285-bbf7-a4530ef6949e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        208
      ],
      "parameters": {
        "color": 2,
        "width": 400,
        "height": 816,
        "content": "## 1. 节点:获取商店中的所有客户数据"
      },
      "typeVersion": 1
    },
    {
      "id": "c75fac79-51eb-44f7-8bf5-13ddb622884f",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        208
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 1024,
        "content": "## 节点:循环遍历项目(分批拆分)"
      },
      "typeVersion": 1
    },
    {
      "id": "13e6b28d-ea71-42ba-a614-1e843dccbb2f",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        208
      ],
      "parameters": {
        "color": 6,
        "width": 416,
        "height": 1024,
        "content": "## 1. 节点:清理 WhatsApp 号码(代码节点)"
      },
      "typeVersion": 1
    },
    {
      "id": "bb30d9ea-0826-4aaa-aa95-7d1e1be71a3c",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        208
      ],
      "parameters": {
        "color": 4,
        "width": 720,
        "height": 1024,
        "content": "## 1. 节点:如果(条件检查)"
      },
      "typeVersion": 1
    },
    {
      "id": "53d0c208-8d90-4503-8fd5-49057a65c93d",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2128,
        208
      ],
      "parameters": {
        "color": 4,
        "width": 848,
        "height": 2416,
        "content": "# Shopify 自动发送 WhatsApp 感谢消息和忠诚度优惠券(使用 Rapiwa API)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cbabfc7c-e86f-4f5d-a3ab-3eee077691d4",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send Message Using Rapiwa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append Rows in Sheet Unverified & Not sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clicki": {
      "main": [
        [
          {
            "node": "Get All Customer Data In Store",
            "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
          }
        ]
      ]
    },
    "Clean HTTP Request Data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Message Using Rapiwa": {
      "main": [
        [
          {
            "node": "Append Rows in Sheet Verified & Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Customer Data In Store": {
      "main": [
        [
          {
            "node": "Clean HTTP Request Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Rows in Sheet Verified & Sent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check valid whatsapp number Using Rapiwa": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Rows in Sheet Unverified & Not sent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
SpaGreen Creative

SpaGreen Creative

@spagreen

SpaGreen Creative is a leading software company specializing in SaaS solutions, AI automation, and Laravel/Vue.js development. With 800+ eCommerce platforms and 8,000+ global clients, we deliver powerful tools for OTT, CRM, ERP, and WhatsApp marketing. We combine innovation and tech to build scalable digital products.

外部链接
在 n8n.io 查看

分享此工作流