8
n8n 中文网amn8n.com

Google 电子表格 -> 发票生成 -> 电子邮件

高级

这是一个自动化工作流,包含 18 个节点。主要使用 Set, Airtable, Aggregate, EmailSend, ManualTrigger 等节点。 使用 Airtable 和 CustomJS PDF 生成器自动生成发票并发送邮件

前置要求
  • Airtable API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "fB4si9amQw4D2TK2",
  "meta": {
    "instanceId": "b503899dfd9ae32bbf8e1f446a1f2c9b3c59f80c79b274c49b1606b7ae9579e1",
    "templateCredsSetupCompleted": true
  },
  "name": "Google 电子表格 -> 发票生成 -> 电子邮件",
  "tags": [],
  "nodes": [
    {
      "id": "c2e9a234-394c-4c5e-ab59-a5311fa61ed8",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -144,
        16
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1f9f59c4-9927-4a0f-8aaf-64488bdc5a13",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -576
      ],
      "parameters": {
        "width": 864,
        "height": 448,
        "content": "# 使用 Airtable 管理发票"
      },
      "typeVersion": 1
    },
    {
      "id": "895fe916-1db2-4055-a87e-804a6be14383",
      "name": "获取就绪发票",
      "type": "n8n-nodes-base.airtable",
      "position": [
        144,
        16
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apphyDa3uYAq0VOMW",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW",
          "cachedResultName": "Custom JS - Invoicing Template"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblW46vfkwOFQJLMs",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW/tblW46vfkwOFQJLMs",
          "cachedResultName": "Invoices"
        },
        "options": {},
        "operation": "search",
        "filterByFormula": "{Status} = 'Ready'"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "y4iDRTq2XVlO3xSa",
          "name": "CustomJS Invoice Example"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "5c20d60e-72b3-45db-8df0-223676a7880e",
      "name": "获取客户",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1024,
        0
      ],
      "parameters": {
        "id": "={{ $('Get Ready Invoices').item.json['Client ID'][0] }}",
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apphyDa3uYAq0VOMW",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW",
          "cachedResultName": "Custom JS - Invoicing Template"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblQdiFVsZ9w3sahJ",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW/tblQdiFVsZ9w3sahJ",
          "cachedResultName": "Clients"
        },
        "options": {}
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "y4iDRTq2XVlO3xSa",
          "name": "CustomJS Invoice Example"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1da85e53-eaf2-4928-b1bb-0d2d7eb56056",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        -96
      ],
      "parameters": {
        "color": 2,
        "width": 416,
        "height": 560,
        "content": "## 定义您的公司详情"
      },
      "typeVersion": 1
    },
    {
      "id": "047f3d97-760b-4307-a17f-a92d4c8f268d",
      "name": "获取发票项目",
      "type": "n8n-nodes-base.airtable",
      "position": [
        528,
        128
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apphyDa3uYAq0VOMW",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW",
          "cachedResultName": "Custom JS - Invoicing Template"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblASYLVpsnrUoKt5",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW/tblASYLVpsnrUoKt5",
          "cachedResultName": "Invoice-Items"
        },
        "options": {},
        "operation": "search",
        "filterByFormula": "=FIND(\"{{ $json.ID }}\", ARRAYJOIN({Invoice}))"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "y4iDRTq2XVlO3xSa",
          "name": "CustomJS Invoice Example"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3e86f778-d65a-47c6-8fd4-83b8063174e1",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        848,
        128
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "32205005-9879-4abe-be18-d77126675ccb",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        352,
        16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "9e68a44d-f0d2-407b-88fb-bf97032504b0",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        -96
      ],
      "parameters": {
        "color": 5,
        "width": 416,
        "height": 560,
        "content": "## 将发票标记为\"已发送\""
      },
      "typeVersion": 1
    },
    {
      "id": "6d4c0372-e2b4-45fb-8840-82378e557f4c",
      "name": "更新记录",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2288,
        0
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apphyDa3uYAq0VOMW",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW",
          "cachedResultName": "Custom JS - Invoicing Template"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblW46vfkwOFQJLMs",
          "cachedResultUrl": "https://airtable.com/apphyDa3uYAq0VOMW/tblW46vfkwOFQJLMs",
          "cachedResultName": "Invoices"
        },
        "columns": {
          "value": {
            "id": "={{ $('Get Ready Invoices').item.json.id }}",
            "Status": "Sent"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client ID",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Client ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Name",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Client Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description (from Invoice-Items)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Description (from Invoice-Items)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Total",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoicedate",
              "type": "dateTime",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Invoicedate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "Delayed",
                  "value": "Delayed"
                },
                {
                  "name": "Sent",
                  "value": "Sent"
                },
                {
                  "name": "Paid",
                  "value": "Paid"
                },
                {
                  "name": "Ready",
                  "value": "Ready"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Create Invoice (Airtable API)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Create Invoice (Airtable API)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Create Invoice (Get Parameters)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Create Invoice (Get Parameters)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice-Items",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice-Items",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prices (from Invoice-Items)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Prices (from Invoice-Items)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Default Hourly Rate (from Client ID)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Default Hourly Rate (from Client ID)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total (from Invoice-Items)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Total (from Invoice-Items)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ClientAddressField1",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "ClientAddressField1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ClientAddressField2",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "ClientAddressField2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ClientTax",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "ClientTax",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "y4iDRTq2XVlO3xSa",
          "name": "CustomJS Invoice Example"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "6792cf9c-9aa6-444e-9c1c-66cf5784341d",
      "name": "生成发票",
      "type": "@custom-js/n8n-nodes-pdf-toolkit.invoiceGenerator",
      "position": [
        1728,
        0
      ],
      "parameters": {
        "issuer": {
          "issuerValues": {
            "email": "={{ $json.Email }}",
            "phone": "={{ $json.Phone }}",
            "taxId": "={{ $json.TaxId }}",
            "address": "={{ $json.Address }}",
            "logoUrl": "={{ $json.Logo }}",
            "companyName": "={{ $json.CompanyName }}"
          }
        },
        "billing": {
          "billingValues": {
            "notes": "Please transfer the amount within 14 days.",
            "taxRate": 19,
            "currency": "EUR",
            "invoiceDate": "={{ $('Get Ready Invoices').item.json['Client ID'][0] }}",
            "invoiceNumber": "={{ $('Get Ready Invoices').item.json.ID }}"
          }
        },
        "payment": {
          "paymentValues": {
            "BIC": "={{ $json['Bic/Swift'] }}",
            "bankName": "={{ $json['Bank Name'] }}",
            "accountNumber": "={{ $json['Account Number'] }}"
          }
        },
        "itemsJson": "={{ $('Loop Over Items').item.json.items }}",
        "itemsMode": "json",
        "recipient": {
          "recipientValues": {
            "name": "={{ $('Get Clients').item.json['Comany Name'] }}",
            "taxId": "={{ $('Get Clients').item.json.Tax }}",
            "address": "={{ $('Get Clients').item.json.Street }} {{ $('Get Clients').item.json['Street No.'] }}\n{{ $('Get Clients').item.json['Postal Code'] }} {{ $('Get Clients').item.json.City }}"
          }
        }
      },
      "credentials": {
        "customJsApi": {
          "id": "BFGbk0a71fKWY967",
          "name": "Coding Service"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b3263d7d-e8ca-4776-8d27-08773ab65549",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -96
      ],
      "parameters": {
        "color": 5,
        "width": 1040,
        "height": 560,
        "content": "## 从 Airtable 收集发票数据"
      },
      "typeVersion": 1
    },
    {
      "id": "7904b830-14ce-4ff5-8ca4-e4ab2cd4a644",
      "name": "设置公司详情",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "860bad3a-81d5-4591-9d8d-3f399e88227d",
              "name": "CompanyName",
              "type": "string",
              "value": "MyCompany"
            },
            {
              "id": "4f473e5c-1f8a-4fce-971b-7bcf3a585953",
              "name": "Address",
              "type": "string",
              "value": "My Street 45\n12322 New York"
            },
            {
              "id": "a4de3c7f-2470-48a2-81ee-22d43dbbded5",
              "name": "TaxId",
              "type": "string",
              "value": "US12124234"
            },
            {
              "id": "f6b26bc0-dbe7-433b-96ff-843a137afa99",
              "name": "Email",
              "type": "string",
              "value": "info@mycorp.org"
            },
            {
              "id": "9ee8496d-93c8-4828-aa43-a4168ffd7c39",
              "name": "Phone",
              "type": "string",
              "value": "+331 123412433123"
            },
            {
              "id": "a66fb0d6-a2c2-4d9d-86aa-fe3f7dc97e6e",
              "name": "Logo",
              "type": "string",
              "value": "https://equalengineers.com/wp-content/uploads/2024/04/dummy-logo-5b.png"
            },
            {
              "id": "717ca346-29d6-4d0a-9942-af8db75c23ce",
              "name": "Account Number",
              "type": "string",
              "value": "12345677"
            },
            {
              "id": "db4d6b35-9ddb-4f38-a6a1-2f66a36d58d6",
              "name": "Bic/Swift",
              "type": "string",
              "value": "1234"
            },
            {
              "id": "d08fdf69-c730-4bda-b621-dd8a429ed3ac",
              "name": "Bank Name",
              "type": "string",
              "value": "Bank of XYZ"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a0d0705b-5d60-4845-bace-2e0cc9a9a8bd",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1648,
        -96
      ],
      "parameters": {
        "color": 4,
        "width": 448,
        "height": 560,
        "content": "## 生成发票并发送带附件的电子邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "bbdd0964-c9ea-4c4b-b402-7a2e34e79c70",
      "name": "映射字段",
      "type": "n8n-nodes-base.set",
      "position": [
        688,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a95b61df-c10d-43f1-b005-d6d84c6fec47",
              "name": "description",
              "type": "string",
              "value": "={{ $json.Description }}"
            },
            {
              "id": "f290e440-dd5b-46f9-a23b-be419443685b",
              "name": "quantity",
              "type": "string",
              "value": "={{ $json.Hours }}"
            },
            {
              "id": "09688f5f-0461-4c04-988a-2b92da3e595e",
              "name": "unitPrice",
              "type": "string",
              "value": "={{ $json['Custom Hourly Rate'] || $json['Default Hourly Rate'][0]}}"
            },
            {
              "id": "bcdadef7-0f5b-48a3-851b-f7fe5f401fa7",
              "name": "invoiceId",
              "type": "string",
              "value": "={{ $json.ID }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0a5e9db0-410f-4b5c-99cf-a616107942a5",
      "name": "发送带附件的电子邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1904,
        0
      ],
      "webhookId": "aa09d395-1678-4800-9fe8-875468e53d08",
      "parameters": {
        "text": "Hello,\n\nPlease find attached your invoice for the last month. Thank you very much for your cooperation.\n\nBest regards,\nHenrik",
        "options": {
          "attachments": "data"
        },
        "subject": "Your Invoice for Last Month",
        "toEmail": "info@yourcomp.org",
        "fromEmail": "={{ $json.InvoiceEmail }}",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "id": "vvY03KbEvsdTVMXI",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "cc9d1907-9d69-4f72-b3a0-76ce416e75e8",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -96
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 560,
        "content": "## 手动运行此工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "ec0d2733-966b-49ff-ab2f-5a944882e916",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        0
      ],
      "parameters": {
        "width": 720,
        "height": 448,
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4c90ec99-f624-4f7f-a4be-ccd8653cdb04",
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Fields": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Clients": {
      "main": [
        [
          {
            "node": "Set Company Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Get Clients",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Invoice Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Invoice": {
      "main": [
        [
          {
            "node": "Send Email With Attachment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Invoice Items": {
      "main": [
        [
          {
            "node": "Map Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ready Invoices": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Company Details": {
      "main": [
        [
          {
            "node": "Generate Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email With Attachment": {
      "main": [
        [
          {
            "node": "Update record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Ready Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流