8
n8n 中文网amn8n.com

我的工作流 2

高级

这是一个Document Extraction, AI Summarization领域的自动化工作流,包含 18 个节点。主要使用 If, Set, Code, Slack, EmailSend 等节点。 通过Slack和邮件使用ScrapeGraphAI监控供应链风险预警

前置要求
  • Slack Bot Token 或 Webhook URL
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "VhEwspDqzu7ssFVE",
  "meta": {
    "instanceId": "f4b0efaa33080e7774e0d9285c40c7abcd2c6f7cf1a8b901fa7106170dd4cda3",
    "templateCredsSetupCompleted": true
  },
  "name": "我的工作流 2",
  "tags": [
    {
      "id": "DxXGubfBzRKh6L8T",
      "name": "Revenue Optimization",
      "createdAt": "2025-07-25T16:24:30.370Z",
      "updatedAt": "2025-07-25T16:24:30.370Z"
    },
    {
      "id": "IxkcJ2IpYIxivoHV",
      "name": "Content Strategy",
      "createdAt": "2025-07-25T12:57:37.677Z",
      "updatedAt": "2025-07-25T12:57:37.677Z"
    },
    {
      "id": "PAKIJ2Mm9EvRcR3u",
      "name": "Trend Monitoring",
      "createdAt": "2025-07-25T12:57:37.670Z",
      "updatedAt": "2025-07-25T12:57:37.670Z"
    },
    {
      "id": "YtfXmaZk44MYedPO",
      "name": "Dynamic Pricing",
      "createdAt": "2025-07-25T16:24:30.369Z",
      "updatedAt": "2025-07-25T16:24:30.369Z"
    }
  ],
  "nodes": [
    {
      "id": "97c1e8d5-3813-4bf6-878a-2f197a7de968",
      "name": "每日风险检查",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -192,
        688
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "793c2693-4f4d-45cb-8d5a-3c4db372b958",
      "name": "抓取供应商 1",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        128,
        592
      ],
      "parameters": {
        "userPrompt": "Extract supplier health indicators from this website. Look for financial news, operational updates, regulatory issues, and any risk factors. Use this schema: { \"supplier_name\": \"Company Name\", \"financial_status\": \"stable/warning/critical\", \"operational_issues\": [\"list of issues\"], \"regulatory_problems\": [\"list of problems\"], \"news_sentiment\": \"positive/neutral/negative\", \"risk_score\": \"1-10\", \"last_updated\": \"date\", \"source_url\": \"url\" }",
        "websiteUrl": "https://example-supplier-1.com/news"
      },
      "typeVersion": 1
    },
    {
      "id": "9a2d5ce5-3155-48ed-850f-37f3dd88344b",
      "name": "抓取供应商 2",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        128,
        736
      ],
      "parameters": {
        "userPrompt": "Extract supplier health indicators from this website. Look for financial news, operational updates, regulatory issues, and any risk factors. Use this schema: { \"supplier_name\": \"Company Name\", \"financial_status\": \"stable/warning/critical\", \"operational_issues\": [\"list of issues\"], \"regulatory_problems\": [\"list of problems\"], \"news_sentiment\": \"positive/neutral/negative\", \"risk_score\": \"1-10\", \"last_updated\": \"date\", \"source_url\": \"url\" }",
        "websiteUrl": "https://example-supplier-2.com/investor-relations"
      },
      "typeVersion": 1
    },
    {
      "id": "2980958d-05b9-4474-a256-fd805acdf673",
      "name": "抓取行业新闻",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        128,
        896
      ],
      "parameters": {
        "userPrompt": "Search for news articles about supply chain disruptions, supplier bankruptcies, regulatory issues, and industry risks. Extract relevant information using this schema: { \"headline\": \"news title\", \"summary\": \"brief summary\", \"impact_level\": \"low/medium/high\", \"affected_suppliers\": [\"list of companies\"], \"risk_category\": \"financial/operational/regulatory/geopolitical\", \"date\": \"publication date\", \"source\": \"news source\" }",
        "websiteUrl": "https://www.reuters.com/business/supply-chain/"
      },
      "typeVersion": 1
    },
    {
      "id": "9b26bc24-88ba-4a74-9481-4c960729cf38",
      "name": "风险评分器",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        688
      ],
      "parameters": {
        "jsCode": "// Aggregate all supplier data and calculate risk scores\nconst supplierData = $input.all();\nconst riskThresholds = {\n  low: 3,\n  medium: 6,\n  high: 8\n};\n\nfunction calculateOverallRisk(supplier) {\n  let riskScore = 0;\n  \n  // Financial status scoring\n  if (supplier.financial_status === 'critical') riskScore += 4;\n  else if (supplier.financial_status === 'warning') riskScore += 2;\n  \n  // Operational issues scoring\n  const operationalIssues = supplier.operational_issues || [];\n  riskScore += Math.min(operationalIssues.length, 3);\n  \n  // Regulatory problems scoring\n  const regulatoryProblems = supplier.regulatory_problems || [];\n  riskScore += Math.min(regulatoryProblems.length * 1.5, 3);\n  \n  // News sentiment scoring\n  if (supplier.news_sentiment === 'negative') riskScore += 2;\n  else if (supplier.news_sentiment === 'neutral') riskScore += 0.5;\n  \n  return Math.min(Math.round(riskScore), 10);\n}\n\nfunction getRiskLevel(score) {\n  if (score >= riskThresholds.high) return 'HIGH';\n  if (score >= riskThresholds.medium) return 'MEDIUM';\n  return 'LOW';\n}\n\nfunction formatRiskReport(suppliers) {\n  const highRiskSuppliers = suppliers.filter(function(s) { return s.overall_risk_score >= riskThresholds.high; });\n  const mediumRiskSuppliers = suppliers.filter(function(s) { return s.overall_risk_score >= riskThresholds.medium && s.overall_risk_score < riskThresholds.high; });\n  \n  let report = '🚨 **SUPPLY CHAIN RISK REPORT**\\n📅 Date: ' + new Date().toLocaleDateString() + '\\n\\n';\n  \n  if (highRiskSuppliers.length > 0) {\n    report += '⚠️ **HIGH RISK SUPPLIERS (' + highRiskSuppliers.length + ')**\\n';\n    for (let i = 0; i < highRiskSuppliers.length; i++) {\n      const supplier = highRiskSuppliers[i];\n      const operationalCount = (supplier.operational_issues || []).length;\n      report += '• ' + supplier.supplier_name + ' (Score: ' + supplier.overall_risk_score + '/10)\\n';\n      report += '  Status: ' + supplier.financial_status + ' | Issues: ' + operationalCount + '\\n';\n    }\n    report += '\\n';\n  }\n  \n  if (mediumRiskSuppliers.length > 0) {\n    report += '⚡ **MEDIUM RISK SUPPLIERS (' + mediumRiskSuppliers.length + ')**\\n';\n    for (let i = 0; i < mediumRiskSuppliers.length; i++) {\n      const supplier = mediumRiskSuppliers[i];\n      report += '• ' + supplier.supplier_name + ' (Score: ' + supplier.overall_risk_score + '/10)\\n';\n    }\n    report += '\\n';\n  }\n  \n  report += '📊 **SUMMARY**\\n';\n  report += 'Total Suppliers Monitored: ' + suppliers.length + '\\n';\n  report += 'High Risk: ' + highRiskSuppliers.length + '\\n';\n  report += 'Medium Risk: ' + mediumRiskSuppliers.length + '\\n';\n  report += 'Low Risk: ' + (suppliers.length - highRiskSuppliers.length - mediumRiskSuppliers.length) + '\\n';\n  \n  return report;\n}\n\n// Process each supplier's data\nconst processedSuppliers = [];\nfor (let i = 0; i < supplierData.length; i++) {\n  const item = supplierData[i];\n  const supplier = item.json.result || item.json;\n  const overallRiskScore = calculateOverallRisk(supplier);\n  const riskLevel = getRiskLevel(overallRiskScore);\n  \n  processedSuppliers.push({\n    supplier_name: supplier.supplier_name || 'Unknown Supplier',\n    financial_status: supplier.financial_status || 'stable',\n    operational_issues: supplier.operational_issues || [],\n    regulatory_problems: supplier.regulatory_problems || [],\n    news_sentiment: supplier.news_sentiment || 'neutral',\n    overall_risk_score: overallRiskScore,\n    risk_level: riskLevel,\n    needs_attention: overallRiskScore >= riskThresholds.medium,\n    assessment_date: new Date().toISOString(),\n    source_url: supplier.source_url || ''\n  });\n}\n\n// Generate summary report\nconst summaryReport = formatRiskReport(processedSuppliers);\n\nconsole.log('Processed ' + processedSuppliers.length + ' suppliers');\nconst highRiskCount = processedSuppliers.filter(function(s) { return s.risk_level === 'HIGH'; }).length;\nconsole.log('High risk suppliers: ' + highRiskCount);\n\nreturn [{\n  json: {\n    suppliers: processedSuppliers,\n    summary_report: summaryReport,\n    high_risk_count: highRiskCount,\n    medium_risk_count: processedSuppliers.filter(function(s) { return s.risk_level === 'MEDIUM'; }).length,\n    total_suppliers: processedSuppliers.length,\n    assessment_timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "97557200-2713-4f26-890e-c4601e203a1c",
      "name": "查找替代方案",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        992,
        560
      ],
      "parameters": {
        "userPrompt": "Find alternative suppliers in manufacturing category. Extract company information using this schema: { \"company_name\": \"name\", \"location\": \"city, state/country\", \"specialties\": [\"list of services\"], \"certifications\": [\"list of certs\"], \"contact_info\": \"email or phone\", \"website\": \"url\", \"estimated_capacity\": \"small/medium/large\", \"quality_rating\": \"1-5 stars\" }",
        "websiteUrl": "https://www.thomasnet.com/suppliers/manufacturing"
      },
      "typeVersion": 1
    },
    {
      "id": "f0122ca7-ae5b-4ffe-9ac2-ce9a4f78b78d",
      "name": "检查警报条件",
      "type": "n8n-nodes-base.if",
      "position": [
        1376,
        720
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "condition-high-risk",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.high_risk_count }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "0ab9cb88-eeab-431e-a04a-cd26c5300018",
      "name": "格式化警报",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        464
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "assignment-alert",
              "name": "alert_message",
              "type": "string",
              "value": "🚨 **URGENT: High Risk Suppliers Detected**\n\n{{ $json.summary_report }}\n\n⚡ **Recommended Actions:**\n• Review contracts with high-risk suppliers\n• Contact alternative suppliers\n• Assess inventory levels\n• Update contingency plans\n\n📞 **Next Steps:**\n1. Schedule emergency procurement meeting\n2. Review supplier performance metrics\n3. Initiate backup supplier evaluation\n\n🕐 Generated: {{ new Date().toLocaleString() }}"
            },
            {
              "id": "assignment-priority",
              "name": "priority",
              "type": "string",
              "value": "={{ $json.high_risk_count >= 2 ? \"CRITICAL\" : \"HIGH\" }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b21e22c8-5c61-4416-b646-6371d46b6500",
      "name": "发送 Slack 警报",
      "type": "n8n-nodes-base.slack",
      "position": [
        2096,
        368
      ],
      "webhookId": "7c498ffe-444f-4506-91a2-c8603e06427c",
      "parameters": {
        "text": "={{ $json.alert_message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#procurement-alerts"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.2
    },
    {
      "id": "ae81a56e-cb26-49ac-bb0b-19326a11c88e",
      "name": "邮件通知采购团队",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2096,
        704
      ],
      "webhookId": "ea0e7113-a71a-4c87-9d94-85c347613f6b",
      "parameters": {
        "options": {
          "attachments": [
            {
              "value": "={{ JSON.stringify($node['Risk Scorer'].json.suppliers.filter(s => s.risk_level === 'HIGH' || s.risk_level === 'MEDIUM'), null, 2) }}",
              "property": "supply_chain_risk_data.json"
            }
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "c168f67c-910d-4ada-9377-0790745fd08f",
      "name": "格式化每日报告",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        864
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "assignment-daily-report",
              "name": "daily_summary",
              "type": "string",
              "value": "📊 **Daily Supply Chain Health Report**\n\n{{ $json.summary_report }}\n\n✅ **All systems monitored successfully**\n📈 **Trend Analysis**: Suppliers performing within acceptable risk parameters\n\n🔄 Next check: Tomorrow at 9:00 AM"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4fbc224c-7fc7-4388-94a9-833137a571f1",
      "name": "发送每日报告",
      "type": "n8n-nodes-base.slack",
      "position": [
        2096,
        864
      ],
      "webhookId": "2dfea5a3-4911-4f2b-8cb3-5bc33dc60112",
      "parameters": {
        "text": "={{ $json.daily_summary }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#supply-chain-updates"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.2
    },
    {
      "id": "19f69bd7-d629-48ef-971f-8e0a4d59d1fa",
      "name": "步骤 1 说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 1198,
        "content": "# 步骤 1:每日触发器 ⏰"
      },
      "typeVersion": 1
    },
    {
      "id": "6b581da0-033c-4ce9-9113-bb50d518c2ff",
      "name": "步骤 2 说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 1198,
        "content": "# 步骤 2:供应商数据收集 🔍"
      },
      "typeVersion": 1
    },
    {
      "id": "28a20162-93f4-47ee-95ef-a31a2570e846",
      "name": "步骤 3 说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 1198,
        "content": "# 步骤 3:风险分析引擎 🧮"
      },
      "typeVersion": 1
    },
    {
      "id": "66e6b608-9c4d-4493-be0b-90a813145cc2",
      "name": "步骤 4 说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 1198,
        "content": "# 步骤 4:替代供应商查找器 🔄"
      },
      "typeVersion": 1
    },
    {
      "id": "a59c8221-0d7d-4fba-b473-55fbf02d15ec",
      "name": "步骤 5 说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 1198,
        "content": "# 步骤 5:警报系统逻辑 🚨"
      },
      "typeVersion": 1
    },
    {
      "id": "8c6b1208-46ba-4e06-b281-3a27a4446fc6",
      "name": "步骤 6 说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1632,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 688,
        "height": 1198,
        "content": "# 步骤 6:多渠道通知 📢"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "13cec458-59b4-43fb-a10b-7bdbfa7e8fc0",
  "connections": {
    "Risk Scorer": {
      "main": [
        [
          {
            "node": "Find Alternatives",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check Alert Conditions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert": {
      "main": [
        [
          {
            "node": "Send Slack Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email Procurement Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Risk Check": {
      "main": [
        [
          {
            "node": "Scrape Supplier 1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Scrape Supplier 2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Scrape Industry News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Alternatives": {
      "main": [
        [
          {
            "node": "Check Alert Conditions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Supplier 1": {
      "main": [
        [
          {
            "node": "Risk Scorer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Supplier 2": {
      "main": [
        [
          {
            "node": "Risk Scorer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Daily Report": {
      "main": [
        [
          {
            "node": "Send Daily Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Industry News": {
      "main": [
        [
          {
            "node": "Risk Scorer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Alert Conditions": {
      "main": [
        [
          {
            "node": "Format Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Daily Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文档提取, AI 摘要总结

需要付费吗?

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

工作流信息
难度等级
高级
节点数量18
分类2
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流