<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amplence</title>
    <description>The latest articles on DEV Community by Amplence (@amplence).</description>
    <link>https://dev.to/amplence</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4167968%2Fd63b7738-04ac-4cf3-a980-7771bf1810d1.png</url>
      <title>DEV Community: Amplence</title>
      <link>https://dev.to/amplence</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amplence"/>
    <language>en</language>
    <item>
      <title>Our n8n workflow said "Active" for a day while doing nothing</title>
      <dc:creator>Amplence</dc:creator>
      <pubDate>Wed, 25 Nov 2026 22:25:53 +0000</pubDate>
      <link>https://dev.to/amplence/our-n8n-workflow-said-active-for-a-day-while-doing-nothing-6f5</link>
      <guid>https://dev.to/amplence/our-n8n-workflow-said-active-for-a-day-while-doing-nothing-6f5</guid>
      <description>&lt;p&gt;One of our client workflows said "Active" for most of a day while it did nothing at all.&lt;/p&gt;

&lt;p&gt;The workflow is a 37-step n8n pipeline we built for CollageDepot, an online art store. It reads every customer email, looks up the live Shopify order, drafts a reply in the customer's language (Dutch, English, German or French), and routes anything sensitive to a person. It runs on a self-hosted n8n instance with Shopify, Airtable and OpenAI.&lt;/p&gt;

&lt;p&gt;In September, the email trigger quietly stopped receiving mail. n8n still showed the workflow as Active. Nothing errored, nothing alerted. The client noticed before we did, because customers were waiting longer than usual for replies. It was down for under a day and the only damage was late answers, but it was a useful lesson about what "Active" actually means.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened
&lt;/h2&gt;

&lt;p&gt;The workflow starts with an IMAP trigger that keeps a connection open to the support mailbox. During a forced reconnect, that connection dropped and didn't come back. The workflow itself was still switched on, so the editor showed the green Active toggle.&lt;/p&gt;

&lt;p&gt;That's the trap. In n8n, "Active" means the workflow is enabled. It does not mean its trigger is still receiving events. A listener-style trigger (IMAP, a long-lived connection, some polling setups) can die while the toggle stays green.&lt;/p&gt;

&lt;p&gt;Our fix for this incident was small: we removed the reconnect setting that caused the drop. The bigger takeaway was that we had no signal that would have told us before the client did.&lt;/p&gt;

&lt;h2&gt;
  
  
  "Active" vs "working": watch the output, not the toggle
&lt;/h2&gt;

&lt;p&gt;If a workflow is supposed to process something regularly, the most reliable health check is whether it actually processed anything. Some ways to get that signal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A volume check.&lt;/strong&gt; If a support inbox normally gets mail every hour during business hours, then zero executions in two business hours is a problem, whatever the toggle says. A small scheduled workflow can count recent executions (or rows written downstream) and alert when the count is zero.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An Error Trigger workflow.&lt;/strong&gt; n8n lets you attach an error workflow that runs when another workflow fails. It won't catch a trigger that silently stops, but it catches everything that fails loudly, which is most problems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An outside heartbeat.&lt;/strong&gt; Have the workflow ping an external monitor each time it runs, and let that monitor alert you when the pings stop. The point is that the check lives outside the thing it's checking.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of these is complicated. The mistake is assuming the editor's status is the same as the business outcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other ways a self-hosted workflow fails quietly
&lt;/h2&gt;

&lt;p&gt;The same system taught us three more lessons that never show up as an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The disk fills up.&lt;/strong&gt; Execution logs from AI steps plus daily database backups were adding about 1 GB a day. Nothing warns you until the disk is nearly full and things start failing at once. n8n has execution-data pruning settings (for example &lt;code&gt;EXECUTIONS_DATA_PRUNE&lt;/code&gt; and &lt;code&gt;EXECUTIONS_DATA_MAX_AGE&lt;/code&gt;); set them on day one and keep an eye on disk usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third-party APIs move under you.&lt;/strong&gt; The workflow was still pointed at a Shopify API version that Shopify had since retired. Shopify releases new API versions on a schedule and retires old ones, so a store integration needs a calendar reminder, not just a working test today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Models get retired.&lt;/strong&gt; When an AI provider retires a model, swapping the model name is a one-line change. Re-testing everything that depends on it is not. For our client builds, properly re-testing after a model retirement takes about three weeks.&lt;/p&gt;

