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
- Webhook Trigger
Configure to receive form submissions (order details like name, email, items, total).
- Function: Generate Random Order ID
Sample JS code generates unique IDs prefixed by INV-.
- Google Sheets: Lookup Row
Set up connection to your invoice log sheet. Search for existing order ID to avoid duplicates.
- IF Node: Check Order ID Existence
Condition: If order ID found ā loop to regenerate. Else ā continue workflow.
- Set Node: Prepare Invoice HTML
Define variables like customer name, date, items, and order ID. This data populates your HTML invoice template.
- 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.
- Google Drive (or Dropbox) Upload
Upload the PDF file. Use file name format: Invoice-{{$json["order_id"]}}.pdf
- Email Node
Recipient: customer email from the form data. Attach generated PDF. Include order ID in email subject or body for reference.
- 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.
Related Templates
Demo Workflow - How to use workflowStaticData()
This workflow demonstrates how to use the workflowStaticData() function to set any type of variable that will persist wi...
Bulk Automated Google Drive Files Sharing and Direct Download Link Generation
This N8N workflow automates the process of sharing files from Google Drive. It includes OAuth2 authentication, batch pro...
USDT And TRC20 Wallet Tracker API Workflow for n8n
Overview This n8n workflow is specifically designed to monitor USDT TRC20 transactions within a specified wallet. It u...
š Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments