Skip to main content

Generate invoices, save to Drive and send email to customer with JS + G Sheets

Workflow preview

Workflow preview
100%
Generate invoices, save to Drive and send email to customer with JS + G Sheets preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow automates invoice generation from form submissions, ensuring unique order IDs, creating PDF invoices, storing files, emailing customers, and logging invoice data — all seamlessly inte...

Best for

  • Invoice Processing automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.code, n8n-nodes-base.googlesheets, n8n-nodes-base.if, n8n-nodes-base.set, n8n-nodes-base.httprequest, n8n-nodes-base.googledrive, n8n-nodes-base.emailsend

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Joseph.

Original n8n.io source

1.1 Workflow description

Title
Generate invoices, save to Drive and send email to customer with JS + G Sheets
Workflow name
Generate invoices, save to Drive and send email to customer with JS + G Sheets

This workflow automates invoice generation from form submissions, ensuring unique order IDs, creating PDF invoices, storing files, emailing customers, and logging invoice data — all seamlessly integrated.


🔹 Workflow Overview

  1. Trigger (Webhook) Starts when an order form is submitted, capturing customer and order details.

  2. Generate Random Order ID A Function node creates a unique alphanumeric invoice ID (e.g., INV-X92B7D).

  3. Check for Duplicate Order ID Google Sheets looks up the generated order ID in your invoice log sheet to prevent duplicates.

  4. Conditional Check (IF Node)

    • If the ID already exists → regenerates a new ID (loops back)
    • If unique → proceeds to invoice creation
  5. Prepare Invoice Data A Set node formats customer info, date, order items, and the unique order ID to fit your invoice template.

  6. Convert HTML to PDF HTTP Request node sends your invoice HTML to the RapidAPI HTML-to-PDF service and receives the PDF file.

  7. Upload PDF to Cloud Storage Save the PDF in Google Drive or Dropbox with a clear file name like Invoice-INV-X92B7D.pdf.

  8. Send Invoice Email to Customer Email node attaches the PDF and includes the order ID in the email subject/body.

  9. Log Invoice Details Append invoice data (customer info, order ID, total, PDF link) to your Google Sheet for tracking.


⚙️ Node Details & Setup

1. Webhook Trigger

  • Configure to receive form submissions (order details like name, email, items, total).

2. Function: Generate Random Order ID

  • Sample JS code generates unique IDs prefixed by INV-.

3. Google Sheets: Lookup Row

  • Set up connection to your invoice log sheet.
  • Search for existing order ID to avoid duplicates.

4. IF Node: Check Order ID Existence

  • Condition: If order ID found → loop to regenerate.
  • Else → continue workflow.

5. Set Node: Prepare Invoice HTML

  • Define variables like customer name, date, items, and order ID.
  • This data populates your HTML invoice template.

6. HTTP Request: Convert HTML to PDF

7. Google Drive (or Dropbox) Upload

  • Upload the PDF file.
  • Use file name format: Invoice-{{$json["order_id"]}}.pdf

8. Email Node

  • Recipient: customer email from the form data.
  • Attach generated PDF.
  • Include order ID in email subject or body for reference.

9. Google Sheets: Append Row

  • Log invoice metadata to keep records updated.

📁 Google Sheets Template

You can make a copy of the invoice log template here

This sheet includes columns for order\_id, customer name, email, total, and invoice PDF link. Customize it as needed.


📌 Additional Notes

  • Customize the invoice HTML template inside the Set node to match your branding.
  • Ensure API credentials for RapidAPI, Google Drive/Dropbox, and email are properly set up in your n8n credentials.
  • You can expand this workflow by adding payment processing or SMS notifications.

Need help or want a custom workflow?

Reach out via email at [email protected].

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Webhook Simulator

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 2 - Generate Invoice ID

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Check if ID Already Exists

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.5

Block 4 - If Does not Exist

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 5 - Set Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 6 - Create Invoice HTML

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - HTML to PDF

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 8 - Upload PDF to GDrive

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 9 - Email Invoice to Customer

Type / Role
n8n-nodes-base.emailSend - emailSend
Config choices
Version 2.1

Block 10 - Append Details to Invoices Sheet

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.5

Block 11 - Download PDF from API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Generate invoices, save to Drive and send email to customer with JS + G Sheets
Complexity intermediate
Nodes 12
Categories Invoice Processing
Author Joseph
Published 16 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4105/4105.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Generate invoices, save to Drive and send email to customer with JS + G Sheets do?

This workflow automates invoice generation from form submissions, ensuring unique order IDs, creating PDF invoices, storing files, emailing customers, and logging invoice data — all seamlessly inte...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Invoice Processing use case.