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

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

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

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

Conditional Check (IF Node)

If the ID already exists → regenerates a new ID (loops back) If unique → proceeds to invoice creation

Prepare Invoice Data A Set node formats customer info, date, order items, and the unique order ID to fit your invoice template.

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

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

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

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).

  1. Function: Generate Random Order ID

Sample JS code generates unique IDs prefixed by INV-.

  1. Google Sheets: Lookup Row

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

  1. IF Node: Check Order ID Existence

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

  1. Set Node: Prepare Invoice HTML

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

  1. HTTP Request: Convert HTML to PDF

API URL to get your key Send invoice HTML in the request body. Receive PDF file blob or download URL.

  1. Google Drive (or Dropbox) Upload

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

  1. Email Node

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

  1. 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 joseph@uppfy.com.

0
Downloads
4477
Views
8.94
Quality Score
intermediate
Complexity
Created:8/13/2025
Updated:8/25/2025

šŸ”’ Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments