使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 折扣券
高级
这是一个Social Media领域的自动化工作流,包含 16 个节点。主要使用 If, Code, Wait, HttpRequest, WooCommerce 等节点。 使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 折扣券
前置要求
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "klxTlclRsNctKqg1",
"meta": {
"instanceId": "cb9a1e5321767b6316634728341237e564b2587ab15b74ca0a89eb02a53484d6",
"templateCredsSetupCompleted": true
},
"name": "使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 折扣券",
"tags": [],
"nodes": [
{
"id": "70fcfcfc-a653-4d5b-92db-01951eb416da",
"name": "如果",
"type": "n8n-nodes-base.if",
"position": [
128,
224
],
"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": "1830de6f-7291-4150-8d02-3b88bed4a49a",
"name": "等待",
"type": "n8n-nodes-base.wait",
"position": [
656,
320
],
"webhookId": "6c474e54-eb3c-4fcd-b455-948322cd0121",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "2a78cc95-9c6f-484d-913a-de3d708bc35e",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-560,
208
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "3a8e2e8e-faa4-4f84-ad98-855f22d74a52",
"name": "WooCommerce 触发器",
"type": "n8n-nodes-base.wooCommerceTrigger",
"position": [
-1280,
208
],
"webhookId": "5530612b-221d-4418-9a9a-ffbe24957be7",
"parameters": {
"event": "coupon.created"
},
"credentials": {
"wooCommerceApi": {
"id": "BZ5Lp9IB4Phney4R",
"name": "WooCommerce (get customer)"
}
},
"typeVersion": 1
},
{
"id": "e421bbaa-b283-417d-8dc3-c8715c855518",
"name": "清理 WhatsApp 号码",
"type": "n8n-nodes-base.code",
"position": [
-304,
224
],
"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": "693bfe50-4746-412a-a463-543331863a2f",
"name": "使用 Rapiwa 检查有效的 WhatsApp 号码",
"type": "n8n-nodes-base.httpRequest",
"position": [
-112,
224
],
"parameters": {
"url": "=https://app.rapiwa.com/api/verify-whatsapp",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "number",
"value": "={{ $json.billing.phone }}"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "jnaHCyYia9OAFozh",
"name": "Rapiwa Bearer YOUR_TOKEN_HERE"
}
},
"typeVersion": 4.2
},
{
"id": "e1149c81-4cc8-4395-91c2-42a099d67738",
"name": "使用 Rapiwa 发送消息",
"type": "n8n-nodes-base.httpRequest",
"position": [
432,
96
],
"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.first_name }} {{ $('Clean WhatsApp Number').item.json.last_name }},\n\n🎉 {{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].description }} from SpaGreen Creative! 🎉 \nCelebrate with *{{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].discountAmount }}* OFF — use code *{{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].couponCode }}* at checkout. \nThis special offer is valid until *{{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].dateExpires }}* — don’t miss out!\n\nThanks for being with us!\n"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "jnaHCyYia9OAFozh",
"name": "Rapiwa Bearer YOUR_TOKEN_HERE"
}
},
"typeVersion": 4.2
},
{
"id": "13e94fe4-66dd-42d2-85a8-e291fb7dee28",
"name": "在已验证和已发送中保存行状态",
"type": "n8n-nodes-base.googleSheets",
"position": [
640,
96
],
"parameters": {
"columns": {
"value": {
"name": "={{ $('Clean WhatsApp Number').item.json.first_name }} {{ $('Clean WhatsApp Number').item.json.first_name }}",
"email": "={{ $('Clean WhatsApp Number').item.json.billing.email }}",
"number": "={{ $('Clean WhatsApp Number').item.json.billing.phone }}",
"status": "sent",
"address1": "={{ $('Clean WhatsApp Number').item.json.billing.address_1 }}",
"validity": "verified",
"couponCode": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].couponCode }}",
"couponType": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].discountType }}",
"createDate": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].dateCreate }}",
"expireDate": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].dateExpires }}",
"couponTitle": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].description }}",
"aouponAmount": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].discountAmount }}"
},
"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": "couponCode",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "couponCode",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "couponTitle",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "couponTitle",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "couponType",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "couponType",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "aouponAmount",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "aouponAmount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "createDate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "createDate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "expireDate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "expireDate",
"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": "id",
"value": "gid=0"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "14UclmcZ7TGU4Qaag89yaZLVFee1IQNA6t-uhgN8_TAE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/14UclmcZ7TGU4Qaag89yaZLVFee1IQNA6t-uhgN8_TAE/edit?usp=drivesdk",
"cachedResultName": "Send WooCommerce Promo Codes via WhatsApp with Rapiwa API"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "gFH3Wjq6yYqSEAei",
"name": "Google Sheets"
}
},
"typeVersion": 4.6
},
{
"id": "bdd3c281-cc39-441c-8275-e0b95390429b",
"name": "格式化 WooCommerce 触发器响应数据",
"type": "n8n-nodes-base.code",
"position": [
-1040,
208
],
"parameters": {
"jsCode": "// Access the input data (from previous node)\nconst coupons = items[0].json;\n\n// If input is not an array, wrap it\nconst couponsArray = Array.isArray(coupons) ? coupons : [coupons];\n\n// Format coupon data\nconst formattedCoupons = couponsArray.map(coupon => {\n const amountWithSymbol = coupon.discount_type === \"percent\" \n ? coupon.amount + \"%\" \n : coupon.amount;\n\n return {\n couponCode: coupon.code,\n discountAmount: amountWithSymbol,\n discountType: coupon.discount_type,\n description: coupon.description,\n dateCreate: coupon.date_modified,\n dateExpires: coupon.date_expires,\n freeShipping: coupon.free_shipping,\n };\n});\n\n// Return as a **single item** with the array in a `coupons` field\nreturn [\n {\n json: {\n data: {\n coupons: formattedCoupons\n }\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "e87d5c95-b176-4062-897d-3eb15bd6c5e1",
"name": "获取多个客户",
"type": "n8n-nodes-base.wooCommerce",
"position": [
-752,
208
],
"parameters": {
"filters": {},
"resource": "customer",
"operation": "getAll",
"returnAll": true
},
"credentials": {
"wooCommerceApi": {
"id": "BZ5Lp9IB4Phney4R",
"name": "WooCommerce (get customer)"
}
},
"typeVersion": 1
},
{
"id": "8e804acd-a932-4849-bc42-428c478808cd",
"name": "在\"未验证和未发送\"中保存行状态",
"type": "n8n-nodes-base.googleSheets",
"position": [
432,
320
],
"parameters": {
"columns": {
"value": {
"name": "={{ $('Clean WhatsApp Number').item.json.first_name }} {{ $('Clean WhatsApp Number').item.json.first_name }}",
"email": "={{ $('Clean WhatsApp Number').item.json.billing.email }}",
"number": "={{ $('Clean WhatsApp Number').item.json.billing.phone }}",
"status": "not sent",
"address1": "={{ $('Clean WhatsApp Number').item.json.billing.address_1 }}",
"validity": "unverified",
"couponCode": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].couponCode }}",
"couponType": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].discountType }}",
"createDate": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].dateCreate }}",
"expireDate": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].dateExpires }}",
"couponTitle": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].description }}",
"aouponAmount": "={{ $('Format WooCommerce Trigger Response Data').item.json.data.coupons[0].discountAmount }}"
},
"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": "couponCode",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "couponCode",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "couponTitle",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "couponTitle",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "couponType",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "couponType",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "aouponAmount",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "aouponAmount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "createDate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "createDate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "expireDate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "expireDate",
"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": "id",
"value": "gid=0"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "14UclmcZ7TGU4Qaag89yaZLVFee1IQNA6t-uhgN8_TAE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/14UclmcZ7TGU4Qaag89yaZLVFee1IQNA6t-uhgN8_TAE/edit?usp=drivesdk",
"cachedResultName": "Send WooCommerce Promo Codes via WhatsApp with Rapiwa API"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "gFH3Wjq6yYqSEAei",
"name": "Google Sheets"
}
},
"typeVersion": 4.6
},
{
"id": "091ac102-1ec7-4dca-a64e-702e075bb3c3",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-816,
32
],
"parameters": {
"width": 400,
"height": 496,
"content": "## 获取所有客户"
},
"typeVersion": 1
},
{
"id": "395e382a-e3b1-415c-bfcf-efcbc877854d",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
-112
],
"parameters": {
"width": 464,
"height": 640,
"content": "## 清理 WhatsApp 号码"
},
"typeVersion": 1
},
{
"id": "a73fd36e-e349-44bd-9bf0-221fd7f22c8d",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-336
],
"parameters": {
"width": 768,
"height": 864,
"content": "## 条件判断"
},
"typeVersion": 1
},
{
"id": "a2b388b8-8055-4008-970a-4c1f82d86c81",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1376,
-144
],
"parameters": {
"width": 544,
"height": 672,
"content": "## WooCommerce 触发器"
},
"typeVersion": 1
},
{
"id": "d25e8d9c-0c45-4c70-baa8-49d18295a065",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2736,
-144
],
"parameters": {
"width": 1328,
"height": 1776,
"content": "# 使用 Rapiwa API 通过 WhatsApp 向客户发送 WooCommerce 折扣券"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "0ffbb79e-1623-4af0-99f4-5024c1204461",
"connections": {
"If": {
"main": [
[
{
"node": "Send Message Using Rapiwa",
"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
}
]
]
},
"Get many customers": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"WooCommerce Trigger": {
"main": [
[
{
"node": "Format WooCommerce Trigger Response Data",
"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 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
}
]
]
},
"Format WooCommerce Trigger Response Data": {
"main": [
[
{
"node": "Get many customers",
"type": "main",
"index": 0
}
]
]
},
"Save State of Rows in Unerified & Not sent": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 社交媒体
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 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
+5
15 节点Rapiwa
客户关系管理
WooCommerce订单完成的WhatsApp评价请求自动化
使用Rapiwa通过WhatsApp为完成的WooCommerce订单自动化评价请求
If
Code
Wait
+5
15 节点Rapiwa
客户培育
自动向 Shopify 客户发送 WhatsApp 折扣码
使用 Rapiwa 自动向 Shopify 客户发送 WhatsApp 折扣码
If
Code
Wait
+5
17 节点Rapiwa
当Shopify订单取消时发送WhatsApp道歉与重新订购链接
当Shopify订单取消时发送Rapiwa WhatsApp道歉与重新订购链接
If
Code
Wait
+5
15 节点Rapiwa
客服机器人
通过WhatsApp向客户发送WooCommerce订单状态更新
使用Rapiwa API通过WhatsApp向客户发送WooCommerce订单更新
If
Code
Wait
+5
14 节点Rapiwa
客服机器人