8
n8n 中文网amn8n.com

通过WhatsApp和邮件分发学校通知工作流

中级

这是一个Miscellaneous领域的自动化工作流,包含 10 个节点。主要使用 If, Code, EmailSend, HttpRequest, MicrosoftExcel 等节点。 通过WhatsApp、电子邮件和Excel自动化学校通知分发

前置要求
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "HPVAZGksUMoYkWlX",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "通过 WhatsApp 和邮件分发学校通知工作流",
  "tags": [],
  "nodes": [
    {
      "id": "4ed6aade-7953-401e-9c87-54f159b81428",
      "name": "每日通知检查 - 上午 9 点",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -500,
        400
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cdd53457-2296-42db-ba46-444e2ac7ab6b",
      "name": "验证通知数据",
      "type": "n8n-nodes-base.if",
      "position": [
        -60,
        400
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json.title}}",
              "operation": "isNotEmpty"
            },
            {
              "value1": "={{$json.message}}",
              "operation": "isNotEmpty"
            },
            {
              "value1": "={{$json.targetAudience}}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "752ae286-9f2d-4c7e-8e01-1ff92966a9c4",
      "name": "处理通知分发",
      "type": "n8n-nodes-base.code",
      "position": [
        160,
        400
      ],
      "parameters": {
        "jsCode": "const notices = $('Read Notices').all();\nconst contacts = $('Read Stakeholder Contacts').all();\n\nconst processedNotices = [];\n\nfor (const notice of notices) {\n  const noticeData = notice.json;\n  \n  const targetAudience = noticeData.targetAudience.toLowerCase();\n  const relevantContacts = contacts.filter(contact => {\n    const contactData = contact.json;\n    \n    if (targetAudience === 'all') return true;\n    if (targetAudience === 'students' && contactData.type === 'Student') return true;\n    if (targetAudience === 'parents' && contactData.type === 'Parent') return true;\n    if (targetAudience === 'teachers' && contactData.type === 'Teacher') return true;\n    if (targetAudience === 'staff' && contactData.type === 'Staff') return true;\n    \n    return false;\n  });\n  \n  for (const contact of relevantContacts) {\n    processedNotices.push({\n      noticeId: noticeData.noticeId || 'NOTICE-' + Date.now(),\n      title: noticeData.title,\n      message: noticeData.message,\n      priority: noticeData.priority || 'Medium',\n      targetAudience: noticeData.targetAudience,\n      contactName: contact.json.name,\n      contactEmail: contact.json.email,\n      contactPhone: contact.json.phone,\n      contactType: contact.json.type,\n      distributionDate: new Date().toISOString().split('T')[0],\n      status: 'Ready for Distribution'\n    });\n  }\n}\n\nreturn processedNotices.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "9d1fd210-9737-4756-a70d-002c899e3f0f",
      "name": "准备邮件内容",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        300
      ],
      "parameters": {
        "jsCode": "const noticeData = $input.first().json;\n\nconst emailSubject = `[${noticeData.priority} Priority] ${noticeData.title}`;\nconst emailBody = `Dear ${noticeData.contactName},\n\n${noticeData.message}\n\n---\nNotice Details:\n- Priority: ${noticeData.priority}\n- Target Audience: ${noticeData.targetAudience}\n- Distribution Date: ${noticeData.distributionDate}\n- Notice ID: ${noticeData.noticeId}\n\nFor any questions or concerns, please contact the school administration.\n\nBest regards,\nSchool Administration Team`;\n\nreturn [{\n  json: {\n    to: noticeData.contactEmail,\n    subject: emailSubject,\n    body: emailBody,\n    recipientName: noticeData.contactName,\n    noticeId: noticeData.noticeId,\n    priority: noticeData.priority\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "5b817e81-22d2-4618-848e-62b0c286e1b4",
      "name": "准备 WhatsApp 内容",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        500
      ],
      "parameters": {
        "jsCode": "const noticeData = $input.first().json;\n\nconst whatsappMessage = `🏫 *${noticeData.title}*\\n\\n${noticeData.message}\\n\\n📋 Notice ID: ${noticeData.noticeId}\\n⚡ Priority: ${noticeData.priority}\\n📅 Date: ${noticeData.distributionDate}\\n\\n_This is an official school notice. Please keep this for your records._`;\n\nreturn [{\n  json: {\n    phone: noticeData.contactPhone,\n    message: whatsappMessage,\n    recipientName: noticeData.contactName,\n    noticeId: noticeData.noticeId,\n    priority: noticeData.priority\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "88cc77ed-4861-4a1a-b4bb-0c491e58a709",
      "name": "发送邮件通知",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        600,
        300
      ],
      "webhookId": "adef7634-8e55-45e9-a79e-89aaac2a2b70",
      "parameters": {
        "text": "={{$json.body}}",
        "options": {},
        "subject": "={{$json.subject}}",
        "toEmail": "={{$json.to}}",
        "fromEmail": "notices@school.edu",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "5b58440e-6a47-4ba0-94ba-19b998d4204e",
      "name": "发送 WhatsApp 通知",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        600,
        500
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v17.0/FROM_PHONE_NUMBER_ID/messages",
        "options": {},
        "jsonBody": "={\n  \"messaging_product\": \"whatsapp\",\n  \"to\": \"{{ $json.phone }}\",\n  \"type\": \"text\",\n  \"text\": {\n    \"body\": \"{{ $json.message }}\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_ACCESS_TOKEN"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5c4b3929-cb7d-45d7-804e-b7281adef0e7",
      "name": "更新通知状态",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        820,
        400
      ],
      "parameters": {
        "options": {},
        "dataMode": "autoMap",
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "=notices-workbook-001"
        },
        "operation": "update",
        "worksheet": {
          "__rl": true,
          "mode": "id",
          "value": "=notices-sheet-001"
        },
        "columnToMatchOn": "=title"
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "id": "jevPChvDpEJk6W9v",
          "name": "Microsoft Excel account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e77a2dd6-1487-4632-b6f6-9e9b6237fc8f",
      "name": "工作流文档",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -220
      ],
      "parameters": {
        "color": 4,
        "width": 640,
        "height": 400,
        "content": "### **学校通知分发工作流组件**"
      },
      "typeVersion": 1
    },
    {
      "id": "003b88f7-1cc6-4170-94ff-32d25a6bb758",
      "name": "读取通知",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        -280,
        400
      ],
      "parameters": {
        "filters": {
          "fields": [
            {
              "value": "Pending",
              "column": "Status"
            }
          ]
        },
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "=notices-workbook-001"
        }
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "id": "jevPChvDpEJk6W9v",
          "name": "Microsoft Excel account - test"
        }
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2046bf84-b64c-40b9-9270-8bbc4455f878",
  "connections": {
    "Read Notices": {
      "main": [
        [
          {
            "node": "Validate Notice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Notice": {
      "main": [
        [
          {
            "node": "Update Notice Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send WhatsApp Notice": {
      "main": [
        [
          {
            "node": "Update Notice Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Notice Status": {
      "main": [
        []
      ]
    },
    "Validate Notice Data": {
      "main": [
        [
          {
            "node": "Process Notice Distribution",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Prepare Email Content": {
      "main": [
        [
          {
            "node": "Send Email Notice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare WhatsApp Content": {
      "main": [
        [
          {
            "node": "Send WhatsApp Notice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Notice Check - 9 AM": {
      "main": [
        [
          {
            "node": "Read Notices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Notice Distribution": {
      "main": [
        [
          {
            "node": "Prepare Email Content",
            "type": "main",
            "index": 0
          },
          {
            "node": "Prepare WhatsApp Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 杂项

需要付费吗?

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

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

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

作者
Oneclick AI Squad

Oneclick AI Squad

@oneclick-ai

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

外部链接
在 n8n.io 查看

分享此工作流