&lt;h2&gt;
  
  
  A short checklist for any production workflow
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Does every event-driven workflow have a check on its output, not just its status?&lt;/li&gt;
&lt;li&gt;Is there an Error Trigger workflow, and does it notify a person who will read it?&lt;/li&gt;
&lt;li&gt;Is execution data pruned, and is disk usage watched?&lt;/li&gt;
&lt;li&gt;Do you know which API versions and AI models each workflow depends on, and when they retire?&lt;/li&gt;
&lt;li&gt;Does the client know who gets the alert, and what happens next?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most automation failures we've seen aren't dramatic. They're a green toggle on a workflow that stopped doing its job. If you'd rather not run that kind of monitoring yourself, it's part of how we scope &lt;a href="https://amplence.com/services/workflow-automation-services" rel="noopener noreferrer"&gt;workflow automation&lt;/a&gt; projects for small teams.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article was written with the help of AI, from our own incident notes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>devops</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Let the model read the invoice, not approve it: an n8n pattern for AP automation</title>
      <dc:creator>Amplence</dc:creator>
      <pubDate>Wed, 07 Oct 2026 09:44:21 +0000</pubDate>
      <link>https://dev.to/amplence/let-the-model-read-the-invoice-not-approve-it-an-n8n-pattern-for-ap-automation-58g4</link>
      <guid>https://dev.to/amplence/let-the-model-read-the-invoice-not-approve-it-an-n8n-pattern-for-ap-automation-58g4</guid>
      <description>&lt;p&gt;Most "AI invoice automation" demos stop at the fun part: a model reads a PDF and spits out JSON. The hard part is what happens next. Who decides the invoice gets paid? What stops a fake "we changed our bank details" email from going straight through?&lt;/p&gt;

&lt;p&gt;We built an accounts payable workflow in n8n around one rule: &lt;strong&gt;the model reads the invoice, code decides what happens to it.&lt;/strong&gt; The model never approves anything. This post walks through the pattern, with the actual checks we run.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of the workflow
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A Gmail trigger catches emails with a PDF attached.&lt;/li&gt;
&lt;li&gt;The workflow calls itself once per email (Execute Workflow), so every invoice gets its own run, its own logs and its own failure.&lt;/li&gt;
&lt;li&gt;The PDF is filed in Google Drive, then one Claude call turns it into fixed JSON fields.&lt;/li&gt;
&lt;li&gt;A Code node runs every check and picks a route: &lt;code&gt;auto_approve&lt;/code&gt;, &lt;code&gt;approve&lt;/code&gt; (a person in Slack) or &lt;code&gt;hold&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Approved invoices become QuickBooks bills. Held ones get the right follow-up. Everything lands in a Google Sheet log.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Splitting per email matters more than it looks. If one batch run handles five invoices and the third one throws, you get a half-processed mess. One execution per invoice means one red run you can retry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: ask the model for fields, not decisions
&lt;/h2&gt;

&lt;p&gt;The extraction prompt asks for a fixed schema: vendor name, tax ID, invoice number, dates, currency, subtotal, tax, total, PO number, bank details, line items, plus two fields that do a lot of work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;is_invoice&lt;/code&gt;: statements, quotes, receipts and payment reminders look like invoices. Asking the model to say so up front stops them from becoming bills.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;confidence&lt;/code&gt;: a 0 to 1 self-rating. It is not calibrated, but very low values reliably flag blurry scans and unusual layouts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is no "should we pay this?" field. That question never goes to the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: normalise before you compare
&lt;/h2&gt;

&lt;p&gt;Half the bugs in invoice matching are string comparisons. "Acme, Inc." and "ACME Inc" are the same vendor. "INV-00042" and "inv 42" are probably the same invoice. So every comparison goes through small key functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// drop legal suffixes so "Acme Inc" and "ACME, Inc." match&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;nameKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="nf"&gt;b&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incorporated&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;inc&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;llc&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;ltd&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;limited&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;gmbh&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;corp&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;corporation&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;co&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;plc&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;pty&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;bv&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;sarl&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;srl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="n"&gt;b&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;?/&lt;/span&gt;&lt;span class="n"&gt;gi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// invoice numbers, tax IDs, PO numbers: uppercase, alphanumeric, no leading zeros&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;idKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;Z0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vendors are matched on tax ID first and name second, because names drift and tax IDs usually do not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: two lists, holds and notes
&lt;/h2&gt;

