8
n8n 中文网amn8n.com

使用Twilio从Google Sheets发送批量短信

中级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 12 个节点。主要使用 If, Set, Merge, Twilio, GoogleSheets 等节点。 使用Twilio从Google Sheets发送批量短信

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "c8c9ba5d3eb26ae47a06d24ff164a01c0d73ed4753a74903c2bb609d434a0f6b",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "57c3d2f1-a6bf-489b-8d89-e22e2c331060",
      "name": "监控 Google Sheet 中的 SMS 队列",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -16,
        784
      ],
      "parameters": {
        "options": {
          "columnsToWatch": [
            "Status"
          ]
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/1DGhQ2YLeQ5boLYPMK4nUF8SIOJmDDqvtyleSz5IpJEc/edit?gid=0#gid=0"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/1DGhQ2YLeQ5boLYPMK4nUF8SIOJmDDqvtyleSz5IpJEc/edit?gid=0#gid=0"
        }
      },
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "id": "wmHyp3V8IXvfJ6RS",
          "name": "Google Sheets Trigger account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "46ad543f-8988-4258-9a9d-f824461e5862",
      "name": "配置",
      "type": "n8n-nodes-base.set",
      "position": [
        176,
        784
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e60a21c7-574a-4579-9e7f-57cf6b9f50c9",
              "name": "sheet_url",
              "type": "string",
              "value": "https://docs.google.com/spreadsheets/d/1DGhQ2YLeQ5boLYPMK4nUF8SIOJmDDqvtyleSz5IpJEc/edit?gid=0#gid=0"
            },
            {
              "id": "e39b8ae5-c53a-4186-9ec5-6c352cd1d7e4",
              "name": "from_number",
              "type": "string",
              "value": "+18565883517"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "122f32a2-c87e-419f-b168-fabe5ed9a111",
      "name": "合并配置与行数据",
      "type": "n8n-nodes-base.merge",
      "position": [
        736,
        560
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "e2135c65-c83a-487a-9fab-6760711001f1",
      "name": "准备 SMS 内容",
      "type": "n8n-nodes-base.set",
      "position": [
        928,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "463668f7-11f7-48d2-91c3-635a78637c7f",
              "name": "Message",
              "type": "string",
              "value": "={{ $json['Message Template']\n  .replace(/\\[First Name\\]/g, $json['First Name'])\n  .replace(/\\[Last Name\\]/g, $json['Last Name'])\n}}"
            },
            {
              "id": "3ddbf667-aa74-4ddb-b12e-6bf1294fdaa3",
              "name": "To",
              "type": "string",
              "value": "={{ $json.Phone }}"
            },
            {
              "id": "609250bc-7ae0-4213-9611-a60b3ac63eaa",
              "name": "From",
              "type": "string",
              "value": "={{ $json.from_number }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "604eeeb8-57c7-452e-b9ba-a69609fb0869",
      "name": "检查是否准备发送",
      "type": "n8n-nodes-base.if",
      "position": [
        384,
        784
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "223f9988-650a-4fcc-9a65-2f240c4b3dce",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Status }}",
              "rightValue": "To send"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "61cf54a2-dafe-48f2-812e-68edc1207c63",
      "name": "通过 Twilio 发送 SMS",
      "type": "n8n-nodes-base.twilio",
      "onError": "continueRegularOutput",
      "position": [
        1136,
        560
      ],
      "parameters": {
        "to": "={{ $json.To }}",
        "from": "={{ $json.From }}",
        "message": "={{ $json.Message }}",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "JgMpoxsNKUfVKqN1",
          "name": "Twilio account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3a112254-bd07-4b7c-9cd4-b2950548fbff",
      "name": "更新状态为发送中",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        592,
        768
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $json.ID }}",
            "Status": "Sending..."
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Message Template",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Message Template",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $json.sheet_url }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $json.sheet_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gbEbCNKqCMSRZPql",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "3497b801-644b-4e83-9638-e674090a4871",
      "name": "检查发送结果",
      "type": "n8n-nodes-base.if",
      "position": [
        1344,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3f814939-8cea-4114-aed8-9f4202c7eb80",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ !$json.error }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d5252d5b-7064-42e5-9167-a9e544e7eaa8",
      "name": "标记为成功",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1584,
        464
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Update Status to Sending').item.json.ID }}",
            "Status": "Success"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Message Template",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Message Template",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Config').first().json.sheet_url }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Config').first().json.sheet_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gbEbCNKqCMSRZPql",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "b9b09def-5a49-49f3-b754-fcd7fb2bc521",
      "name": "标记为错误",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1584,
        672
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Update Status to Sending').item.json.ID }}",
            "Status": "Error"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Message Template",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Message Template",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Config').first().json.sheet_url }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Config').first().json.sheet_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gbEbCNKqCMSRZPql",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7
    },
    {
      "ida": "3ae7f2e6-2907-4ccf-9c65-3f74ff79bbac",
      "name": "配置助手",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        592
      ],
      "parameters": {
        "width": 272,
        "content": "## 在此处配置 👇👇"
      },
      "typeVersion": 1
    },
    {
      "id": "doc-note-1759930148725",
      "name": "工作流描述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -716,
        369
      ],
      "parameters": {
        "width": 600,
        "height": 950,
        "content": "## 工作流概述"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Config": {
      "main": [
        [
          {
            "node": "Check if Ready to Send",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Send Result": {
      "main": [
        [
          {
            "node": "Mark as Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark as Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare SMS Content": {
      "main": [
        [
          {
            "node": "Send SMS via Twilio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send SMS via Twilio": {
      "main": [
        [
          {
            "node": "Check Send Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Ready to Send": {
      "main": [
        [
          {
            "node": "Update Status to Sending",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Config with Row Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Status to Sending": {
      "main": [
        [
          {
            "node": "Merge Config with Row Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Config with Row Data": {
      "main": [
        [
          {
            "node": "Prepare SMS Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monitor Google Sheet for SMS Queue": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 社交媒体, 多模态 AI

需要付费吗?

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

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

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

作者
Milan Vasarhelyi - SmoothWork

Milan Vasarhelyi - SmoothWork

@vasarmilan

We help you eliminate the busywork by building compact business tools tailored to your processes. 📞: https://smoothwork.ai/book-a-call ▶️: https://www.youtube.com/@vasarmilan

外部链接
在 n8n.io 查看

分享此工作流