DEV Community

WorkflowStash
WorkflowStash

Posted on

Form submitted, invoice sent: building a Form-to-Invoice flow in n8n

If you sell services, the gap between "the client filled in the order form" and "the invoice is in their inbox" is where getting paid quietly stalls. You copy line items into a spreadsheet, work out the totals, save a PDF, attach it to an email, and file a copy somewhere you will never find again. It is five minutes of admin per order, and it is the five minutes that gets skipped.

This post walks through a small n8n workflow that closes that gap: nine nodes, no manual steps between form submission and sent invoice.

What the flow does

  1. A customer submits your order form. A Webhook node receives the order as JSON.
  2. A Code node validates the email address, works out line totals, tax, and the due date, and generates an invoice number.
  3. The invoice is logged in Google Sheets.
  4. A second Code node turns the invoice into a printable file.
  5. Gmail sends it to the client as an attachment.
  6. Google Drive keeps an archived copy, in parallel with the email.

The form contract

Your form POSTs JSON to the webhook URL:

{
  "client_name": "Acme Studio",
  "client_email": "billing@acme.example",
  "items": [
    { "description": "Brand refresh, phase 1", "quantity": 1, "unit_price": 499.00 },
    { "description": "Extra revision round", "quantity": 2, "unit_price": 75.00 }
  ],
  "currency": "USD",
  "tax_rate": 0.1,
  "due_days": 14
}
Enter fullscreen mode Exit fullscreen mode

currency, tax_rate, and due_days are all optional — the defaults are USD, no tax, and 14 days. A single-line order also works with plain description, quantity, and unit_price fields instead of an array.

Node by node

1. New Order Form (Webhook). The entry point. Any form tool that can POST JSON works here — a website form, a Typeform webhook, or a simple HTML form pointed at the production URL.

2. Build Invoice (Code). The brains of the workflow. It does four things in order: it validates client_email first and throws an error if it is missing or invalid, so a bad address fails loudly instead of silently dropping an invoice; it normalizes the order lines; it computes subtotal, tax, and total; and it stamps an issue date, a due date (issue date plus due_days), and an invoice number in the format INV-YYYYMMDD-xxxxx.

3. Save Invoice to Sheet (Google Sheets). Every invoice lands in one row, with these headers: Invoice ID, Client name, Client email, Items, Subtotal, Tax, Total, Currency, Issue date, Due date, Status. This is the audit trail — and the Status column is where you later mark invoices paid, or spot the overdue ones.

4. Create Invoice File (Code). This turns the invoice into an HTML file (Invoice-INV-....html) carried in a binary field both downstream nodes read. It opens in any browser and prints cleanly to PDF, so the client never needs special software to read it.

5. Send Invoice Email (Gmail). Sends the file as an attachment. Before activating, replace the [Your Name] / [Your Business Name] placeholders in this node and paste in your payment link or bank details.

6. Archive Copy to Drive (Google Drive). Saves the same file into a folder you pick. One copy goes to the client, one copy stays with you — no more hunting through sent mail when a client asks for a copy in six months.

Three edge cases worth handling before you activate

  • Bad email, no invoice. The validation in node 2 is deliberate. An invoice with nowhere to go should error, not vanish.
  • Tax as a decimal. tax_rate is 0.1 for 10%, not 10. Getting this wrong is the easiest way to overcharge a client by 10x.
  • Single-line orders. If your form only ever sells one thing, the flat description / quantity / unit_price fields keep the form simple.

Setup checklist

  • An n8n instance, with Google Sheets, Gmail, and Google Drive credentials connected.
  • A sheet with the eleven headers listed above.
  • A form posting JSON to the webhook URL.
  • Placeholders replaced in the Gmail node, and a Drive folder picked in node 6.

Where to get it

The free workflows live here: https://github.com/newbeechong-glitch/free-n8n-workflows

This Form-to-Invoice workflow is part of the WorkflowStash n8n pack ($29, four workflows including this one): https://ko-fi.com/s/4b5ee09c2f

And if you would rather not set it up yourself, there is a custom build service that will build a workflow like this one around your own forms and tools: https://ko-fi.com/workflowstash/commissions

One honest note: this workflow is structure-checked — the JSON parses, every connection points at a real node, and the two Code nodes were tested offline against sample orders (a sample order came out at subtotal 649.97, tax 65.00, total 714.97, due 2026-11-30). It has not been through a live n8n import test yet. If you run it, I would genuinely like to hear how it goes.


Top comments (0)