Built an automated AR escalation engine for aging invoices (QBO/Xero sync + urgency tiering + owner approval gates)

Hello, just starting out here and have been working on this n8n workflow for a while and definitely appreciate any feedback.

I also wanted to make it so you couldn’t accidentally blast aggressive automated collection emails to key accounts, so I built in an option to allow users to apply a threshold (or key names) that will flag and redirect notices to the owner for approval before going out.

Here’s the breakdown of how I wired together what I’m calling the automated AR escalation system with built-in “Human-in-the-Loop” approval gates. It’s a bit wordy so I’ll work on that.

(the quickbooks workflow below)

Under the Hood

1. Pulling & Standardizing the Receivables Data

·The Trigger: A simple Schedule Trigger running every morning at 9:00 AM. It’s adjustable, but the Client_Config node ultimately directs when it will go through the system based on custom input.

·Fetching the Invoices: An HTTP Request (or native QBO node in this case) queries open/overdue invoices.

·Cleaning the Schema: since accounting APIs can have deeply nested JSON arrays (I’ve learned) and inconsistent date formats, I used a Filter node right after the pull to normalize everything into clean key-value pairs: client_name, client_email, amount, due_date, and invoice_id

2. Aging Logic & Smart Urgency Tiers

Instead of hardcoding static reminders, I wanted to have a more polished, custom feel, so I route the parsed invoices through a custom Code Node (JavaScript) to calculate exact days past due and tag them with an urgency level:

// Calculate days overdue
const today = new Date();

for (let item of $input.all()) {
const dueDate = new Date(item.json.due_date);
const diffTime = today - dueDate;
const daysOverdue = Math.floor(diffTime / (1000 * 60 * 60 * 24));

// Assign Urgency Tier
if (daysOverdue >= 1 && daysOverdue <= 14) {
item.json.urgency_tier = ‘Tier 1 - Friendly Nudge’;
} else if (daysOverdue >= 15 && daysOverdue <= 30) {
item.json.urgency_tier = ‘Tier 2 - Firm Notice’;
} else if (daysOverdue > 30) {
item.json.urgency_tier = ‘Tier 3 - Escalated’;
}
}

return $input.all();

A Switch Node (risk router) then takes those tags and splits the pipeline based on the threshold, if any set up in the Client_Config node :

3. The “Don’t Blast My VIP Client” Safety Valve (Wait Node)

The trickiest part of automating collections is trusting the machine. To prevent disaster on high-dollar or sensitive accounts, I built a human-approval gate using n8n’s Wait Node for any instances that meet the threshold and travel down the risk routers false path:

  • Low-Risk / Minor Invoices (< $1k & Tier 1): These flow through automatically to draft and send standard, polite follow-up emails.
  • High-Risk / High-Dollar Invoices (> $1k or Tier 3): The workflow generates a dynamic webhook callback inside a Wait Node (On Webhook Call) and sends an internal notification email to the business owner first. ***The dollar threshold is ultimately set by the user via the Client_Config node, so that’s completely customizable
  • The Owner’s Interface: The owner gets a summary email:

“Invoice #1042 for $3,500 is 20 days overdue. Review email preview and [Click Here to Approve Sending].”

  • Paused Execution: n8n holds execution in a state until the owner clicks approve. Once clicked, it resumes and sends off the next high-risk approval or packages the full client-facing email and pushes the notices out

Web-based review that lets the owner make changes if needed before sending through:

Recreate It or Grab the Turnkey Files

If you want to build this yourself from scratch, the node pipeline and JS snippet above give you the core logic tree.

Or if you or your agency clients want to save some hours on troubleshooting API edge cases, credential mapping, and setting up formatted HTML templates, I’ve packaged up the ready-to-import JSON blueprints with complete setup guides for purchase:

  • :package: Turnkey Workflow JSONs: AutomateNow on Whop
  • :magnifying_glass_tilted_left: Free AR Diagnostic Tool: If you just want to run a quick audit on your uncollected revenue runway, you can test it out at AutomateNow.app via the top-right link on the homepage (another n8n workflow I built that will compile and send out a custom report based on the information gathered in the form; let me know if there’s any interest in seeing this in more detail)

Would love to hear feedback from the community! How are you guys handling Human-in-the-Loop gates or accounting API quirks in your n8n workflows?

1 Like