8
n8n 中文网amn8n.com

从 Google Sheets 发送 WhatsApp 批量消息广播

中级

这是一个Social Media领域的自动化工作流,包含 8 个节点。主要使用 Code, Limit, WhatsApp, GoogleSheets, SplitInBatches 等节点。 从 Google Sheets 发送 WhatsApp 批量消息

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "9KGiiRIN9IKHc7Ls",
  "meta": {
    "instanceId": "281fe883012e72eba57c771d5dbf7c3138ca3fe3633c5ba2adf6169821825dd4",
    "templateCredsSetupCompleted": true
  },
  "name": "从 Google Sheets 发送 WhatsApp 批量消息广播",
  "tags": [],
  "nodes": [
    {
      "id": "e76ca205-6342-48e8-baf2-dd46c7cd8524",
      "name": "获取所有待处理查询以进行消息发送",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        128,
        32
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nI-AwIR3Y1FYzV0lwjr9iK6Ia4WuD5eRtgJH819rIIc/edit#gid=0",
          "cachedResultName": "message"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nI-AwIR3Y1FYzV0lwjr9iK6Ia4WuD5eRtgJH819rIIc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nI-AwIR3Y1FYzV0lwjr9iK6Ia4WuD5eRtgJH819rIIc/edit?usp=drivesdk",
          "cachedResultName": "WhatsApp Message Broadcast"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "hIOzlTOST3U7PqR8",
          "name": "Google Sheets account"
        }
      },
      "notesInFlow": false,
      "retryOnFail": false,
      "typeVersion": 4.6
    },
    {
      "id": "96e27292-9c80-4294-87da-7c16a3b1e5c2",
      "name": "限制",
      "type": "n8n-nodes-base.limit",
      "position": [
        368,
        32
      ],
      "parameters": {
        "maxItems": 300
      },
      "typeVersion": 1
    },
    {
      "id": "e9246a66-68d4-4159-b231-b9032f104ddf",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        640,
        32
      ],
      "parameters": {
        "options": {}
      },
      "executeOnce": false,
      "typeVersion": 3
    },
    {
      "id": "f3ba4b18-d324-4548-80e5-469354af27a9",
      "name": "更改 Sent1 中行的状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1072,
        16
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Sent",
            "row_number": "={{ $('Limit').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "SL",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "SL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "WhatsApp No",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "WhatsApp No",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Message",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Image URL",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Image URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nI-AwIR3Y1FYzV0lwjr9iK6Ia4WuD5eRtgJH819rIIc/edit#gid=0",
          "cachedResultName": "message"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nI-AwIR3Y1FYzV0lwjr9iK6Ia4WuD5eRtgJH819rIIc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nI-AwIR3Y1FYzV0lwjr9iK6Ia4WuD5eRtgJH819rIIc/edit?usp=drivesdk",
          "cachedResultName": "WhatsApp Message Broadcast"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "hIOzlTOST3U7PqR8",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "547f5f77-cf4a-4d50-897a-682b53389293",
      "name": "向 100 个电话号码发送消息",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1072,
        208
      ],
      "webhookId": "0a1149cd-db71-46f9-b95f-0ef3ffdf6bf8",
      "parameters": {
        "template": "n8n_broadcast_message|en",
        "components": {
          "component": [
            {
              "type": "header",
              "headerParameters": {
                "parameter": [
                  {
                    "type": "image",
                    "imageLink": "={{ $json['Image URL'] }}"
                  }
                ]
              }
            },
            {
              "bodyParameters": {
                "parameter": [
                  {
                    "text": "={{ $json.Name }}"
                  },
                  {
                    "text": "={{ $json.Message }}"
                  }
                ]
              }
            }
          ]
        },
        "phoneNumberId": "106689602303326",
        "recipientPhoneNumber": "={{ String($json['WhatsApp No']) }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "T2ie58mIhsaFCRN8",
          "name": "SpaGreen WA"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d85bfed1-57d8-4889-834e-d0a3b0288cf1",
      "name": "清理 WhatsApp 号码",
      "type": "n8n-nodes-base.code",
      "position": [
        848,
        208
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst updatedItems = items.map((item) => {\n  const waNo = item?.json[\"WhatsApp No\"];\n  const waNoStr = typeof waNo === 'string' ? waNo : (waNo !== undefined && waNo !== null ? String(waNo) : \"\");\n  const cleanedNumber = waNoStr.replace(/\\D/g, \"\");\n  item.json[\"WhatsApp No\"] = cleanedNumber;\n  return item;\n});\nreturn updatedItems;"
      },
      "typeVersion": 2
    },
    {
      "id": "daafd591-1d05-4469-a727-2985f56081db",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 704,
        "height": 2028,
        "content": "# 📘 n8n 工作流:通过 Google Sheets 发送 WhatsApp 批量消息广播"
      },
      "typeVersion": 1
    },
    {
      "id": "37d1728b-89fe-4bf8-9c5e-e42d3e4e51ae",
      "name": "每 5 分钟触发一次",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -80,
        32
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e5e04a32-bc80-4623-ac07-b00706d20adf",
  "connections": {
    "Limit": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Change State of Rows in Sent1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Clean WhatsApp Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean WhatsApp Number": {
      "main": [
        [
          {
            "node": "Send Message to 300 Phone No",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Every 5 Minute": {
      "main": [
        [
          {
            "node": "Fetch All Pending Queries for Messaging",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Message to 100 Phone No1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Pending Queries for Messaging": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 社交媒体

需要付费吗?

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

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

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

作者
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 6,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 查看

分享此工作流