&lt;p&gt;The routing node keeps two arrays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;holds&lt;/strong&gt;: anything that stops the invoice until a person looks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;notes&lt;/strong&gt;: anything that sends it to a human approver instead of auto-approving.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'hold'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;holds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;poMatched&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;autoApproveLimit&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'auto_approve'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'approve'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each check pushes a plain-English sentence, not a code. Those sentences go straight into the Slack message and the log, so the approver reads &lt;em&gt;why&lt;/em&gt; it came to them rather than &lt;code&gt;ERR_PO_MISMATCH&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The checks that actually catch things
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Vendor and sender.&lt;/strong&gt; Is the vendor on the list and active? Did the email come from the domain on the vendor record? An invoice from &lt;code&gt;acme-billing.co&lt;/code&gt; when the record says &lt;code&gt;acme.com&lt;/code&gt; is held.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bank details.&lt;/strong&gt; If the invoice includes bank details and they differ from the vendor record, it is held and flagged as possible payment fraud. We also run a regex over the email body and the model's notes for phrases like "updated bank details" or "remit to our new account". Business email compromise usually announces itself in exactly those words.&lt;/p&gt;

&lt;p&gt;When that hold fires, the workflow alerts finance in Slack and &lt;strong&gt;never replies to the sender&lt;/strong&gt;. Replying to a compromised thread just confirms to the attacker that someone is reading.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmetic.&lt;/strong&gt; Subtotal plus tax should equal the total, and the line items should add up to the subtotal (with a small tolerance for rounding). Models sometimes misread one digit; this catches it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Duplicates, three ways.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Same vendor and same invoice number already in the log.&lt;/li&gt;
&lt;li&gt;Same vendor, same amount, invoice dates within N days (the classic "resent with a new number").&lt;/li&gt;
&lt;li&gt;The bill already exists in QuickBooks, which catches bills someone entered by hand before the automation existed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Purchase orders.&lt;/strong&gt; Is the PO on the list, still open, raised for this vendor and in the same currency? Then we subtract everything already approved against that PO, so three invoices cannot each "fit" a PO that only has room for one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;invoiced&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;idKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;po_number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;poKey&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="n"&gt;approved&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;num&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;remaining&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;num&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;po&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;invoiced&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;remaining&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tolerancePct&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;poMatched&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Approvals that respect separation of duties
&lt;/h2&gt;

&lt;p&gt;Small, PO-matched invoices with no notes approve themselves. Everything else goes to a Slack approver using the Slack node's send-and-wait operation, so the workflow pauses until someone clicks Approve or Decline.&lt;/p&gt;

&lt;p&gt;Two rules sit on top:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Above a second threshold, a second approver must also say yes.&lt;/li&gt;
&lt;li&gt;If the usual approver raised the PO, the request goes to a backup approver instead. The person who ordered something should not be the person who signs off paying for it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Not every hold is the same
&lt;/h2&gt;

&lt;p&gt;A held invoice gets one of three follow-ups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fraud risk&lt;/strong&gt; (bank or domain mismatch): Slack alert to finance, no reply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixable by the vendor&lt;/strong&gt; (unknown PO number, totals that do not add up): a polite email asking for a corrected invoice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everything else&lt;/strong&gt;: labelled in Gmail and logged for a person to review.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Gmail labels mirror the outcome (approved, held, rejected), so the AP inbox doubles as a status board.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we would tell anyone building this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the model on extraction. Every decision you hand to it is one you cannot explain to an auditor.&lt;/li&gt;
&lt;li&gt;Write holds as sentences. The approver, the log and the vendor email all reuse them.&lt;/li&gt;
&lt;li&gt;Test duplicates by running the same invoice twice. Our pinned sample does exactly that.&lt;/li&gt;
&lt;li&gt;Make the workflow its own error workflow, so a failure posts to the AP channel instead of failing silently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full workflow is free on the n8n template library: &lt;a href="https://n8n.io/workflows/20234" rel="noopener noreferrer"&gt;Approve vendor invoices from Gmail with Claude, PO matching and Slack, then post bills to QuickBooks&lt;/a&gt;. We also wrote up the setup and the Google Sheet structure in more detail on &lt;a href="https://amplence.com/blog/n8n-invoice-approval-workflow" rel="noopener noreferrer"&gt;our blog&lt;/a&gt;. The same split, a model for reading and plain rules for deciding, is how we approach most of our &lt;a href="https://amplence.com/services/business-process-automation" rel="noopener noreferrer"&gt;business process automation&lt;/a&gt; work.&lt;/p&gt;

&lt;p&gt;If you have built AP automation in n8n, I would like to hear which checks caught real problems for you, and which ones turned out to be noise.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>ai</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
