Published on September 22, 2025.
Last week, I wrote about NetSuite AI Agents — what they are, and why they matter. I explained that agents aren’t just about analysis; they can watch, decide, act, and even learn over time.
In this post, I'll discuss how I've been putting the AI Agent concept to work for a NetSuite client who came to me struggling with receivables.
Like many growing businesses, my client was feeling the pain of receivables creeping past terms. Cash flow had become unpredictable. Month-end was a stressful scramble to figure out who had paid, who hadn’t, and what that meant for the weeks ahead.
They weren’t short on tools. NetSuite’s aging reports, dashboards, and saved searches were all in place. But those tools required people to constantly watch and interpret them. The finance team was reactive and stretched thin, while leadership was left asking the same question: “When exactly is the money coming in?”
That’s when I proposed creating an Accounts Receivable AI Agent — a service designed to act like a dedicated teammate, continuously monitoring AR activity, spotting issues, and taking action where appropriate.
The agent is built on Suite.js, which provides the orchestration layer that runs queries, applies rules, and triggers actions. It operates outside of NetSuite, hosted on a low-cost Amazon LightSail server. That external execution means it can monitor and act 24/7, without depending on a logged-in user or scheduled script.
An example of the log file from an early run of the AR Agent is included at the end of this post. It illustrates the agent’s cycle as it runs. You can see it detecting new fulfillments and deciding whether invoices should be generated, flagging unusual payments (like partials or out-of-sequence ones), calculating DSO, and producing a prioritized list of at-risk accounts. It also shows guardrails in action (like holding invoices for review) and the human-in-the-middle checkpoints where staff approve or override. The log provides visibility into the agent watching, deciding, acting, and then learning from each cycle.
I’ve made good progress on the agent, but it's still very much a work in progress. Some guardrails are still in place, and I'm actively working with my client to adjust the amount of autonomy to give the agent.
Here’s what I’ve implemented so far:
Automated Invoice Generation
• What it does: Creates invoices tied to actual fulfillment events, reducing premature or delayed billing. Supports deposits and pro forma invoicing.
• How I implemented it: SuiteQL queries monitor Item Fulfillments and Sales Orders. A custom instance of SuiteAPI transforms eligible orders into invoices. Guardrails ensure nothing posts too early. For now, all invoices still pass through a human-in-the-middle (HITM) review before they go out.
Cash Receipt Monitoring
• What it does: Flags unusual payment patterns — partials, unapplied funds, or out-of-sequence payments.
• How I implemented it: SuiteQL compares open invoices and payment applications. SuiteAPI pulls detailed payment data. Alerts are generated automatically, but AR staff still decide how to act. The long-term goal is to let the agent draft branded customer communications itself.
DSO Tracking
• What it does: Keeps a rolling calculation of Days Sales Outstanding, surfacing trends in real time instead of at quarter-end.
• How I implemented it: A SuiteQL-based algorithm runs daily, with results exposed in dashboards and daily summaries. This already gives leadership clearer visibility into cash inflows.
Collections Prioritization
• What it does: Produces a daily ranked list of customers needing attention, based on balance, invoice age, and payment patterns.
• How I implemented it: A rules engine running in Suite.js applies scoring logic to SuiteQL results. For now, the agent just hands the AR team the priority list — but the foundation is there for autonomous follow-up.
Exception Controls
• What it does: Detects transactions that don’t follow expected patterns, such as partially paid invoices or skipped billing cycles.
• How I implemented it: SuiteQL queries surface exceptions, guardrails reduce noise, and results are logged externally in SQLite for auditability. Staff can override with explanations, which the agent records to refine its rules.
One question I've been getting about AI Agents is: “Where does the intelligence actually come in?”
Here’s how I’ve layered in learning, adaptation, and smarter decisioning — not just hard-coded rules.
Adaptive Thresholds & Trend Detection
The agent doesn’t just apply fixed cutoffs (e.g. “flag invoices older than 60 days”). It watches how DSO, payment lag, and invoice-aging shift over time. If it sees consistent drift in those metrics (for example, customers systematically paying 3-5 days slower than two months ago), it raises internal alerts or adjusts the thresholds for flags.
This means the system is “learning” from recent history, not just enforcing what was true yesterday.
Exception Learning & Noise Filtering
One of the harder parts is dealing with “false positives” — transactions that look odd, but are actually pretty normal given some edge case.
I built a feedback loop: AR staff override certain exception flags when they judge “this is okay given X.” Those overrides are logged. Over time, the agent adjusts its rules so that similar cases in the future are either deprioritized or not flagged at all. That reduces alert fatigue.
Scoring & Prioritization Based on Multiple Signals
Rather than picking just “oldest invoice” or “largest balance,” the collections prioritization is based on a blended score: invoice age, payment history (are they intermittently late?), recent partial payments, outstanding balance, how many invoices the customer has open, etc. The weights of these signals aren’t static — I’m tuning them based on which kinds of accounts tend to become real risks versus which ones resolve quickly.
Predictive Alerts
As more data comes in, there are early-warning patterns that the agent watches for.
For example:
• If a customer consistently pays later the day before invoices are due.
• If there are repeated partial or unapplied payments.
• If new fulfillment-to-invoice lags are increasing.
These signals are compiled into “risk scores,” so the agent can alert before something becomes past due, rather than only when it already is.
Human-in-the-Middle (HITM) Learning Phase
Because it’s still a work in progress, many actions are gated through HITM review. Every time a human intervenes (approves, rejects, edits), the agent records what was done, and slowly, the goal is to reduce those needed interventions by learning from them. That way, over time it can gain more autonomy in safer areas.
Right now, the AR AI Agent is configured to be intentionally cautious - almost to the point of being overly cautious. While it can generate invoices, flag exceptions, and even draft customer reminder emails, it doesn’t act without oversight in certain areas.
For example:
• Invoices are routed through a Human-in-the-Middle step before being released.
• Customer payment anomalies are flagged, but it’s still up to AR staff to decide how to follow up.
• Collections emails are drafted but not yet sent automatically.
Every one of those interventions is logged. When a staff member approves, rejects, or edits an action, the agent records it. Over time, that feedback helps “teach” the system what’s acceptable and where the real risks are.
The goal isn’t to replace the AR team — it’s to make their work easier by cutting through noise, enforcing consistency, and giving them clearer visibility. Ultimately, it’s about freeing them up to focus on higher-value tasks. To get there, we need to build trust in the agent step by step, so it can gradually take on more responsibility and autonomy.
Even with the guardrails still in place, the AR AI Agent has already made a difference. It’s caught unapplied payments, flagged invoices that were never sent, and highlighted accounts slipping behind.
The finance team isn’t “hands off” yet — but they’re no longer buried in reports. They’re reacting faster, with better information.
For me, this project has been a clear demonstration of what AI Agents in NetSuite can do.
The AR AI Agent doesn’t replace people — it augments them. It enforces discipline, surfaces risks, and builds predictability around cash flow.
And the client is already thinking about the future. They’ve asked about a similar Accounts Payable Agent — one that could catch duplicate vendor invoices, flag unusual payment runs, and make sure early-payment discounts don’t slip through the cracks. The company's CFO pointed out that by automating both the AR and AP, they'll end up with a fuller picture of working capital.
This agent is still evolving, with guardrails in place and autonomy carefully dialed in. But even in its early form, it proves the point: NetSuite AI Agents can take pressure off finance teams and make cash flow more predictable.
Here's an example of the log file for an early run of the AR Agent.
[2025-09-20 07:58:14] [INFO] Accounts Receivable AI Agent starting up... [2025-09-20 07:58:14] [INFO] Running on AWS LightSail (512 MB RAM, 1 vCPU). [2025-09-20 07:58:14] [INFO] Suite.js orchestration layer initialized (heartbeat active). [2025-09-20 08:00:01] [WATCH] Polling NetSuite for new fulfillment events... [2025-09-20 08:00:01] [INFO] SuiteQL query sent via SuiteAPI... [2025-09-20 08:00:04] [INFO] 2 unbilled fulfillments found (SO12345, SO12346). [2025-09-20 08:00:05] [DECIDE] Invoice generation criteria met for SO12345 (100% shipped). [2025-09-20 08:00:07] [ACT] Created invoice INV10339 via SuiteAPI (status: pending approval). [2025-09-20 08:00:08] [HITM] Invoice INV10339 routed for human review before release. [2025-09-20 08:00:09] [DECIDE] Invoice deferred for SO12346 (partial shipment detected). [2025-09-20 08:00:09] [INFO] Guardrail: Prevented premature invoicing. [2025-09-20 08:05:12] [WATCH] Checking for payments applied since last cycle... [2025-09-20 08:05:12] [INFO] 6 payments detected. [2025-09-20 08:05:13] [DECIDE] Payment PAY20314 is out-of-sequence (applied to INV10299, older INV10295 still open). [2025-09-20 08:05:13] [ACT] Flagged for AR team follow-up (customer: ACME Industrial). [2025-09-20 08:05:14] [DECIDE] Payment PAY20315 partially applied (customer: Globex). [2025-09-20 08:05:14] [ACT] Created exception record EXC-20250920-001. [2025-09-20 08:10:41] [WATCH] Calculating current DSO (30-day rolling). [2025-09-20 08:10:42] [INFO] Current DSO: 48.3 days (↑ 2.1 days vs. last week). [2025-09-20 08:10:42] [DECIDE] Threshold exceeded (>45 days). [2025-09-20 08:10:43] [ACT] Generated alert email to CFO and AR controller. [2025-09-20 08:10:43] [LEARN] Recorded trend data to SQLite (learning model updated). [2025-09-20 08:15:27] [WATCH] Prioritizing collections. [2025-09-20 08:15:28] [INFO] Top 3 risk accounts: 1. ACME Industrial — $142,000 past due, oldest invoice 67 days. 2. Globex — $98,500 past due, partial payments detected. 3. Initech — $55,000 past due, payments slowing. [2025-09-20 08:15:28] [ACT] Generated daily collections priority report (delivered via SuiteAPI → File Cabinet). [2025-09-20 08:15:29] [HITM] Report review required by AR lead before sending reminders. [2025-09-20 08:20:05] [WATCH] Exception scanning complete. [2025-09-20 08:20:06] [INFO] Exceptions logged: 3 (2 partial payments, 1 unapplied). [2025-09-20 08:20:06] [LEARN] Exception overrides from AR staff will be incorporated into rule tuning. [2025-09-20 08:25:00] [INFO] Cycle complete. Next run scheduled in 5 minutes. [2025-09-20 08:25:00] [HEARTBEAT] Agent operational and waiting for next cycle...
Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.
I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.
I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.
Copyright © 2025 Tim Dietrich.