8
n8n 中文网amn8n.com

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

高级

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

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

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Bk4bt3p0zi7Z9ETX",
  "meta": {
    "instanceId": "3549451ca835035557d5dc1c3d9e6ba924e7314534a74c901f66b91f9ef6023e",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 Jotform 和 Xero 为客户生成发票并发送提醒",
  "tags": [],
  "nodes": [
    {
      "id": "d7858d88-bccd-4bbb-8de0-c7ba96d74263",
      "name": "接收表单提交",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -464,
        0
      ],
      "webhookId": "148f97af-2d29-4836-a910-2c77b7c33b26",
      "parameters": {
        "path": "148f97af-2d29-4836-a910-2c77b7c33b26",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "267003ec-6e40-4a33-bacc-2244c8e43b64",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 接收提交"
      },
      "typeVersion": 1
    },
    {
      "id": "8ee7dc1e-86bf-4bec-b8b6-7b97889eab6b",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 320,
        "content": "## 创建/更新联系人"
      },
      "typeVersion": 1
    },
    {
      "id": "a14a8305-8c22-4213-9414-861019d3ae69",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 创建发票"
      },
      "typeVersion": 1
    },
    {
      "id": "77f6b18b-004e-4e00-8de2-54194fdd9a47",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1488,
        -400
      ],
      "parameters": {
        "width": 896,
        "height": 1200,
        "content": "## 使用 Jotform 和 Xero 为客户生成发票并发送提醒"
      },
      "typeVersion": 1
    },
    {
      "id": "79c58923-f8c3-4054-93ca-c2de89ff7306",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 320,
        "content": "## 格式化数据"
      },
      "typeVersion": 1
    },
    {
      "id": "e495d2d4-3f6d-482a-bb95-7a4dfdbd5dba",
      "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": "9153a6f7-10d8-44f6-976b-b0abdaf5fd20",
      "name": "创建/更新联系人",
      "type": "n8n-nodes-base.xero",
      "position": [
        160,
        0
      ],
      "parameters": {
        "name": "={{ $json.customer.name }}",
        "resource": "contact",
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446",
        "additionalFields": {
          "phonesUi": {
            "phonesValues": [
              {
                "phoneType": "MOBILE",
                "phoneNumber": "={{ $json.customer.phone }}"
              }
            ]
          },
          "addressesUi": {
            "addressesValues": [
              {
                "city": "={{ $json.address.city }}",
                "type": "STREET",
                "line1": "={{ $json.address.line1 }}",
                "line2": "={{ $json.address.line2 }}",
                "region": "={{ $json.address.stateProvince }}",
                "country": "={{ $json.address.country }}",
                "postalCode": "={{ $json.address.postalZipCode }}"
              }
            ]
          },
          "emailAddress": "={{ $json.customer.email }}"
        }
      },
      "credentials": {
        "xeroOAuth2Api": {
          "id": "HZnbTfrr5leqrLUQ",
          "name": "Xero account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "15e1d23a-3c96-4037-83cd-97004e6aebe8",
      "name": "创建发票",
      "type": "n8n-nodes-base.xero",
      "position": [
        480,
        0
      ],
      "parameters": {
        "type": "ACCREC",
        "contactId": "={{ $json.ContactID }}",
        "lineItemsUi": {
          "lineItemsValues": [
            {
              "taxType": "INPUT",
              "itemCode": "={{ $('Format data').item.json.item.name }}",
              "unitAmount": "10",
              "accountCode": "200"
            }
          ]
        },
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446",
        "additionalFields": {}
      },
      "credentials": {
        "xeroOAuth2Api": {
          "id": "HZnbTfrr5leqrLUQ",
          "name": "Xero account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2831fd4c-313c-4b63-b6d0-6b36428ae778",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        816,
        -432
      ],
      "parameters": {
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "=You are an AI assistant that generates a professional invoice email that you get from an Xero response (newly created invoice), so you will recive an Xero invoice response and thus your job is to create a professional html email content because this html email content will be sent to the customer."
        },
        "promptType": "define"
      },
      "executeOnce": false,
      "typeVersion": 2.2
    },
    {
      "id": "3436d1ca-18bf-4929-982a-89fa802ff015",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        816,
        -224
      ],
      "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": "5dbc3862-69b4-4174-8952-635f386cb81c",
      "name": "便签19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 480,
        "content": "## 发送发票"
      },
      "typeVersion": 1
    },
    {
      "id": "8add409c-adb4-4d9b-9e6a-0db66e17093e",
      "name": "发送邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1088,
        -432
      ],
      "webhookId": "e6595484-bef2-43b0-894f-23f53746c0af",
      "parameters": {
        "html": "={{ $json.output }}",
        "options": {},
        "subject": "=New Invoice",
        "toEmail": "={{ $('Create the invoice').item.json.Contact.EmailAddress }}",
        "fromEmail": "system@example.com"
      },
      "credentials": {
        "smtp": {
          "id": "awV8UBK3MYzosMxe",
          "name": "Mailtrap SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d5ebc764-96f4-41e5-a5dd-ecc8b69470c5",
      "name": "添加提醒配置",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        320
      ],
      "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": "f40da212-3f17-426d-bc58-5348b4488d9d",
      "name": "发送提醒邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2768,
        688
      ],
      "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.InvoiceNumber }}</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.InvoiceNumber }}</p>\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.InvoiceNumber }}",
        "toEmail": "={{ $json.Contact.EmailAddress }}",
        "fromEmail": "reminders@example.com"
      },
      "credentials": {
        "smtp": {
          "id": "awV8UBK3MYzosMxe",
          "name": "Mailtrap SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e220b58d-04f9-483a-90b0-e196b8088bd1",
      "name": "将发票 ID 插入数据库",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1504,
        128
      ],
      "parameters": {
        "columns": {
          "value": {
            "currency": "={{ $('Create the invoice').item.json.CurrencyCode }}",
            "invoiceId": "={{ $('Create the invoice').item.json.InvoiceID }}",
            "remindersSent": "=0",
            "remainingAmount": "={{ $('Create the invoice').item.json.AmountDue }}"
          },
          "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": "ae2c88cb-764a-48be-bec0-c172dcf1732e",
      "name": "获取发票",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1504,
        496
      ],
      "parameters": {
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Add reminders config').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "56a479b9-6fc2-4ad8-8a09-7bfd76c5da81",
      "name": "如果2",
      "type": "n8n-nodes-base.if",
      "position": [
        1152,
        320
      ],
      "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": "fc86c9e1-0f12-47a8-893c-4a2479207702",
      "name": "发送已发送提醒摘要",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2848,
        160
      ],
      "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": "a1b465b8-6884-4878-ab45-81731cc11306",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2512,
        736
      ],
      "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.AmountDue > 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.AmountDue == 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": "90f88e6b-c967-4ac7-b11a-4e86be5b9e40",
      "name": "计划提醒触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        384,
        544
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5a708503-da01-49d5-af64-5b190f61bcb3",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        416
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 320,
        "content": "## 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "8f75c160-2d8e-4391-8d73-166a96fc7566",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 368,
        "content": "## 添加提醒配置"
      },
      "typeVersion": 1
    },
    {
      "id": "9fbe84fe-3ed0-479c-ab9d-fc7d2a7bfff0",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 368,
        "content": "## 检查触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "362c4c03-bd7f-4130-8e0c-060ad5e6957e",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 336,
        "content": "## 将发票插入数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "6703f7ec-7901-4d28-9330-ef2ec277df60",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 336,
        "content": "## 获取所有发票"
      },
      "typeVersion": 1
    },
    {
      "id": "aa2278cb-85aa-4038-b837-bbf085b9b245",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        368
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 320,
        "content": "## 遍历发票"
      },
      "typeVersion": 1
    },
    {
      "id": "2620e88d-9c4a-418a-b378-f81aad2f991f",
      "name": "遍历发票",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1856,
        496
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "67f18351-969d-4489-89c7-b77a2d4ff283",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 352,
        "content": "## 获取已发送提醒"
      },
      "typeVersion": 1
    },
    {
      "id": "1c001fdd-4d76-4243-94f0-a93ed84b2cfa",
      "name": "便签18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        560
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 368,
        "content": "## 获取发票详细信息"
      },
      "typeVersion": 1
    },
    {
      "id": "5949d37a-037b-4292-bbd4-722efc81d0a6",
      "name": "获取今天已发送的提醒",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2208,
        304
      ],
      "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": "f55fd793-3299-4ca7-ab12-6b73a2df3706",
      "name": "增加已发送提醒次数",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2976,
        688
      ],
      "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": "6bb0af0e-dc3d-438e-b811-ee897ccddd74",
      "name": "删除发票",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3456,
        848
      ],
      "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": "ad8ba6c6-d1f4-4329-90ea-b5f39ee7e37f",
      "name": "如果3",
      "type": "n8n-nodes-base.if",
      "position": [
        3184,
        688
      ],
      "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": "1e7c11be-4898-4d65-bec2-836d6d769849",
      "name": "便签20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        560
      ],
      "parameters": {
        "color": 7,
        "width": 1184,
        "height": 480,
        "content": "## 发送提醒逻辑"
      },
      "typeVersion": 1
    },
    {
      "id": "54b8f2b7-c849-48cb-9483-0d0a614575df",
      "name": "AI 代理1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2576,
        160
      ],
      "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": "a8aeb3a0-f1fd-4038-9899-a7debeb396a3",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2576,
        368
      ],
      "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": "73ba208d-4c77-47f7-8a6c-b8d8d7e89ed8",
      "name": "便利贴21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 480,
        "content": "## 汇总已发送提醒并发送电子邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "a603f1f4-ca24-4c3d-b2bb-0209d999c05f",
      "name": "获取发票",
      "type": "n8n-nodes-base.xero",
      "position": [
        2208,
        720
      ],
      "parameters": {
        "invoiceId": "={{ $json.invoiceId }}",
        "operation": "get",
        "organizationId": "bc9a44a6-eb14-4f81-b24c-ca676c506446"
      },
      "credentials": {
        "xeroOAuth2Api": {
          "id": "HZnbTfrr5leqrLUQ",
          "name": "Xero account"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "Receive form submission": [
      {
        "json": {
          "body": {
            "name": "Adrian Mathews",
            "email": "yoled82772@elygifts.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>"
          }
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "15956a08-b0e1-4140-952c-370bd5bae437",
  "connections": {
    "56a479b9-6fc2-4ad8-8a09-7bfd76c5da81": {
      "main": [
        [
          {
            "node": "e220b58d-04f9-483a-90b0-e196b8088bd1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ae2c88cb-764a-48be-bec0-c172dcf1732e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ad8ba6c6-d1f4-4329-90ea-b5f39ee7e37f": {
      "main": [
        [
          {
            "node": "6bb0af0e-dc3d-438e-b811-ee897ccddd74",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "2620e88d-9c4a-418a-b378-f81aad2f991f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a1b465b8-6884-4878-ab45-81731cc11306": {
      "main": [
        [
          {
            "node": "f40da212-3f17-426d-bc58-5348b4488d9d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "6bb0af0e-dc3d-438e-b811-ee897ccddd74",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "2620e88d-9c4a-418a-b378-f81aad2f991f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2831fd4c-313c-4b63-b6d0-6b36428ae778": {
      "main": [
        [
          {
            "node": "8add409c-adb4-4d9b-9e6a-0db66e17093e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "54b8f2b7-c849-48cb-9483-0d0a614575df": {
      "main": [
        [
          {
            "node": "fc86c9e1-0f12-47a8-893c-4a2479207702",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e495d2d4-3f6d-482a-bb95-7a4dfdbd5dba": {
      "main": [
        [
          {
            "node": "9153a6f7-10d8-44f6-976b-b0abdaf5fd20",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ae2c88cb-764a-48be-bec0-c172dcf1732e": {
      "main": [
        [
          {
            "node": "2620e88d-9c4a-418a-b378-f81aad2f991f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6bb0af0e-dc3d-438e-b811-ee897ccddd74": {
      "main": [
        [
          {
            "node": "2620e88d-9c4a-418a-b378-f81aad2f991f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a603f1f4-ca24-4c3d-b2bb-0209d999c05f": {
      "main": [
        [
          {
            "node": "a1b465b8-6884-4878-ab45-81731cc11306",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3436d1ca-18bf-4929-982a-89fa802ff015": {
      "ai_languageModel": [
        [
          {
            "node": "2831fd4c-313c-4b63-b6d0-6b36428ae778",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "15e1d23a-3c96-4037-83cd-97004e6aebe8": {
      "main": [
        [
          {
            "node": "2831fd4c-313c-4b63-b6d0-6b36428ae778",
            "type": "main",
            "index": 0
          },
          {
            "node": "d5ebc764-96f4-41e5-a5dd-ecc8b69470c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2620e88d-9c4a-418a-b378-f81aad2f991f": {
      "main": [
        [
          {
            "node": "5949d37a-037b-4292-bbd4-722efc81d0a6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a603f1f4-ca24-4c3d-b2bb-0209d999c05f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a8aeb3a0-f1fd-4038-9899-a7debeb396a3": {
      "ai_languageModel": [
        [
          {
            "node": "54b8f2b7-c849-48cb-9483-0d0a614575df",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "f40da212-3f17-426d-bc58-5348b4488d9d": {
      "main": [
        [
          {
            "node": "f55fd793-3299-4ca7-ab12-6b73a2df3706",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d5ebc764-96f4-41e5-a5dd-ecc8b69470c5": {
      "main": [
        [
          {
            "node": "56a479b9-6fc2-4ad8-8a09-7bfd76c5da81",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f55fd793-3299-4ca7-ab12-6b73a2df3706": {
      "main": [
        [
          {
            "node": "ad8ba6c6-d1f4-4329-90ea-b5f39ee7e37f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d7858d88-bccd-4bbb-8de0-c7ba96d74263": {
      "main": [
        [
          {
            "node": "e495d2d4-3f6d-482a-bb95-7a4dfdbd5dba",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9153a6f7-10d8-44f6-976b-b0abdaf5fd20": {
      "main": [
        [
          {
            "node": "15e1d23a-3c96-4037-83cd-97004e6aebe8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5949d37a-037b-4292-bbd4-722efc81d0a6": {
      "main": [
        [
          {
            "node": "54b8f2b7-c849-48cb-9483-0d0a614575df",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "90f88e6b-c967-4ac7-b11a-4e86be5b9e40": {
      "main": [
        [
          {
            "node": "d5ebc764-96f4-41e5-a5dd-ecc8b69470c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34