Inspiration
Small businesses do the work, send the invoice, and wait. But late payment is not a rare edge case. According to the QuickBooks 2026 Small Business Late Payments Report, nearly 3 in 5 small businesses (59%) have invoices more than 30 days overdue, and businesses waiting on unpaid invoices are owed $17.7K on average. The Federal Reserve's Report on Payments also found that roughly 4 in 5 small firms face payment-related challenges. And research from the UK Department for Business and Trade found that businesses spending staff time chasing late payments lose an average of 86 hours per affected business each year.
I kept seeing the same pattern: the customer was not necessarily refusing to pay, and the invoice was not always disputed. The business simply did not have someone with the time to follow up in the right way at the right moment.
The hard part was never writing the reminder. The hard part was the judgment behind it: whether to contact the customer today, how firmly to follow up, which channel to use, when to wait, when to negotiate, and when pushing harder could cost more goodwill than it recovers.
That judgment should not remain another task buried in a crowded dashboard. It is something an AI agent can own, as long as its decisions stay inside clear, deterministic guardrails.
So I built Arrearly.
What it does
Arrearly is an AI receivables agent that decides the next best action for every overdue invoice and explains every decision it makes.
For each overdue invoice, the agent reads the complete account context: the outstanding balance, the number of days overdue, the customer's payment history, the full conversation, and every previous decision made on that account.
It then decides the single right action for today:
- Move through the escalation ladder one step at a time. The agent starts with a gentle reminder, moves to a firmer follow-up, proposes a payment plan when appropriate, issues a final notice, and eventually hands the case to a person. It never skips a step, so a customer who is four days late never receives the message intended for one who is ninety days late.
- Write the message in the appropriate tone and channel, whether email, WhatsApp, or Telegram, ready for delivery or human review.
- Propose and structure a payment plan when a customer signals cash flow pressure, turning an uncertain balance into a clear installment schedule with per-installment due dates.
- Stay quiet when waiting is the right decision. If a customer has already committed to a valid payment date, the agent pauses the chase and records why.
- Hand the account to a person when the invoice is disputed, the balance exceeds the autonomy limit, confidence is too low, or the escalation ladder has been exhausted.
Every decision appears on a decision board with the agent's reasoning, confidence score, selected action, and a clear record of whether it was executed autonomously or queued for review. Accounts that require human judgment are ranked by urgency, so the most important case is always at the top.
Each invoice also carries a live payment model. The agent shows the probability the invoice will be paid and the predicted number of days to payment, and it breaks that prediction down feature by feature, so a reader can see exactly which factors push the odds toward payment and which push against it. The model is one input to the agent's reasoning, never an instruction.
When money arrives, Arrearly treats settlement as first-class. Payments are collected through PayPal, and each invoice shows the payments received as PayPal receipts: the amount, the date shown in both the customer's timezone and the operator's, the transaction ID, and, for invoices billed in installments, exactly which installment each payment covers.
A business can also point Arrearly at its own book through an Add data screen, entering its own customers and invoices, which the agent then scores and works exactly like any other account.
How I built it
Arrearly is a deployed, polyglot application built with three programming languages and two Gemini deployment paths, each chosen for a specific role:
- TypeScript with Next.js 15, React 19, and Tailwind CSS v4 powers the complete web application, including the interface, API routes, agent workflow, live risk scoring, and end-to-end type safety.
- Gemini powers the reasoning layer through two deployment-specific paths. Local development uses Gemini 2.5 Flash on Vertex AI through Google Cloud, while the production deployment on Vercel uses Gemini 3.5 Flash through the Gemini Developer API. Both paths use the same structured prompt and return the same schema-constrained decision: action, tone, channel, reasoning, confidence score, risk score, review timing, and drafted message.
- Rust powers the batch risk-scoring engine, deployed as a scheduled Google Cloud Run job for whole-book rescoring. It uses the same scoring formula as the TypeScript application, keeping live and batch prioritization consistent while delivering predictable performance at higher volumes.
- Python with FastAPI and scikit-learn powers the payment-prediction service, deployed on Google Cloud Run and connected to the production Vercel application via
PREDICTOR_URL. A gradient-boosted classifier estimates the likelihood that an invoice will be paid, while a regression model estimates when payment may arrive. The agent uses those predictions as one input to its reasoning, never as an instruction.
The most important architectural choice is simple: the model proposes, but policy decides what is allowed.
The application selects the appropriate Gemini connection from environment variables, while the rest of the agent workflow remains unchanged. Whether the response comes from Gemini 2.5 Flash on Vertex AI locally or Gemini 3.5 Flash through the Gemini Developer API on Vercel, a deterministic policy engine checks the recommendation against the escalation ladder, grace periods, contact cooldowns, confidence thresholds, and handoff limits.
If the model proposes an action that breaks a rule, the policy engine automatically steps it back to the highest permitted action and records the override in the audit log.
This allows the agent to reason flexibly without giving it permission to ignore operational boundaries. Model drift, overconfidence, or prompt injection cannot produce an action that violates the enforced guardrails.
Challenges I ran into
- Making autonomy trustworthy. An autonomous agent is only useful when its decisions can be reviewed and challenged. I spent a significant part of the build designing the audit trail, so every run preserves what the agent decided, why it decided it, how confident it was, which model responded, whether policy changed the decision, and whether a person was involved.
- Keeping two implementations of one formula synchronized. Risk scoring runs in TypeScript during live requests and in Rust during batch processing. I tested both implementations against the same reference cases to prevent them from producing different results for the same invoice.
- Supporting two Gemini deployment paths without splitting the product. Local development uses Vertex AI and Application Default Credentials, while Vercel uses the Gemini Developer API and an API key. I kept both behind one agent interface so every downstream policy, audit, and UI component behaves consistently.
- Making the model's response reliable. A capable model can still return output that is truncated or wrapped in extra text. I set a generous token budget, disabled the thinking budget for this structured task, and wrote a defensive parser that repairs a nearly valid response before falling back, so a long drafted message never takes the whole decision down.
- Designing graceful degradation. A receivables process should not stop because an external model API is temporarily unavailable. When Gemini cannot respond or returns an invalid structured result, Arrearly falls back to a conservative offline policy engine. The run continues, but it is clearly marked as simulated in the log.
- Getting the tone right. Collecting overdue payments without damaging the relationship that created the revenue is a difficult communication problem. I designed the agent to treat silence as a process failure rather than deliberate refusal until the available evidence suggests otherwise.
- Making complex decisions understandable. Risk scores, confidence thresholds, escalation levels, and autonomous actions can quickly become opaque. I designed the interface so every important score, status, and decision can be understood without leaving the screen.
Accomplishments that I'm proud of
- A genuinely AI-native workflow where the agent makes operational decisions instead of merely generating text for a human to approve.
- A dual-path Gemini integration using Gemini 2.5 Flash on Vertex AI for local development and Gemini 3.5 Flash through the Gemini Developer API for the Vercel deployment.
- A deterministic policy engine that keeps autonomous decisions inside clearly defined business boundaries.
- A live, explainable payment model on every invoice, showing the probability of payment, the predicted days to pay, and a feature-by-feature breakdown of what drives the score.
- PayPal settlement with installment plans and dual-timezone scheduling, so recovered money is shown as real receipts and every due time is clear for both the customer and the operator.
- A complete decision board that makes the agent's actions, reasoning, confidence, overrides, and review queue auditable line by line.
- The aging spine, a visualization that places every invoice at its exact number of days overdue, with height representing the money at risk and position showing how long the balance has been outstanding.
- A channel-aware conversation interface that presents WhatsApp, email, and Telegram conversations in the format the customer actually experienced.
- An Add data workflow so a real business can enter and work its own customers and invoices, not just the sample book.
- A live Try it playground where anyone, including a judge, can describe an overdue invoice and hold a back-and-forth conversation with the real agent. The same Gemini call and the same deterministic policy engine answer every turn, so a promise to pay produces a hold, a disputed amount produces a handoff, and a plea for time produces a payment plan. It is clearly labelled as a preview, and nothing is ever delivered.
- A Decision Receipt that prints out once a decision clears the policy layer, recording the final action, tone, channel, confidence, risk score, policy outcome, decision source, model, and decision ID. It makes the audit trail tangible: the model proposes, the guardrails enforce, and Arrearly records.
- A polyglot architecture where TypeScript, Rust, and Python each solve a problem suited to their strengths, while the main application still deploys with a single command.
- A system that remains operational even without model access, while clearly distinguishing AI decisions from offline fallback decisions.
What I learned
The hardest part of building an AI agent is not calling the model.
The real work is building everything around it: the policies that make autonomy safe, the audit trail that makes decisions accountable, the fallback behavior that keeps the product reliable, and the interface that makes complex reasoning understandable.
The model is a component.
The system is the product.
Pilot users
Arrearly is new, so it runs for a small number of real businesses first rather than a crowd. The first is Heytugas.com, a services company that invoices clients for design and data work and, like most small businesses, had no one whose job was chasing the money back. The second is Kardi Putera Motor, a car-service and bus-rental business that had been tracking its receivables entirely by hand and is helped simply by having the follow-up handled.
I disclose both plainly as related parties rather than arms-length traction: Heytugas is a relationship I have known since 2010, and Kardi Putera Motor is a local business I know personally. They are the source of honest, first-hand feedback while the product proves itself. Any review they leave is written in their own words through the in-app review form, not by me.
One honest point about the live demo. The public deployment runs on a built-in demonstration dataset of thirty-six invoices with fictional customer names, so that anyone, including the judges, can explore the full product without seeing anyone's private financial data. The pilot businesses keep their real receivables private. This is also why the store is single-tenant for now: durable, per-business separation through Firestore and authenticated accounts is the next step on the roadmap, so each business can work its own book without it ever mixing with another's.
What's next for Arrearly
- Real channel delivery through the WhatsApp Business API and transactional email providers.
- Inbound reply parsing, so each customer response automatically becomes part of the agent's next decision.
- Payment reconciliation through PayPal, Stripe, and bank feeds, closing the loop from overdue invoice to cleared payment.
- Firestore persistence and multi-tenant accounts, allowing small businesses to onboard and manage their own receivables securely and durably.
- Per-customer tone profiles, learned from the communication approaches that have historically worked for each account.
- Weekly recovery reports showing what the agent recovered, what it chose not to chase, and which accounts still require human attention.
Bonus: Blog Post
I wrote a longer, behind-the-scenes article on Medium explaining how Arrearly makes, validates, and audits its decisions.
The short version: most receivables tools automate sending a fixed sequence of reminders on a schedule. Arrearly automates deciding, which is the part that traditionally required a person. For every overdue invoice, Gemini reviews the full account context and proposes the next action. A deterministic policy engine then checks that proposal against the escalation ladder, contact limits, and operating guardrails. If the proposed action breaks a rule, the system automatically steps it back to the highest permitted action. The model proposes, policy decides, and every decision appears on an auditable board with its reasoning and confidence score.
The article walks through the product end to end:
- The problem and the solution: why collections is a job almost every small business has and almost none of them staff, and how treating it as a sequence of decisions, rather than a sequence of reminders, changes the outcome.
- What makes it different: a direct comparison of automating sending against automating deciding.
- How it works, under the hood: the separation of powers where the model proposes and a deterministic policy engine disposes, the escalation ladder the agent climbs one rung at a time, the live payment-prediction model with its feature-by-feature explanation, and the offline fallback that keeps the book moving when the model is unreachable.
- The architecture and the three languages: how the pieces fit together, and why TypeScript runs the app, Rust runs the batch risk engine, and Python runs the prediction model, each doing the job it is best at.
- Getting paid: how PayPal settlement, installment schedules, and dual-timezone due dates turn a recovered invoice into a clear, auditable record.
- Adding your own accounts, and who it is for: how a real business points Arrearly at its own receivables, and why it runs for a couple of pilot businesses first.
Read the full article on Medium: Arrearly: The AI Agent That Doesn't Just Send Reminders. It Decides.
Repository Access for Judging
The Arrearly source-code repository is private to protect the project's source code while still providing full access for hackathon evaluation.
In accordance with the official Build with Gemini XPRIZE submission rules for private repositories, I have granted repository access by inviting both required judging and testing accounts:
- Devpost Testing:
testing@devpost.com - Hacker Fund Judging:
judging@hacker.fund
Both invitations have been sent through GitHub, giving the authorized testing and judging teams access to inspect the complete Arrearly source code during the evaluation period.
Repository: github.com/wiqilee/Arrearly
The repository contains the source code and implementation used to build Arrearly, including the Gemini-powered agent workflow, deterministic policy guardrails, payment-prediction service, and supporting application infrastructure.
Built With
- fastapi
- gemini
- gemini-api
- google-cloud
- next.js
- node.js
- python
- react
- rust
- scikit-learn
- serde
- tailwindcss
- typescript
- vercel
- vertex-ai

Log in or sign up for Devpost to join the conversation.