8
n8n 中文网amn8n.com

使用 Jotform 和 QuickBooks 为客户生成发票并发送提醒

高级

这是一个自动化工作流,包含 48 个节点。主要使用 If, Set, Code, Switch, Webhook 等节点。 使用Jotform和QuickBooks生成发票并发送AI摘要提醒

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • OpenAI API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "KQbawPw1ywuc0eGO",
  "meta": {
    "instanceId": "3549451ca835035557d5dc1c3d9e6ba924e7314534a74c901f66b91f9ef6023e",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 Jotform 和 QuickBooks 为客户生成发票并发送提醒",
  "tags": [],
  "nodes": [
    {
      "id": "0ee2cee9-681e-45c7-9216-dec123742bc2",
      "name": "接收表单提交",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -464,
        0
      ],
      "webhookId": "fdbfa94e-4df0-4fe4-86b9-41f20ba83079",
      "parameters": {
        "path": "requests",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "92a0d734-7408-42ec-942a-5f63ec5f64bb",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        320,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bfa24559-7702-4ebf-909d-c5c2a60ad817",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json }}",
              "rightValue": 0
            },
            {
              "id": "b4301cfe-a22a-490f-a72b-50d266bc1c5e",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.Id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "17d10f15-2a8a-4186-9a72-34d3770331bb",
      "name": "获取产品",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        1248,
        0
      ],
      "parameters": {
        "limit": 1,
        "filters": {
          "query": "=WHERE name = '{{ $json.item.name }}'"
        },
        "resource": "item",
        "operation": "getAll"
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cbd7276e-0569-4062-ae59-680d3236e8f6",
      "name": "创建发票",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        1856,
        0
      ],
      "parameters": {
        "Line": [
          {
            "Amount": 1,
            "itemId": "={{ $json.item.id }}",
            "DetailType": "SalesItemLineDetail",
            "Description": "Jotform submission"
          }
        ],
        "resource": "invoice",
        "operation": "create",
        "CustomerRef": "={{ $json.customer.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6b28414b-72b8-4e26-adea-402c9e59163d",
      "name": "发送发票",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        2160,
        0
      ],
      "parameters": {
        "email": "={{ $('Add item id').item.json.customer.email }}",
        "resource": "invoice",
        "invoiceId": "={{ $json.Id }}",
        "operation": "send"
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "470f1239-6ac7-4d01-bf20-1537618d65dc",
      "name": "检查客户是否存在",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        112,
        0
      ],
      "parameters": {
        "limit": 1,
        "filters": {
          "query": "=Where PrimaryEmailAddr = '{{ $json.customer.email }}'"
        },
        "operation": "getAll"
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "acc16aeb-cf5c-4d02-9cd6-c8d847b94fa0",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 接收提交"
      },
      "typeVersion": 1
    },
    {
      "id": "89deb6f7-daed-472f-bd2e-d8ac900d9d67",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 320,
        "content": "## 检查客户是否存在"
      },
      "typeVersion": 1
    },
    {
      "id": "5b37fa39-fd2f-4059-b588-d381b10b0f93",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 336,
        "content": "## 客户存在"
      },
      "typeVersion": 1
    },
    {
      "id": "0cd6a217-c27c-4eb8-80c7-6f2c8042f592",
      "name": "创建客户",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        608,
        176
      ],
      "parameters": {
        "operation": "create",
        "displayName": "=",
        "additionalFields": {
          "BillAddr": {
            "details": {
              "City": "={{ $('Format data').item.json.address.city }}",
              "Line1": "={{ $('Format data').item.json.address.line1 }}",
              "PostalCode": "={{ $('Format data').item.json.address.postalZipCode }}"
            }
          },
          "GivenName": "={{ $('Format data').item.json.customer.name }}",
          "PrimaryPhone": "={{ $('Format data').item.json.customer.phone }}",
          "PrimaryEmailAddr": "={{ $('Format data').item.json.customer.email }}"
        }
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3af11658-34ae-46db-b0ef-591842598676",
      "name": "更新客户",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        608,
        -192
      ],
      "parameters": {
        "operation": "update",
        "customerId": "={{ $json.Id }}",
        "updateFields": {
          "BillAddr": {
            "details": {
              "City": "={{ $('Format data').item.json.address.city }}",
              "Line1": "={{ $('Format data').item.json.address.line1 }}",
              "PostalCode": "={{ $('Format data').item.json.address.postalZipCode }}"
            }
          },
          "GivenName": "={{ $('Format data').item.json.customer.name }}",
          "PrimaryPhone": "={{ $('Format data').item.json.customer.phone }}"
        }
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0240fabc-19b9-4fac-a4f8-39ca7eca10ed",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 320,
        "content": "## 客户不存在"
      },
      "typeVersion": 1
    },
    {
      "id": "55057374-89e8-4d09-99ef-03e6431b12e5",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 获取项目"
      },
      "typeVersion": 1
    },
    {
      "id": "a9f1d66c-3a73-47a3-8c47-2aed6585a29b",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1776,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 创建发票"
      },
      "typeVersion": 1
    },
    {
      "id": "d676861e-120a-458b-839e-2c1add976bec",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 发送发票"
      },
      "typeVersion": 1
    },
    {
      "id": "77305ded-214f-4d16-8993-70f6fda69f8e",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -416
      ],
      "parameters": {
        "width": 1072,
        "height": 1280,
        "content": "## 使用 Jotform 和 QuickBooks 为客户生成发票并发送提醒"
      },
      "typeVersion": 1
    },
    {
      "id": "48bc6ee7-aff6-4197-840c-ddaea49b6336",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 格式化数据"
      },
      "typeVersion": 1
    },
    {
      "id": "d1f516d0-bed4-4946-80aa-701809317d07",
      "name": "格式化数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        0
      ],
      "parameters": {
        "jsCode": "function extractAddressData(text) {\n  const regex = /Street Address:\\s*([^<]+)<br>Street Address Line 2:\\s*([^<]+)<br>City:\\s*([^<]+)<br>State \\/ Province:\\s*([^<]+)<br>Postal \\/ Zip Code:\\s*([^<]+)<br>Country:\\s*([^<]+)<br>/;\n  const matches = text.match(regex);\n  \n  if (matches) {\n    return {\n      line1: matches[1].trim(),\n      line2: matches[2].trim(),\n      city: matches[3].trim(),\n      stateProvince: matches[4].trim(),\n      postalZipCode: matches[5].trim(),\n      country: matches[6].trim()\n    };\n  }\n  \n  return {\n    line1: null,\n    line2: null,\n    city: null,\n    stateProvince: null,\n    postalZipCode: null,\n    country: null\n  }\n}\n\nreturn {\n  address: extractAddressData($input.first().json.body.billingAddress),\n  customer: {\n    name: $input.first().json.body.name,\n    email: $input.first().json.body.email,\n    phone: $input.first().json.body.phone\n  },\n  item: {\n    name: $input.first().json.body.itemName\n  }\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "91b01b8d-8a27-4867-8f45-1739c0ada19d",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 添加客户 ID"
      },
      "typeVersion": 1
    },
    {
      "id": "7ef2bbb3-5ae0-4859-8b0b-d27c4cf1db40",
      "name": "添加客户 ID",
      "type": "n8n-nodes-base.code",
      "position": [
        944,
        0
      ],
      "parameters": {
        "jsCode": "return {\n  ...$('Format data').first().json,\n  customer: {\n    ...$('Format data').first().json.customer,\n    id: $input.first().json.Id\n  }\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "798cc352-8cb1-44b8-9a4d-eb6f861578de",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1472,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 添加项目 ID"
      },
      "typeVersion": 1
    },
    {
      "id": "fb80d92a-9bb5-4090-8c6a-e2cc7aa47ca8",
      "name": "添加项目 ID",
      "type": "n8n-nodes-base.code",
      "position": [
        1552,
        0
      ],
      "parameters": {
        "jsCode": "return {\n  ...$('Add customer id').first().json,\n  item: {\n    ...$('Add customer id').first().json.item,\n    id: $input.first().json.Id\n  }\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "01b200fe-27ae-482d-977c-c786c3c890b8",
      "name": "添加提醒配置",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        704
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"dataTableId\": \"\",\n  \"reminderIntervalsInDays\": [2, 3, 5],\n  isInvoiceTrigger: {{ $json[\"Day of week\"] ? false : true }}\n}\n "
      },
      "typeVersion": 3.4
    },
    {
      "id": "82442769-b159-4420-907e-5b84da107365",
      "name": "发送提醒邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2928,
        1072
      ],
      "webhookId": "8f9ba8d7-7a97-4926-b640-8dc93c30eed8",
      "parameters": {
        "html": "=<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      color: #333;\n      line-height: 1.6;\n    }\n    .container {\n      width: 100%;\n      max-width: 600px;\n      margin: 0 auto;\n      padding: 20px;\n      border: 1px solid #f1f1f1;\n      border-radius: 5px;\n      background-color: #f9f9f9;\n    }\n    .header {\n      text-align: center;\n      background-color: #007bff;\n      color: white;\n      padding: 10px;\n      border-radius: 5px;\n    }\n    .footer {\n      text-align: center;\n      color: #777;\n      font-size: 0.8em;\n      margin-top: 20px;\n    }\n    .button {\n      background-color: #28a745;\n      color: white;\n      text-decoration: none;\n      padding: 10px 20px;\n      border-radius: 5px;\n      display: inline-block;\n      margin-top: 20px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h2>Invoice Reminder: {{ $json.DocNumber }}</h2>\n    </div>\n    \n    <p>Dear,</p>\n    \n    <p>This is a friendly reminder that your invoice with us is due soon. We kindly ask you to review and complete the payment as soon as possible to avoid any delays.</p>\n    \n    <p><strong>Invoice Number:</strong> {{ $json.DocNumber }}</p>\n    <p><strong>Due Date:</strong> {{ $json.DueDate }}</p>\n    \n    <p>Please click the button below to view and pay your invoice:</p>\n    \n    <a href=\"{{ $json.InvoiceLink }}\" class=\"button\">View & Pay Invoice</a>\n    \n    <p>Thank you for your prompt attention to this matter. If you have any questions or need assistance, feel free to contact us.</p>\n    \n    <p>Best regards, <br>\n    [Your Company Name] <br>\n    [Your Contact Information]</p>\n    \n    <div class=\"footer\">\n      <p>&copy; {{ $now.year }} [Your Company Name]. All rights reserved.</p>\n    </div>\n  </div>\n</body>\n</html>\n",
        "options": {},
        "subject": "=Friendly Reminder: Your Invoice is Due Soon – {{ $json.DocNumber }}",
        "toEmail": "={{ $json.BillEmail.Address }}",
        "fromEmail": "reminders@example.com"
      },
      "credentials": {
        "smtp": {
          "id": "awV8UBK3MYzosMxe",
          "name": "Mailtrap SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e3ae7c0a-234e-453b-848e-e767ff3e9782",
      "name": "将发票 ID 插入数据库",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1664,
        512
      ],
      "parameters": {
        "columns": {
          "value": {
            "currency": "={{ $('Send the invoice').item.json.CurrencyRef.value }}",
            "invoiceId": "={{ $('Send the invoice').item.json.Id }}",
            "remindersSent": 0,
            "remainingAmount": "={{ $('Send the invoice').item.json.Balance }}"
          },
          "schema": [
            {
              "id": "invoiceId",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "invoiceId",
              "defaultMatch": false
            },
            {
              "id": "remainingAmount",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "remainingAmount",
              "defaultMatch": false
            },
            {
              "id": "currency",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "currency",
              "defaultMatch": false
            },
            {
              "id": "remindersSent",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "remindersSent",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "optimizeBulk": false
        },
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Add reminders config').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e0665a6-4f7a-44b6-9869-96dd33bec396",
      "name": "获取发票",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1664,
        880
      ],
      "parameters": {
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Add reminders config').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2a9f0ce2-e79a-4fb6-8a0f-3a1215b7261e",
      "name": "获取发票",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        2368,
        1104
      ],
      "parameters": {
        "resource": "invoice",
        "invoiceId": "={{ $json.invoiceId }}"
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "E1S8XZZk9iMCPDSN",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "732054e0-e0ce-4c90-a519-21f0e56c94ce",
      "name": "如果2",
      "type": "n8n-nodes-base.if",
      "position": [
        1312,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "82853a4e-d488-49cd-8e36-ba1a737c519b",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isInvoiceTrigger }}",
              "rightValue": "0"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2d070d34-2b5a-4126-82c3-18ea4ddfd308",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2736,
        544
      ],
      "parameters": {
        "text": "={{ $('Get today's sent reminders').all() }}",
        "options": {
          "systemMessage": "=You are an AI assistant that generates a daily reminder summary for invoices. You will receive a list of invoice data and your task is to summarize how many reminders have been sent for each invoice today.\n\nInput Data:\nThe input data is a list of invoices with the following fields:\n- remainingAmount: The remaining amount the customer still needs to pay.\n- currency: The currency of the remaining amount (e.g., USD, EUR).\n- remindersSent: The total number of reminders that have been sent for this invoice.\n\nGoal:\n1- Summarize the reminders sent today:\n- Count how many reminders have been sent for all invoices provided in the input.\n\n2- Generate a professional HTML email summary:\n- Use the information from the invoices to create a summary in HTML format.\n- Include a greeting for the team (e.g., \"Sales Team\", \"Finance Team\").\n- Display a total count of reminders sent today.\n- Include invoice-level details such as invoiceId, remainingAmount, currency, and remindersSent.\n\nFormatting Guidelines:\n1- The summary should always be structured as an HTML email.\n2- The summary should be clear, readable, and professional.\n3- You may choose the layout that feels most appropriate, but always include:\n  - A greeting (e.g., \"Dear Team,\").\n  - A total number of reminders sent today.\n  - A list of invoices with invoiceId, remainingAmount, currency, and remindersSent.\n4- Closing with generic sign-off.\n\nExample input:\n[\n  {\n    \"id\": 70,\n    \"createdAt\": \"2025-10-10T16:50:54.851Z\",\n    \"updatedAt\": \"2025-10-15T16:50:54.851Z\",\n    \"invoiceId\": \"158\",\n    \"remainingAmount\": 10,\n    \"currency\": \"USD\",\n    \"remindersSent\": 5\n  },\n  {\n    \"id\": 80,\n    \"createdAt\": \"2025-10-12T17:50:54.851Z\",\n    \"updatedAt\": \"2025-10-15T16:50:54.851Z\",\n    \"invoiceId\": \"160\",\n    \"remainingAmount\": 30,\n    \"currency\": \"EUR\",\n    \"remindersSent\": 3\n  }\n]\n\nExample of Expected Output:\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  <title>Reminder Summary for Today</title>\n  <style>\n    body { font-family: Arial, sans-serif; color: #333; line-height: 1.6; }\n    .table { width: 100%; margin-top: 20px; border-collapse: collapse; }\n    .table th, .table td { border: 1px solid #ddd; padding: 8px; text-align: left; }\n    .table th { background-color: #f2f2f2; }\n    .summary { font-size: 16px; margin-top: 20px; }\n  </style>\n</head>\n<body>\n  <div class=\"content\">\n    <p>Dear Sales Team,</p>\n    \n    <p>Here is a summary of the reminders sent today:</p>\n    \n    <div class=\"summary\">\n      <strong>Total reminders sent today: 2</strong>\n    </div>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Invoice ID</th>\n          <th>Remaining Amount</th>\n          <th>Currency</th>\n          <th>Total Reminders Sent</th>\n        </tr>\n      </thead>\n      <tbody>\n        <tr>\n          <td>158</td>\n          <td>$10.00</td>\n          <td>USD</td>\n          <td>5</td>\n        </tr>\n        <tr>\n          <td>160</td>\n          <td>€30.00</td>\n          <td>EUR</td>\n          <td>3</td>\n        </tr>\n      </tbody>\n    </table>\n\n    <p>If you need further details, feel free to reach out!</p>\n\n    <p>Best regards,<br>AI Assistant</p>\n  </div>\n</body>\n</html>"
        },
        "promptType": "define"
      },
      "executeOnce": true,
      "typeVersion": 2.2
    },
    {
      "id": "7937ae1d-7795-43e6-8a46-7683e8c9b887",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2736,
        752
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ns8LVe1zpSS3Kw9p",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d85b60a1-eee2-4264-9872-3ba1aa080fd6",
      "name": "发送已发送提醒摘要",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        3008,
        544
      ],
      "webhookId": "8f9ba8d7-7a97-4926-b640-8dc93c30eed8",
      "parameters": {
        "html": "={{ $json.output }}",
        "options": {},
        "subject": "=Summary of today's reminders sent",
        "toEmail": "=sales@example.com",
        "fromEmail": "reminders@example.com"
      },
      "credentials": {
        "smtp": {
          "id": "awV8UBK3MYzosMxe",
          "name": "Mailtrap SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "2adb26b7-138d-47ac-9994-f41734a08bb1",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2672,
        1120
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "send now",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "df179cc3-60b8-4b49-9fb7-0adabcc3e394",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.Balance > 0 && DateTime.fromISO($('Loop over invoices').item.json.updatedAt).plus($('Add reminders config').item.json.reminderIntervalsInDays[$('Loop over invoices').item.json.remindersSent], 'days').format('yyyy-MM-dd') == $now.format('yyyy-MM-dd') }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "already paid ",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cf03d75d-6560-42ed-8293-3d5e9399b9e3",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.Balance == 0 }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "send later",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "81cb838e-79c8-4c92-964f-f7f5cd44a498",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": true,
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "1e7f2060-d40c-4286-8dcc-8ba10e7e305a",
      "name": "计划提醒触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        608,
        704
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2a099299-21f0-4cab-be4d-9681b3b2275c",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        576
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 320,
        "content": "## 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "e0a1ff93-c702-4d33-9f4e-0ddd7f1100c9",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 368,
        "content": "## 添加提醒配置"
      },
      "typeVersion": 1
    },
    {
      "id": "b9bd6ddb-e0c3-4854-8c8b-4a22b38bdd2b",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 368,
        "content": "## 检查触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "77cb167f-0c90-4aa4-b020-c77b835a26d1",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 336,
        "content": "## 将发票插入数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "d31000ab-9d9d-4227-9a93-01036c923d9a",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        736
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 336,
        "content": "## 获取所有发票"
      },
      "typeVersion": 1
    },
    {
      "id": "56b19a69-6d11-4076-9e61-6356bd2adfa2",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        752
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 320,
        "content": "## 遍历发票"
      },
      "typeVersion": 1
    },
    {
      "id": "e91fe671-1908-49b9-8b62-e84cd4fe74c5",
      "name": "遍历发票",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2016,
        880
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "7084224a-1b22-4104-bf1b-063591afc78f",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2272,
        544
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 352,
        "content": "## 获取已发送提醒"
      },
      "typeVersion": 1
    },
    {
      "id": "c81a0b9a-e704-4887-8510-cb8809ee3039",
      "name": "便签18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2272,
        944
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 368,
        "content": "## 获取发票详情"
      },
      "typeVersion": 1
    },
    {
      "id": "ce3e2b9c-f7b7-4d45-a92d-df893eec233f",
      "name": "获取今天已发送的提醒",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2368,
        688
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "lastSentAt",
              "keyValue": "={{ $now.startOf('day').toUTC().toString() }}",
              "condition": "gte"
            }
          ]
        },
        "matchType": "allConditions",
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Add reminders config').item.json.dataTableId }}"
        }
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "f2327c4c-3e7d-4c77-89ac-a3a8ec26c10e",
      "name": "便签19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2624,
        416
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 480,
        "content": "## 汇总已发送提醒并发送电子邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "793fa0f1-ac9e-47f0-bc79-898740e607c0",
      "name": "增加已发送提醒次数",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3136,
        1072
      ],
      "parameters": {
        "columns": {
          "value": {
            "lastSentAt": "={{ $now.toISO() }}",
            "remindersSent": "={{ $('Loop over invoices').item.json.remindersSent + 1 }} "
          },
          "schema": [
            {
              "id": "invoiceId",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "invoiceId",
              "defaultMatch": false
            },
            {
              "id": "remainingAmount",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "remainingAmount",
              "defaultMatch": false
            },
            {
              "id": "currency",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "currency",
              "defaultMatch": false
            },
            {
              "id": "remindersSent",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "remindersSent",
              "defaultMatch": false
            },
            {
              "id": "lastSentAt",
              "type": "dateTime",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "lastSentAt",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "invoiceId",
              "keyValue": "={{ $('Loop over invoices').item.json.invoiceId }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Add reminders config').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "756cbd66-5cba-409e-9fda-b502389e549f",
      "name": "删除发票",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3616,
        1232
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $('Loop over invoices').item.json.id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "deleteRows",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Add reminders config').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8595b67d-afc5-432b-a71e-2129ec1086b5",
      "name": "如果3",
      "type": "n8n-nodes-base.if",
      "position": [
        3344,
        1072
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f7c9422b-bfd2-4006-9d81-d2332e95532a",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.remindersSent >= $('Add reminders config').item.json.reminderIntervalsInDays.length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "36acca5c-6e26-4694-bf3a-f32e5a2393a2",
      "name": "便签20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2624,
        944
      ],
      "parameters": {
        "color": 7,
        "width": 1184,
        "height": 480,
        "content": "## 发送提醒逻辑"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "Receive form submission": [
      {
        "json": {
          "body": {
            "name": "Adrian Mathews",
            "email": "gexupariq@mailinator.com",
            "phone": "(116) 777-9916",
            "itemName": "Design",
            "billingAddress": "Street Address: Nulla quia debitis est quam facilis amet enim cupidatat officia autem consequatur qui quis dolorem<br>Street Address Line 2: Possimus perferendis ad veritatis quia animi<br>City: Voluptatibus eveniet harum unde dolor doloremque cumque dol<br>State / Province: Reprehenderit rerum voluptas magni ut minim ad deleniti eni<br>Postal / Zip Code: 17167<br>Country: Seychelles<br>"
          },
          "query": {},
          "params": {},
          "headers": {
            "host": "d1e9c8896723.ngrok-free.app",
            "accept": "*/*",
            "referer": "https://submit.jotform.com",
            "newrelic": "eyJ2IjpbMCwxXSwiZCI6eyJ0eSI6IkFwcCIsImFjIjoiNjkxNjIwIiwiYXAiOiIyMzAwNjE1MDQiLCJpZCI6IjA4ZDNjNWMxYzllOTFjOTUiLCJ0ciI6ImJlYjVkMjFhZGM5NDg0YzQiLCJ0eCI6ImJlYjVkMjFhZGM5NDg0YzQiLCJwciI6MS4zODg2NCwic2EiOnRydWUsInRpIjoxNzYwNTI5MDQ3NjY5fX0=",
            "tracestate": "691620@nr=0-0-691620-230061504-08d3c5c1c9e91c95-beb5d21adc9484c4-1-1.388638-1760529047669",
            "user-agent": "Mozilla/5.0 (api.jotform.com; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13",
            "traceparent": "00-0000000000000000beb5d21adc9484c4-08d3c5c1c9e91c95-01",
            "content-type": "application/json",
            "content-length": "517",
            "accept-encoding": "deflate, gzip, br, zstd",
            "x-forwarded-for": "35.222.57.81",
            "x-forwarded-host": "d1e9c8896723.ngrok-free.app",
            "x-forwarded-proto": "https",
            "jf-trace-parent-id": "bd412a79ce24cd1e"
          },
          "webhookUrl": "http://localhost:5678/webhook-test/requests",
          "executionMode": "test"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "104104d2-9b18-4249-a5af-1a103ab2ec15",
  "connections": {
    "92a0d734-7408-42ec-942a-5f63ec5f64bb": {
      "main": [
        [
          {
            "node": "3af11658-34ae-46db-b0ef-591842598676",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "0cd6a217-c27c-4eb8-80c7-6f2c8042f592",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "732054e0-e0ce-4c90-a519-21f0e56c94ce": {
      "main": [
        [
          {
            "node": "e3ae7c0a-234e-453b-848e-e767ff3e9782",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "9e0665a6-4f7a-44b6-9869-96dd33bec396",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8595b67d-afc5-432b-a71e-2129ec1086b5": {
      "main": [
        [
          {
            "node": "756cbd66-5cba-409e-9fda-b502389e549f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e91fe671-1908-49b9-8b62-e84cd4fe74c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2adb26b7-138d-47ac-9994-f41734a08bb1": {
      "main": [
        [
          {
            "node": "82442769-b159-4420-907e-5b84da107365",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "756cbd66-5cba-409e-9fda-b502389e549f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e91fe671-1908-49b9-8b62-e84cd4fe74c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2d070d34-2b5a-4126-82c3-18ea4ddfd308": {
      "main": [
        [
          {
            "node": "d85b60a1-eee2-4264-9872-3ba1aa080fd6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fb80d92a-9bb5-4090-8c6a-e2cc7aa47ca8": {
      "main": [
        [
          {
            "node": "cbd7276e-0569-4062-ae59-680d3236e8f6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d1f516d0-bed4-4946-80aa-701809317d07": {
      "main": [
        [
          {
            "node": "470f1239-6ac7-4d01-bf20-1537618d65dc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9e0665a6-4f7a-44b6-9869-96dd33bec396": {
      "main": [
        [
          {
            "node": "e91fe671-1908-49b9-8b62-e84cd4fe74c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "756cbd66-5cba-409e-9fda-b502389e549f": {
      "main": [
        [
          {
            "node": "e91fe671-1908-49b9-8b62-e84cd4fe74c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7ef2bbb3-5ae0-4859-8b0b-d27c4cf1db40": {
      "main": [
        [
          {
            "node": "17d10f15-2a8a-4186-9a72-34d3770331bb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2a9f0ce2-e79a-4fb6-8a0f-3a1215b7261e": {
      "main": [
        [
          {
            "node": "2adb26b7-138d-47ac-9994-f41734a08bb1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "17d10f15-2a8a-4186-9a72-34d3770331bb": {
      "main": [
        [
          {
            "node": "fb80d92a-9bb5-4090-8c6a-e2cc7aa47ca8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6b28414b-72b8-4e26-adea-402c9e59163d": {
      "main": [
        [
          {
            "node": "01b200fe-27ae-482d-977c-c786c3c890b8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7937ae1d-7795-43e6-8a46-7683e8c9b887": {
      "ai_languageModel": [
        [
          {
            "node": "2d070d34-2b5a-4126-82c3-18ea4ddfd308",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "cbd7276e-0569-4062-ae59-680d3236e8f6": {
      "main": [
        [
          {
            "node": "6b28414b-72b8-4e26-adea-402c9e59163d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e91fe671-1908-49b9-8b62-e84cd4fe74c5": {
      "main": [
        [
          {
            "node": "ce3e2b9c-f7b7-4d45-a92d-df893eec233f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "2a9f0ce2-e79a-4fb6-8a0f-3a1215b7261e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0cd6a217-c27c-4eb8-80c7-6f2c8042f592": {
      "main": [
        [
          {
            "node": "7ef2bbb3-5ae0-4859-8b0b-d27c4cf1db40",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "82442769-b159-4420-907e-5b84da107365": {
      "main": [
        [
          {
            "node": "793fa0f1-ac9e-47f0-bc79-898740e607c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3af11658-34ae-46db-b0ef-591842598676": {
      "main": [
        [
          {
            "node": "7ef2bbb3-5ae0-4859-8b0b-d27c4cf1db40",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "01b200fe-27ae-482d-977c-c786c3c890b8": {
      "main": [
        [
          {
            "node": "732054e0-e0ce-4c90-a519-21f0e56c94ce",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "793fa0f1-ac9e-47f0-bc79-898740e607c0": {
      "main": [
        [
          {
            "node": "8595b67d-afc5-432b-a71e-2129ec1086b5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e3ae7c0a-234e-453b-848e-e767ff3e9782": {
      "main": [
        []
      ]
    },
    "0ee2cee9-681e-45c7-9216-dec123742bc2": {
      "main": [
        [
          {
            "node": "d1f516d0-bed4-4946-80aa-701809317d07",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ce3e2b9c-f7b7-4d45-a92d-df893eec233f": {
      "main": [
        [
          {
            "node": "2d070d34-2b5a-4126-82c3-18ea4ddfd308",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1e7f2060-d40c-4286-8dcc-8ba10e7e305a": {
      "main": [
        [
          {
            "node": "01b200fe-27ae-482d-977c-c786c3c890b8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "470f1239-6ac7-4d01-bf20-1537618d65dc": {
      "main": [
        [
          {
            "node": "92a0d734-7408-42ec-942a-5f63ec5f64bb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级

需要付费吗?

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

工作流信息
难度等级
高级
节点数量48
分类-
节点类型13
难度说明

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

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34