自动向 Shopify 客户发送 WhatsApp 折扣码
高级
这是一个自动化工作流,包含 17 个节点。主要使用 If, Code, Wait, Webhook, HttpRequest 等节点。 使用 Rapiwa 自动向 Shopify 客户发送 WhatsApp 折扣码
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "3ckQmwxTKtMRIWEs",
"meta": {
"instanceId": "cb9a1e5321767b6316634728341237e564b2587ab15b74ca0a89eb02a53484d6",
"templateCredsSetupCompleted": true
},
"name": "自动向 Shopify 客户发送 WhatsApp 折扣码",
"tags": [],
"nodes": [
{
"id": "f168dde7-9e0e-407c-b303-6ea10aac4353",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
1232,
624
],
"webhookId": "a9b6a936-e5f2-4d4c-9cf9-182de0a970d5",
"parameters": {
"path": "a9b6a936-e5f2-4d4c-9cf9-182de0a970d5",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2
},
{
"id": "8195a385-5359-49ac-98ec-fa1b420f2f1d",
"name": "如果",
"type": "n8n-nodes-base.if",
"position": [
3008,
640
],
"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": "0c976026-d9ac-4ee2-a5ee-e37bb007c50e",
"name": "等待",
"type": "n8n-nodes-base.wait",
"position": [
3488,
704
],
"webhookId": "6c474e54-eb3c-4fcd-b455-948322cd0121",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "31e045f5-511e-49f7-8695-0043fe6fb5bb",
"name": "清理 WhatsApp 号码",
"type": "n8n-nodes-base.code",
"position": [
2512,
640
],
"parameters": {
"jsCode": "const items = $input.all();\n\nconst updatedItems = items.map((item) => {\n const waNo = item?.json?.[\"number\"];\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[\"number\"] = cleanedNumber;\n\n return item;\n});\n\nreturn updatedItems;\n"
},
"typeVersion": 2
},
{
"id": "226d9053-c905-43c0-b1e0-b475fab1ca86",
"name": "使用 Rapiwa 检查有效的 WhatsApp 号码",
"type": "n8n-nodes-base.httpRequest",
"position": [
2704,
640
],
"parameters": {
"url": "=https://app.rapiwa.com/api/verify-whatsapp",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "number",
"value": "={{ $json.number }}"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "jnaHCyYia9OAFozh",
"name": "Rapiwa Bearer Auth"
}
},
"typeVersion": 4.2
},
{
"id": "e5531a68-481c-4ff7-80c4-b1b2e47655c6",
"name": "使用 Rapiwa 发送消息",
"type": "n8n-nodes-base.httpRequest",
"position": [
3232,
512
],
"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!\nWe've just created a new discount rule at our store, and we’ve got something special just for you! 🎉\nDiscount Code: *{{ $('Clean Webhooks Response Data').item.json.title }}*\n\nUse this code on your next order to enjoy an exclusive discount.\n\n– Team *SpaGreen Creative*"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "jnaHCyYia9OAFozh",
"name": "Rapiwa Bearer Auth"
}
},
"typeVersion": 4.2
},
{
"id": "aaa23891-6e2d-4cca-bdcd-276b3b53ed17",
"name": "清理 Webhooks 响应数据",
"type": "n8n-nodes-base.code",
"position": [
1456,
624
],
"parameters": {
"jsCode": "const result = $input.all().map(item => {\n const body = item.json.body || {};\n \n return {\n discount_id: body.admin_graphql_api_id,\n title: body.title,\n status: body.status,\n created_at: body.created_at,\n updated_at: body.updated_at,\n shop_domain: item.json.headers['x-shopify-shop-domain'],\n };\n});\n\nreturn result;"
},
"typeVersion": 2
},
{
"id": "b1fdf13b-9648-4fb0-8785-255261aa84bd",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2256,
624
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "484ecd1a-c9da-4e4e-aad6-663ada850870",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-128,
336
],
"parameters": {
"width": 1168,
"height": 1248,
"content": "# 使用 Rapiwa 自动向 Shopify 客户发送 WhatsApp 折扣码"
},
"typeVersion": 1
},
{
"id": "d7993dbb-5885-4a16-81d8-2c9b9d868886",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1088,
352
],
"parameters": {
"width": 624,
"height": 560,
"content": "## 1. Webhook"
},
"typeVersion": 1
},
{
"id": "dc59f834-6f18-42a8-870b-22cf09a92eda",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1728,
352
],
"parameters": {
"width": 448,
"height": 560,
"content": "## 1. 获取店内所有客户数据"
},
"typeVersion": 1
},
{
"id": "3366ce0c-0d80-4c99-b750-ddbe9a3565c7",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2448,
256
],
"parameters": {
"width": 384,
"height": 656,
"content": "## 1. 清理 WhatsApp 号码"
},
"typeVersion": 1
},
{
"id": "e0f334ec-45b0-4ba4-bd92-fc72f687bf6a",
"name": "便签 5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2928,
144
],
"parameters": {
"width": 816,
"height": 768,
"content": "## 1. 节点:If(条件检查)"
},
"typeVersion": 1
},
{
"id": "56c123fc-edad-4d59-bb62-e3d009d0dbcf",
"name": "获取 Shopify 商店中的所有客户数据",
"type": "n8n-nodes-base.httpRequest",
"position": [
1776,
624
],
"parameters": {
"url": "https://your_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": "22ae91ae-2286-46ce-b1e6-8f6cac7d3fc4",
"name": "清理 Shopify 商店中的客户数据",
"type": "n8n-nodes-base.code",
"position": [
1984,
624
],
"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 const fullName = `${customer.first_name || ''} ${customer.last_name || ''}`.trim();\n\n return {\n json: {\n customerId: customer.id || null,\n customerName: fullName,\n email: customer.email || 'N/A',\n number: 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 state: customer.state || 'N/A',\n }\n };\n });\n"
},
"typeVersion": 2
},
{
"id": "4f0c8dca-3b77-4aeb-b61d-5d72951d8425",
"name": "在表格中保存未验证和未发送的数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
3248,
704
],
"parameters": {
"columns": {
"value": {
"name": "={{ $('Clean WhatsApp Number').item.json.customerName }}",
"title": "={{ $('Webhook').item.json.body.title }}",
"number": "={{ $json.data.number }}",
"status": "not sent",
"verify": "=unverified",
"created_at": "={{ $('Clean Webhooks Response Data').item.json.created_at }}",
"discount_id": "={{ $('Webhook').item.json.body.admin_graphql_api_id }}",
"shop_domain": "={{ $('Webhook').item.json.headers[\"x-shopify-shop-domain\"] }}"
},
"schema": [
{
"id": "discount_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "discount_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "title",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "title",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "created_at",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "created_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "shop_domain",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "shop_domain",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"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": "verify",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "verify",
"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": "1Zx_WXQW29NsITFPJ-SnjHgOlouvzG_sBNGzSA_B8cSA",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Zx_WXQW29NsITFPJ-SnjHgOlouvzG_sBNGzSA_B8cSA/edit?usp=drivesdk",
"cachedResultName": "Shopify - Send WhatsApp promo code to customers"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "gFH3Wjq6yYqSEAei",
"name": "Google Sheets"
}
},
"typeVersion": 4.6
},
{
"id": "91abd2bc-3bb1-4ebc-a1dd-d30218ffd60d",
"name": "在表格中保存已验证和已发送的数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
3456,
512
],
"parameters": {
"columns": {
"value": {
"name": "={{ $('Clean WhatsApp Number').item.json.customerName }}",
"title": "={{ $('Webhook').item.json.body.title }}",
"number": "={{ $('Clean WhatsApp Number').item.json.number }}",
"status": "sent",
"verify": "verified",
"created_at": "={{ $('Clean Webhooks Response Data').item.json.created_at }}",
"discount_id": "={{ $('Webhook').item.json.body.admin_graphql_api_id }}",
"shop_domain": "={{ $('Webhook').item.json.headers[\"x-shopify-shop-domain\"] }}"
},
"schema": [
{
"id": "discount_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "discount_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "title",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "title",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "created_at",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "created_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "shop_domain",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "shop_domain",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"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": "verify",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "verify",
"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": "1Zx_WXQW29NsITFPJ-SnjHgOlouvzG_sBNGzSA_B8cSA",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Zx_WXQW29NsITFPJ-SnjHgOlouvzG_sBNGzSA_B8cSA/edit?usp=drivesdk",
"cachedResultName": "Shopify - Send WhatsApp promo code to customers"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "gFH3Wjq6yYqSEAei",
"name": "Google Sheets"
}
},
"typeVersion": 4.6
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "d58399cd-b62d-4e4b-a151-3305005d8bce",
"connections": {
"If": {
"main": [
[
{
"node": "Send Message Using Rapiwa",
"type": "main",
"index": 0
}
],
[
{
"node": "Save data Sheet Unverified & Not sent",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Clean Webhooks Response Data",
"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
}
]
]
},
"Send Message Using Rapiwa": {
"main": [
[
{
"node": "Save data in Sheet Verified & Sent",
"type": "main",
"index": 0
}
]
]
},
"Clean Webhooks Response Data": {
"main": [
[
{
"node": "Get All Customer Data In Shopify Store",
"type": "main",
"index": 0
}
]
]
},
"Save data in Sheet Verified & Sent": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Clean Customer Data In Shopify Store": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Save data Sheet Unverified & Not sent": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Get All Customer Data In Shopify Store": {
"main": [
[
{
"node": "Clean Customer Data In Shopify Store",
"type": "main",
"index": 0
}
]
]
},
"Check valid whatsapp number Using Rapiwa": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
通过WhatsApp向客户发送WooCommerce订单状态更新
使用Rapiwa API通过WhatsApp向客户发送WooCommerce订单更新
If
Code
Wait
+5
14 节点Rapiwa
客服机器人
使用Rapiwa API自动在WhatsApp上发送WooCommerce发票
使用Rapiwa API通过WhatsApp自动发送WooCommerce发票
If
Code
Wait
+5
15 节点Rapiwa
客户关系管理
WooCommerce订单完成的WhatsApp评价请求自动化
使用Rapiwa通过WhatsApp为完成的WooCommerce订单自动化评价请求
If
Code
Wait
+5
15 节点Rapiwa
客户培育
当Shopify订单取消时发送WhatsApp道歉与重新订购链接
当Shopify订单取消时发送Rapiwa WhatsApp道歉与重新订购链接
If
Code
Wait
+5
15 节点Rapiwa
客服机器人
使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 交叉销售优惠
使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 交叉销售优惠
If
Code
Wait
+6
23 节点Rapiwa
社交媒体
使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 折扣券
使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 折扣券
If
Code
Wait
+6
16 节点Rapiwa
社交媒体