8
n8n 中文网amn8n.com

自动开票

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 9 个节点。主要使用 Gmail, Filter, GoogleDrive, HttpRequest, GoogleSheets 等节点。 使用Stripe、Google Sheets、Drive和Gmail自动化客户开票与收款

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "vJ0wZhatRHwADMcn",
  "meta": {
    "instanceId": "cbe443dad974471e0b4f8b19ab92782e168bbdef84a3d0b94f5f96a67e01c92c",
    "templateCredsSetupCompleted": true
  },
  "name": "自动开票",
  "tags": [],
  "nodes": [
    {
      "id": "1fc28d00-b93a-47d1-bc7e-9616f36128b2",
      "name": "Google Sheets 触发器",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xRWt65Mu7Lx_LAbCdf_FsZmO0MW2o61kMPM854_L4jw/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1xRWt65Mu7Lx_LAbCdf_FsZmO0MW2o61kMPM854_L4jw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xRWt65Mu7Lx_LAbCdf_FsZmO0MW2o61kMPM854_L4jw/edit?usp=drivesdk",
          "cachedResultName": "ClientPayments"
        }
      },
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "id": "DJ7kiXarj7DIKQKE",
          "name": "Google Sheets Trigger account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4c634c62-6e9e-4948-b2c7-69f278f861c3",
      "name": "通过 Gmail 发送电子邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        352,
        432
      ],
      "parameters": {
        "toList": [
          "={{ $('Filter').item.json[\"Client Email\"] }}"
        ],
        "message": "Invoice",
        "subject": "Invoice for Services",
        "resource": "message",
        "htmlMessage": "=<!DOCTYPE html> <html> <head>   <meta charset=\"UTF-8\">   <style>     body {       font-family: Arial, sans-serif;       background-color: #f8f9fa;       padding: 20px;     }     .container {       max-width: 600px;       margin: auto;       background: #ffffff;       border: 1px solid #ddd;       border-radius: 8px;       padding: 30px;     }     h2 {       color: #333333;     }     p {       font-size: 15px;       color: #555555;     }     .info {       background: #f1f1f1;       padding: 15px;       border-radius: 6px;       margin-bottom: 20px;     }     .btn {       background-color: #007bff;       color: #ffffff !important;       padding: 12px 20px;       text-decoration: none;       border-radius: 5px;       display: inline-block;       font-weight: bold;     }     .footer {       font-size: 12px;       color: #999999;       margin-top: 30px;       text-align: center;     }   </style> </head> <body>   <div class=\"container\">     <h2>Invoice: {{ $('Filter').item.json[\"Order ID\"] }}</h2>     <p>Dear {{ $('Filter').item.json[\"Client Name\"] }},</p>     <p>Thank you for your business! Please find your invoice details below:</p>      <div class=\"info\">       <p><strong>Invoice Date:</strong> {{ DateTime.now().format('yyyy-LL-dd') }}</p>       <p><strong>Due Date:</strong> {{ $('Filter').item.json[\"Due Date\"] }}</p>       <p><strong>Total Amount:</strong>{{ $('Filter').item.json.Amount }} {{ $('Filter').item.json.Currency }}</p>       <p><strong>Items:</strong><br>{{ $('Filter').item.json[\"Items Description\"] }}</p>     </div>      <p>You can view or download your invoice using the button below:</p>     <p><a class=\"btn\" href=\"https://drive.google.com/file/d/{{ $('Google Drive').item.json.id }}/view?usp=drive_link\" target=\"_blank\">View Invoice</a></p>      <p>To complete your payment, please click below:</p>     <p><a class=\"btn\" href=\"{{ $('Create Stripe Payment Link').item.json.url }}\" target=\"_blank\">Pay Now</a></p>      <p>If you have any questions or concerns, feel free to contact us.</p>      <div class=\"footer\">       © {{ DateTime.now().format('yyyy') }} Your Company Name. All rights reserved.     </div>   </div> </body> </html>",
        "includeHtml": true,
        "additionalFields": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "RhbEB1PDPVVI9T4I",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7221a13f-9278-47e1-b99d-dd063b69b2ab",
      "name": "筛选",
      "type": "n8n-nodes-base.filter",
      "position": [
        224,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8b570f11-d7d3-412d-a637-a24fa07008ea",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json[\"Last Updated\"] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "85accbae-199e-4541-8e19-dbfc41339a2a",
      "name": "创建 Stripe 产品",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -96,
        208
      ],
      "parameters": {
        "url": "https://api.stripe.com/v1/products",
        "options": {
          "bodyContentCustomMimeType": "application/x-www-form-urlencoded"
        },
        "requestMethod": "POST",
        "authentication": "basicAuth",
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "name",
              "value": "={{ $json[\"Items Description\"] }}"
            }
          ]
        }
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "EPKbd3Ykc72IhBCw",
          "name": "Unnamed credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f69f2dd2-3446-4f83-aa82-e66e4010f233",
      "name": "创建 Stripe 价格",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        128,
        208
      ],
      "parameters": {
        "url": "https://api.stripe.com/v1/prices",
        "options": {
          "bodyContentCustomMimeType": "application/x-www-form-urlencoded"
        },
        "requestMethod": "POST",
        "authentication": "basicAuth",
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "currency",
              "value": "={{ $('Filter').item.json.Currency }}"
            },
            {
              "name": "unit_amount",
              "value": "={{ $('Filter').item.json.Amount }}"
            },
            {
              "name": "product",
              "value": "={{ $json.id }}"
            }
          ]
        }
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "EPKbd3Ykc72IhBCw",
          "name": "Unnamed credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2b785e52-0f4a-4583-ae9b-9df7f19b2ca0",
      "name": "创建 Stripe 支付链接",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        352,
        208
      ],
      "parameters": {
        "url": "https://api.stripe.com/v1/payment_links",
        "options": {
          "bodyContentCustomMimeType": "application/x-www-form-urlencoded"
        },
        "requestMethod": "POST",
        "authentication": "basicAuth",
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "line_items[0][price]",
              "value": "={{ $json.id }}"
            },
            {
              "name": "line_items[0][quantity]",
              "value": "1"
            }
          ]
        }
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "EPKbd3Ykc72IhBCw",
          "name": "Unnamed credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "983b3432-dd64-4ffa-9e15-5305840867dd",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -96,
        432
      ],
      "parameters": {
        "name": "=Invoice_{{ $('Filter').item.json[\"Order ID\"] }}",
        "content": "=INVOICE\nInvoice Number: {{ $('Filter').item.json[\"Order ID\"] }}\nDate: {{  DateTime.now().format('yyyy-MM-dd') }}\nDue Date: {{ $('Filter').item.json[\"Due Date\"] }}\nClient Name: {{ $('Filter').item.json[\"Client Name\"] }}\nClient Email: {{ $('Filter').item.json[\"Client Email\"] }}\n\n\n\nDescription:\n{{ $('Filter').item.json[\"Items Description\"] }}\n\nAmount:\n{{ $('Filter').item.json.Amount }}\n\n\n\n\nTotal Amount: {{ $('Filter').item.json.Amount }} {{ $('Filter').item.json.Currency }}\nPlease complete your payment using the link below:\n{{ $('Create Stripe Payment Link').item.json.url }}\n\nThank you for your business!\nIf you have any questions, feel free to contact us.\n",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1FfQW6DeAd0UPj-CFFEsXqgE43I2V6zDX",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1FfQW6DeAd0UPj-CFFEsXqgE43I2V6zDX",
          "cachedResultName": "Youtube"
        },
        "operation": "createFromText"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "LxrpvgkD31trhdub",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a43b8711-6c28-40e3-aa60-3883b6cdacca",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        128,
        432
      ],
      "parameters": {
        "columns": {
          "value": {
            "Order ID": "={{ $('Filter').item.json[\"Order ID\"] }}",
            "Invoice Link": "={{ $json.id }}",
            "Last Updated": "={{ DateTime.now() }}",
            "Stripe Payment Link": "={{ $('Create Stripe Payment Link').item.json.url }}"
          },
          "schema": [
            {
              "id": "Order ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Order ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Client Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Email",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Client Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Items Description",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Items Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due Date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Due Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Invoice Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Invoice Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Stripe Payment Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Stripe Payment Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Payment Received On",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Payment Received On",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Updated",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Last Updated",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Order ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xRWt65Mu7Lx_LAbCdf_FsZmO0MW2o61kMPM854_L4jw/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1xRWt65Mu7Lx_LAbCdf_FsZmO0MW2o61kMPM854_L4jw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xRWt65Mu7Lx_LAbCdf_FsZmO0MW2o61kMPM854_L4jw/edit?usp=drivesdk",
          "cachedResultName": "ClientPayments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uqJcQ13LuCAaohLN",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "4dbe5318-59e7-4787-b397-64aabdc6a3e7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -32
      ],
      "parameters": {
        "width": 560,
        "height": 848,
        "content": "## 🛠 设置指南"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e166fc02-4473-4099-b669-e6898694feff",
  "connections": {
    "Filter": {
      "main": [
        [
          {
            "node": "Create Stripe Product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Send Email via Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Price": {
      "main": [
        [
          {
            "node": "Create Stripe Payment Link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Product": {
      "main": [
        [
          {
            "node": "Create Stripe Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Payment Link": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者
Rohit Dabra

Rohit Dabra

@rohitdabra

As the CTO of QServices, I lead digital transformation for startups and SMBs by building scalable, AI-powered SaaS solutions that solve real-world business challenges.

外部链接
在 n8n.io 查看

分享此工作流