Saturday, 11 April 2026

How I Automated Invoice Generation Using n8n — Step by Step

How I Automated Invoice Generation Using n8n — Step by Step

Invoice generation used to eat three hours of my Fridays. Not because it's complicated — it's not — but because it's the kind of repetitive, context-switching task that kills momentum. Enter n8n. After one weekend of setup, I haven't manually created an invoice in four months.

Here's exactly how I automated invoice generation using n8n, including the mistakes I made and how to skip them.

What You'll Need to Automate Invoice Generation

This automation pulls together a few tools you probably already use. The core setup: n8n as the automation engine, Airtable or Google Sheets as the client/project database, and either Invoice Ninja (free) or a PDF generation service to produce the actual invoice file. Email is handled by Gmail or your SMTP provider.

Total ongoing cost after setup: $0 if you self-host n8n and use free tiers. Or about $20/month if you use n8n Cloud and Invoice Ninja's paid plan for more features. Either way, it beats spending hours doing it manually.

The Automation Flow — Step by Step

Step 1: Set Up Your Trigger

In n8n, create a new workflow and add a Schedule trigger. I run mine every Friday at 4pm — it checks all active projects and generates invoices for any that have billable work logged that week. You could also trigger it from a form submission or a webhook from your time-tracking app.

Go to: Trigger → Schedule → Set time → Friday 16:00

Step 2: Pull Client and Project Data

Add a Google Sheets (or Airtable) node that reads your client list. Your spreadsheet needs at minimum: client name, email, project name, hourly rate, and hours logged this period. This is the data source that feeds everything downstream.

Node: Google Sheets → Read Rows → Filter: Status = "Active"

Step 3: Calculate the Invoice Amount

Add a Function node (n8n calls it "Code" in newer versions). Write a simple calculation:

const items = $input.all();
return items.map(item => ({
  json: {
    ...item.json,
    total: item.json.hours_this_week * item.json.hourly_rate,
    invoice_date: new Date().toISOString().split('T')[0],
    due_date: new Date(Date.now() + 14*24*60*60*1000).toISOString().split('T')[0],
    invoice_number: `INV-${Date.now()}`
  }
}));

Step 4: Generate the Invoice PDF

This is where Invoice Ninja's API earns its keep. Add an HTTP Request node to call the Invoice Ninja API, which takes your client data and line items and returns a PDF. If you prefer, you can use an HTML template and a PDF conversion service like WeasyPrint (self-hosted) or PDFMonkey.

For Invoice Ninja: HTTP Request → POST → https://invoiceninja.com/api/v1/invoices with your API key in the header and the invoice data as JSON body.

Step 5: Send the Email

Add a Gmail node (or SMTP node for other providers). Configure it to send to the client email from your spreadsheet, attach the PDF returned from Step 4, and use a template subject and body. I use:

Subject: "Invoice [Invoice Number] from PIXIPACE — Due [Due Date]"

Body: A simple professional note with the total amount due, payment methods, and a note to reply with any questions.

Step 6: Log the Invoice

Add one more Google Sheets node that writes back to a "Sent Invoices" tab with the invoice number, client, amount, date sent, and due date. This gives you a record without switching to another tool.

Common Mistakes to Avoid

MistakeWhat HappensFix
Not adding error handlingOne failed API call kills the whole batchAdd a catch node after each HTTP request
Hardcoding the due dateDue dates become wrong on bank holidaysUse dynamic calculation with buffer days
Sending to test clients in productionClients get test invoicesAdd a Status = "Active" filter, not just "Client" column
Not rate-limiting API callsInvoice Ninja throttles you mid-runAdd a 500ms wait between iterations

The Results After 4 Months

Time saved: about 2.5 hours per week, consistently. More importantly, invoices go out the same time every week without me thinking about it. Cash flow improved because invoices stopped slipping when I was busy. And I stopped making the occasional embarrassing error where I'd send last month's totals.

The setup took about 4 hours including reading the n8n docs and testing. That time was paid back in the first two weeks. Every week after that is pure gain.

Is n8n Right for This, or Should You Use Zapier or Make?

For a purely linear automation with no branching logic, Zapier or Make would work fine and are easier to set up. I use n8n specifically because it's self-hostable (zero ongoing cost), handles the code node elegantly, and I already run it for other workflows. If you're starting from scratch and want the fastest path, Make (formerly Integromat) has good Invoice Ninja integrations and a visual canvas that makes the flow easier to understand.

But if you're going to automate multiple workflows in your business, learning n8n is worth the investment. The self-hosting option alone saves $40-60/month at scale compared to Zapier's higher tiers.

Verdict

Automating invoice generation with n8n took one weekend and now runs invisibly. If you bill clients regularly, there is no good reason to keep doing this manually. The tools exist, they're mostly free, and the setup is approachable even if you've never touched an automation platform before.

Start with the Schedule trigger, connect your spreadsheet, and get one invoice sent. From there, everything else is just adding nodes.

More automation guides at blog.pixipace.com

No comments:

Post a Comment

Best Accounting Software for Freelancers and Small Business in 2025

I switched accounting software twice in two years as a freelancer before landing on the right setup. The first mistake cost me $600 in a ye...