8
n8n 中文网amn8n.com

带AI洞察的财务月度报告

中级

这是一个Document Extraction, AI Summarization领域的自动化工作流,包含 7 个节点。主要使用 Gmail, OpenAi, Function, GoogleSheets, ScheduleTrigger 等节点。 使用Google Sheets、GPT-4分析和Gmail自动化月度财务报告

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "bUnFjkLevdnP1zo7",
  "meta": {
    "instanceId": "a287613f1596da776459594685fbf4e2b4a12124f80ab8c8772f5e37bff103ae",
    "templateCredsSetupCompleted": true
  },
  "name": "带 AI 洞察的财务月度报告",
  "tags": [],
  "nodes": [
    {
      "id": "c9b7416f-8164-4869-8c8a-3ae49f868334",
      "name": "1. 获取财务交易(Google Sheets)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        380,
        140
      ],
      "parameters": {
        "range": "FinanceSummary!A:E",
        "options": {},
        "sheetId": "<YOUR_GOOGLE_SHEET_ID_HERE>"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "MSnszF5oRAiSGHDo",
          "name": "temp"
        }
      },
      "description": "Reads monthly finance transaction data from the specified Google Sheet.",
      "typeVersion": 2
    },
    {
      "id": "6b2dbe34-e3f0-4ca3-b5ca-3a6c3e027ad2",
      "name": "2. 筛选上月交易",
      "type": "n8n-nodes-base.function",
      "position": [
        600,
        140
      ],
      "parameters": {
        "functionCode": "// Filter transactions for the previous month\nconst rows = items.map(item => item.json);\n\nconst now = new Date();\nconst lastMonthStart = new Date(now.getFullYear(), now.getMonth() - 1, 1); // First day of previous month\nconst lastMonthEnd = new Date(now.getFullYear(), now.getMonth(), 0);   // Last day of previous month\n\nconst filtered = rows.filter(row => {\n  // Ensure 'Date' column exists and is a valid date format\n  if (!row.Date) return false;\n  const date = new Date(row.Date); \n  return date >= lastMonthStart && date <= lastMonthEnd;\n});\n\nreturn filtered.map(row => ({ json: row }));"
      },
      "description": "Filters the raw data to only include transactions from the previous full month.",
      "typeVersion": 1
    },
    {
      "id": "869519eb-0879-4f0d-8a21-4035b69df097",
      "name": "3. 生成 AI 财务洞察",
      "type": "n8n-nodes-base.openAi",
      "position": [
        820,
        140
      ],
      "parameters": {
        "model": "gpt-4",
        "prompt": "You are a finance assistant. Analyze the following transaction data. Calculate the total income and total expense for the period. Then, provide 3 concise bullet-point financial insights based on the data. Structure your output clearly:\n\nTotal Income: [Amount]\nTotal Expense: [Amount]\nKey Insights:\n- [Insight 1]\n- [Insight 2]\n- [Insight 3]\n\nTransactions:\n{{JSON.stringify($json, null, 2)}}",
        "options": {},
        "requestOptions": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "WbMi3ZLLBnECFAAV",
          "name": "Temp"
        }
      },
      "description": "Uses OpenAI (GPT-4) to generate a summary of income, expenses, and key financial insights.",
      "typeVersion": 1
    },
    {
      "id": "d8d4588b-9761-4bef-a427-ff3282c1b12e",
      "name": "4. 发送月度财务报告邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1040,
        140
      ],
      "parameters": {
        "subject": "Monthly Finance Summary and AI Insights",
        "additionalFields": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "QFfaHpKmgq4YPiRN",
          "name": "Temp"
        }
      },
      "description": "Composes and sends the monthly finance report email, including transaction details and AI insights.",
      "typeVersion": 1
    },
    {
      "id": "f7d8accf-7532-4289-b564-4d2e566ff83b",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        160,
        140
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9931672d-4382-490b-8ed8-68f84aba39c2",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        80
      ],
      "parameters": {
        "color": 3,
        "width": 1220,
        "height": 240,
        "content": "## 流程"
      },
      "typeVersion": 1
    },
    {
      "id": "31db7ae7-de61-4b2e-b38b-89d33bf0ee5c",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        80
      ],
      "parameters": {
        "color": 4,
        "width": 680,
        "height": 1680,
        "content": "# 工作流文档:带 AI 洞察的财务月度报告"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "fbd3aed3-1704-40c9-a85c-55cfec0e33bc",
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "1. Get Finance Transactions (Google Sheets)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Generate AI Financial Insights": {
      "main": [
        [
          {
            "node": "4. Send Monthly Finance Report Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Filter Previous Month Transactions": {
      "main": [
        [
          {
            "node": "3. Generate AI Financial Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Get Finance Transactions (Google Sheets)": {
      "main": [
        [
          {
            "node": "2. Filter Previous Month Transactions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Marth

Marth

@marth

Simplifying Business with Smart Automation. I create and share user-friendly, highly efficient n8n workflow templates for SMEs, focusing on digital marketing, sales, and operational excellence. Get ready to automate, innovate, and elevate your business. Connect me on Linkedin for custom solutions.

外部链接
在 n8n.io 查看

分享此工作流