Inspiration
Freelancers and small businesses don't struggle to send an invoice. They struggle with everything after it: remembering to check whether it was paid, awkwardly chasing the client, and guessing why the money hasn't arrived. That follow-up is repetitive, easy to forget, and costs real cash flow.
We wanted an assistant that does the whole job from a single sentence, like "Invoice Acme $2,500 for website work, net 30", and keeps going after the invoice is out the door.
What it does
Dueflow is an AI agent that manages the PayPal payment lifecycle from a chat window:
- Create and send: it turns a plain-English request into a PayPal invoice. It shows the plan and the exact details, and creates nothing until you reply
CONFIRM. - Watch: it monitors every invoice in the background and posts into the chat when one is paid or changes.
- Chase: when an invoice goes overdue it sends a reminder automatically, at most once a day per invoice.
- Explain: ask "why haven't I been paid?" and it reads the real invoice state (opened or not, days overdue, reminders sent) and tells you the likely reason and the next step.
- Refund and more: refunds, cancelling, reopening and deleting invoices, QR codes, earnings, disputes, shipment tracking, and one-off pay links, all from chat or the dashboard.
How we built it
- Agent: a LangGraph state graph with a persistent checkpointer, so a conversation survives restarts. The language model (Ollama Cloud, with Google Gemini as an option) only extracts intent and fields. Python enforces every confirmation gate, so the model can never move money on its own.
- PayPal: all calls go through the official PayPal MCP server against the Sandbox, with a REST fallback. Webhooks are supported: each one is verified with PayPal, then the invoice is re-read from PayPal before anything changes, so a forged request can't fake a payment.
- Backend: FastAPI, SQLAlchemy and SQLite for events, invoice state and remembered customers, plus a background monitor.
- Frontend: Next.js and React dashboard with a live chat, invoice list and activity feed.
- Quality: over 100 backend tests and 21 frontend tests, plus a Postman collection of about 57 requests for end-to-end checks.
Challenges we ran into
- Keeping an LLM away from money. We split the work: the model understands, the code decides. Confirmations, amounts and due dates are computed and checked in Python.
- Retries that can't double-charge. Only calls that are safe to repeat are retried. A timed-out "create invoice" or "refund" is never retried blindly.
- Real-world bugs found by running the whole flow live. A cached PayPal token that kept being served after the laptop slept, "$450" being treated as a missing currency, and a stray "CONFIRM" that could have created a duplicate invoice. Each one now has a test.
- Demoing "overdue" without waiting days. We added a simulate-overdue switch, available only in development builds, so the reminder flow can be shown live.
What we learned
The most useful agents aren't the ones that do the most on their own. They are the ones that are safe to trust. Making every irreversible step explicit and verified mattered more than adding clever features.
What's next
Instant payment updates through a public webhook, richer customer-payment insights, and support for more payment flows beyond invoices.
Built With
- fastapi
- google-gemini
- langgraph
- model-context-protocol
- next.js
- ollama
- paypal
- paypal-mcp
- postman
- pytest
- python
- react
- sqlalchemy
- sqlite
- typescript
- uvicorn
- vitest