8
n8n 中文网amn8n.com

Quickbook发票提醒

中级

这是一个Invoice Processing领域的自动化工作流,包含 10 个节点。主要使用 Code, EmailSend, Quickbooks, ScheduleTrigger 等节点。 自动化付款提醒,通过邮件发送分组的QuickBooks发票

前置要求
  • 无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "1FISjXuv3wcHwVKc",
  "meta": {
    "instanceId": "e727f992f69a44655d3d4d5a1d4a30ca3ec1573139240bc4d84b17b8f66642c8",
    "templateCredsSetupCompleted": true
  },
  "name": "Quickbook 发票提醒",
  "tags": [],
  "nodes": [
    {
      "id": "d2bb6837-055b-4eba-a34d-4e64a8fabf77",
      "name": "获取未付发票",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        -192,
        416
      ],
      "parameters": {
        "filters": {
          "query": ""
        },
        "resource": "invoice",
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "r3A6wRAzyp859vQL",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7748eaef-b6f5-44fb-99e0-8a1a3e71cd66",
      "name": "发送提醒邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        848,
        416
      ],
      "parameters": {
        "html": "={{ $json.emailBody }}",
        "text": "=",
        "options": {},
        "subject": "=Unpaid Invoice Reminder for : {{$json.customer}}",
        "toEmail": "={{ $json.invoices[0].json.BillEmail.Address }}",
        "fromEmail": "placeholderEmail"
      },
      "credentials": {
        "smtp": {
          "id": "ZSjtbi8UmObTzmbO",
          "name": "SMTP account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ee0eefd1-3bb9-4d6e-8482-90360990b4c4",
      "name": "发票模板",
      "type": "n8n-nodes-base.code",
      "position": [
        432,
        416
      ],
      "parameters": {
        "jsCode": "// This code runs for each item passed to the node.\n// We assume the input is the single item containing the customer and their invoices.\nconst item = $items(\"Get Customer Wise Invoice list\")[0];\n\n// Extract the customer name and the array of invoices\nconst customerName = item.json.customer;\nconst invoices = item.json.invoices;\n\n// --- 1. Process the Invoices ---\n\nlet totalAmountDue = 0;\nlet invoiceRows = ''; // This will hold the HTML for the table rows\n\n// Loop through each invoice to build the table rows and calculate the total amount\nfor (const invoice of invoices) {\n  totalAmountDue += invoice.json.TotalAmt; // Add the invoice amount to the total\n  \n  // Create an HTML table row for the current invoice\n  invoiceRows += `\n    <tr style=\"border-bottom: 1px solid #ddd;\">\n      <td style=\"padding: 12px; text-align: left;\">${invoice.json.DocNumber}</td>\n      <td style=\"padding: 12px; text-align: left;\">${invoice.json.TxnDate}</td>\n      <td style=\"padding: 12px; text-align: left;\">${invoice.json.DueDate}</td>\n      <td style=\"padding: 12px; text-align: right; font-weight: bold;\">$${invoice.json.TotalAmt.toFixed(2)}</td>\n    </tr>\n  `;\n}\n\n// Format the final total to 2 decimal places\nconst formattedTotal = totalAmountDue.toFixed(2);\n\n// --- 2. Build the HTML Email Template ---\n\nconst emailHtml = `\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n      margin: 0;\n      padding: 0;\n      background-color: #f4f4f4;\n    }\n    .email-container {\n      max-width: 600px;\n      margin: 20px auto;\n      background-color: #ffffff;\n      border: 1px solid #e0e0e0;\n      border-radius: 8px;\n      overflow: hidden;\n    }\n    .email-header {\n      background-color: #007bff;\n      color: #ffffff;\n      padding: 20px;\n      text-align: center;\n    }\n    .email-header h1 {\n      margin: 0;\n      font-size: 24px;\n    }\n    .email-body {\n      padding: 30px;\n      line-height: 1.6;\n      color: #333333;\n    }\n    .email-body p {\n      margin: 0 0 15px 0;\n    }\n    .invoice-table {\n      width: 100%;\n      border-collapse: collapse;\n      margin: 20px 0;\n    }\n    .invoice-table th {\n      background-color: #f2f2f2;\n      padding: 12px;\n      text-align: left;\n      border-bottom: 2px solid #ddd;\n      color: #555;\n    }\n    .total-row td {\n      padding: 15px 12px;\n      font-size: 18px;\n      font-weight: bold;\n      border-top: 2px solid #007bff;\n    }\n    .email-footer {\n      text-align: center;\n      padding: 20px;\n      font-size: 12px;\n      color: #888888;\n      background-color: #f4f4f4;\n    }\n    .cta-button {\n      display: inline-block;\n      background-color: #28a745;\n      color: #ffffff;\n      padding: 12px 25px;\n      margin-top: 20px;\n      border-radius: 5px;\n      text-decoration: none;\n      font-weight: bold;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"email-container\">\n    <div class=\"email-header\">\n      <h1>Payment Reminder</h1>\n    </div>\n    <div class=\"email-body\">\n      <p>Dear ${customerName},</p>\n      <p>We're writing to kindly remind you about the outstanding balance on your account. We have listed the unpaid invoices below for your convenience.</p>\n      \n      <table class=\"invoice-table\">\n        <thead>\n          <tr>\n            <th style=\"width: 25%;\">Invoice #</th>\n            <th style=\"width: 25%;\">Date</th>\n            <th style=\"width: 25%;\">Due Date</th>\n            <th style=\"width: 25%; text-align: right;\">Amount</th>\n          </tr>\n        </thead>\n        <tbody>\n          ${invoiceRows}\n        </tbody>\n      </table>\n      \n      <table style=\"width: 100%; text-align: right;\">\n        <tbody>\n          <tr class=\"total-row\">\n            <td>Total Amount Due: $${formattedTotal}</td>\n          </tr>\n        </tbody>\n      </table>\n      \n      <p>If you have already made the payment, please disregard this email. If you have any questions about your invoices, feel free to contact us at any time.</p>\n      <p>Thank you for your business!</p>\n      <a href=\"https://your-payment-portal-link.com\" class=\"cta-button\">Pay Now</a>\n    </div>\n    <div class=\"email-footer\">\n      <p>Your Company Name | 123 Business Rd, Business City, 12345</p>\n    </div>\n  </div>\n</body>\n</html>\n`;\n\n// --- 3. Return the HTML for the next node ---\n// The generated HTML is placed in the 'emailBody' property\n// This can be easily used in the 'HTML' field of a 'Send Email' node with an expression like: {{$json.emailBody}}\nitem.json.emailBody = emailHtml;\n\nreturn item;"
      },
      "typeVersion": 2
    },
    {
      "id": "f7ffa78f-3f3a-413a-a2b9-89ab743dfd65",
      "name": "获取按客户分类的发票列表",
      "type": "n8n-nodes-base.code",
      "position": [
        176,
        416
      ],
      "parameters": {
        "jsCode": "const getInvoices = $items(\"Get Unpaid Invoices\");\n\nconst invoices = []\nconst customerId = getInvoices[0].json.CustomerRef.value;\nconst customerName = getInvoices[0].json.CustomerRef.name;\n\nfor (const item of getInvoices) {\n  // Access the invoices array from the JSON property of the current item\n  \n    if(customerId == item.json.CustomerRef.value && item.json.Balance > 0) {\n      invoices.push(item)\n    }\n  \n}\n\n\nreturn {\n      \"customer\": customerName,\n      \"customerId\": customerId,\n      \"invoices\": invoices\n    };"
      },
      "typeVersion": 2
    },
    {
      "id": "3cc14603-de0a-42e1-a495-f4790ff14d4d",
      "name": "调度器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -592,
        416
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a6f70c2e-c4f4-416d-9b38-8c741a51dd94",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        -352
      ],
      "parameters": {
        "color": 6,
        "width": 1104,
        "height": 1648,
        "content": "# 使用动态发票表格的自动化 QuickBooks 付款提醒"
      },
      "typeVersion": 1
    },
    {
      "id": "b1d5e894-1873-49da-9249-a837264b133a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        256
      ],
      "parameters": {
        "color": 4,
        "width": 288,
        "height": 304,
        "content": "### 1. 设置您的计划"
      },
      "typeVersion": 1
    },
    {
      "id": "8345f2e0-1628-4e87-83c2-3aa555fa7887",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        176
      ],
      "parameters": {
        "color": 4,
        "width": 304,
        "height": 400,
        "content": "### 2. 连接您的 QuickBooks 账户"
      },
      "typeVersion": 1
    },
    {
      "id": "6a8ffc03-290d-4940-8f5c-cd792af6d5f7",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        192
      ],
      "parameters": {
        "color": 4,
        "width": 304,
        "height": 368,
        "content": "### 3. 个性化您的电子邮件模板"
      },
      "typeVersion": 1
    },
    {
      "id": "b16553f5-200c-40ee-b106-4c474273b45c",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        192
      ],
      "parameters": {
        "color": 4,
        "width": 304,
        "height": 368,
        "content": "### 4. 配置与激活"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f9793645-ce80-4bfb-9f7b-3e2dbe6a59ec",
  "connections": {
    "Scheduler": {
      "main": [
        [
          {
            "node": "Get Unpaid Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Template": {
      "main": [
        [
          {
            "node": "Send Reminder Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Unpaid Invoices": {
      "main": [
        [
          {
            "node": "Get Customer Wise Invoice list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Customer Wise Invoice list": {
      "main": [
        [
          {
            "node": "Invoice Template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 发票处理

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流