8
n8n 中文网amn8n.com

PDF报告监控器 - 含GPT-3.5洞察与Slack/邮件告警

中级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 If, Ftp, Code, Slack, OpenAi 等节点。 PDF报告监控器 - 含GPT-3.5洞察与Slack/邮件告警

前置要求
  • Slack Bot Token 或 Webhook URL
  • OpenAI API Key
  • PostgreSQL 数据库连接信息
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "placeholder"
  },
  "nodes": [
    {
      "id": "system-info",
      "name": "警报系统信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        250,
        150
      ],
      "parameters": {
        "content": "## 文档警报系统"
      },
      "typeVersion": 1
    },
    {
      "id": "schedule-check",
      "name": "每 15 分钟检查一次",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        450,
        300
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute",
              "minute": 15
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "check-folder",
      "name": "检查报告文件夹",
      "type": "n8n-nodes-base.ftp",
      "position": [
        650,
        300
      ],
      "parameters": {
        "folder": "/reports/incoming",
        "operation": "list"
      },
      "typeVersion": 1
    },
    {
      "id": "filter-new-pdfs",
      "name": "筛选新 PDF 文件",
      "type": "n8n-nodes-base.if",
      "position": [
        850,
        300
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.name.endsWith('.pdf') }}",
              "value2": "true"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "pdfvector-parse",
      "name": "PDF 向量 - 解析报告",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "position": [
        1050,
        300
      ],
      "parameters": {
        "useLlm": "auto",
        "resource": "document",
        "operation": "parse",
        "documentUrl": "={{ $json.url }}"
      },
      "typeVersion": 1
    },
    {
      "id": "extract-insights",
      "name": "提取关键洞察",
      "type": "n8n-nodes-base.openAi",
      "position": [
        1250,
        300
      ],
      "parameters": {
        "model": "gpt-3.5-turbo",
        "options": {
          "responseFormat": {
            "type": "json_object"
          }
        },
        "messages": {
          "values": [
            {
              "content": "Extract key information from this report:\n\n{{ $json.content }}\n\nIdentify:\n1. Report type and date\n2. Key metrics or KPIs\n3. Important findings or alerts\n4. Action items\n5. Overall sentiment (positive/neutral/negative)\n\nReturn as structured JSON."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "format-alerts",
      "name": "格式化警报",
      "type": "n8n-nodes-base.code",
      "position": [
        1450,
        300
      ],
      "parameters": {
        "functionCode": "const insights = JSON.parse($json.content);\nconst fileName = $node['Check Report Folder'].json.name;\n\n// Determine alert priority\nlet priority = 'normal';\nif (insights.sentiment === 'negative' || insights.alerts?.length > 0) {\n  priority = 'high';\n}\n\n// Format message\nconst slackBlocks = [\n  {\n    type: 'header',\n    text: {\n      type: 'plain_text',\n      text: `📄 New Report: ${insights.reportType || fileName}`\n    }\n  },\n  {\n    type: 'section',\n    fields: [\n      {\n        type: 'mrkdwn',\n        text: `*Date:* ${insights.date || 'Not specified'}`\n      },\n      {\n        type: 'mrkdwn',\n        text: `*Priority:* ${priority}`\n      }\n    ]\n  }\n];\n\nif (insights.metrics) {\n  slackBlocks.push({\n    type: 'section',\n    text: {\n      type: 'mrkdwn',\n      text: `*Key Metrics:*\\n${Object.entries(insights.metrics).map(([k, v]) => `• ${k}: ${v}`).join('\\n')}`\n    }\n  });\n}\n\nif (insights.findings) {\n  slackBlocks.push({\n    type: 'section',\n    text: {\n      type: 'mrkdwn',\n      text: `*Key Findings:*\\n${insights.findings.map(f => `• ${f}`).join('\\n')}`\n    }\n  });\n}\n\nreturn {\n  fileName,\n  insights,\n  priority,\n  slackBlocks,\n  emailContent: insights\n};"
      },
      "typeVersion": 1
    },
    {
      "id": "slack-alert",
      "name": "发送 Slack 警报",
      "type": "n8n-nodes-base.slack",
      "position": [
        1650,
        250
      ],
      "parameters": {
        "blocks": "={{ $json.slackBlocks }}",
        "channel": "#reports",
        "attachments": []
      },
      "typeVersion": 1
    },
    {
      "id": "email-alert",
      "name": "发送邮件警报",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1650,
        350
      ],
      "parameters": {
        "html": "=<h2>New Report Available</h2>\n<p><strong>Report:</strong> {{ $json.fileName }}</p>\n<p><strong>Type:</strong> {{ $json.insights.reportType }}</p>\n<p><strong>Date:</strong> {{ $json.insights.date }}</p>\n\n<h3>Key Metrics</h3>\n<ul>\n{{ Object.entries($json.insights.metrics || {}).map(([k, v]) => `<li>${k}: ${v}</li>`).join('\\n') }}\n</ul>\n\n<h3>Findings</h3>\n<ul>\n{{ ($json.insights.findings || []).map(f => `<li>${f}</li>`).join('\\n') }}\n</ul>\n\n<h3>Action Items</h3>\n<ul>\n{{ ($json.insights.actionItems || []).map(a => `<li>${a}</li>`).join('\\n') }}\n</ul>",
        "subject": "=New Report Alert: {{ $json.insights.reportType }}",
        "toEmail": "team@company.com"
      },
      "typeVersion": 1
    },
    {
      "id": "log-processed",
      "name": "记录已处理报告",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1650,
        450
      ],
      "parameters": {
        "table": "processed_reports",
        "columns": "filename,report_type,processed_at,insights,priority",
        "operation": "insert"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Format Alerts": {
      "main": [
        [
          {
            "node": "Send Slack Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Email Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log Processed Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter New PDFs": {
      "main": [
        [
          {
            "node": "PDF Vector - Parse Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Report Folder": {
      "main": [
        [
          {
            "node": "Filter New PDFs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Key Insights": {
      "main": [
        [
          {
            "node": "Format Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Every 15 Minutes": {
      "main": [
        [
          {
            "node": "Check Report Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Vector - Parse Report": {
      "main": [
        [
          {
            "node": "Extract Key Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - AI 摘要总结, 多模态 AI

需要付费吗?

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

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

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

作者
PDF Vector

PDF Vector

@pdfvector

A fully featured PDF APIs for developers - Parse any PDF or Word document, extract structured data, and access millions of academic papers - all through simple APIs.

外部链接
在 n8n.io 查看

分享此工作流