Duewise: AI-Powered Invoice Follow-Up
Inspiration
Small businesses lose time chasing late payments. Writing invoices, tracking whether they’ve been paid, and awkwardly nudging customers all take time away from the actual work. Duewise puts an AI agent on the entire process, while ensuring the owner approves every outgoing action.
What It Does
Duewise supports the PayPal invoice lifecycle:
- Draft an invoice from a message. Paste a request such as, “Bill Maria Lopez for 3 hours of logo design at $60/hr, due in two weeks.” Gemini extracts the customer, email, line items, and due date into a structured draft. Missing details are left blank rather than invented.
- Review and approve. The owner checks the draft. Invoices without an email address or with a zero price are blocked.
- Create and send. PayPal creates and sends the invoice through the Invoicing API.
- Track invoice events. Signature-verified PayPal webhooks stream events—created, sent, and paid—into the app in real time.
- Assess late-payment risk. Open invoices receive a risk score with plain-English reasons, such as “overdue by 7 days” or “little or no payment history with this customer.”
- Draft and approve reminders. For overdue invoices, Gemini drafts a reminder with a tone suited to how late the payment is: friendly, firm, or urgent. The owner approves it before it’s sent through PayPal’s invoice reminder feature.
How We Built It
- Backend: FastAPI
- Frontend: Plain JavaScript with AG Grid
- AI drafting: Gemini returns structured JSON, validated with Pydantic. Models automatically fall back when one is overloaded.
- Payments: PayPal OAuth and Invoicing v2 for creating, sending, listing, and reminding
- Invoice updates: PayPal webhooks, hosted on Render
- Risk scoring: scikit-learn logistic regression, with feature contributions used to explain scores
- Overdue tracking: Calculated in the app because PayPal has no overdue event
- Demo: A demo clock lets us fast-forward time to show overdue behavior
Guardrails
- Nothing is sent without human approval.
- Amounts and email addresses are validated.
- Webhook signatures are verified through PayPal’s API.
- Requests are rate limited per visitor.
Challenges We Ran Into
- PayPal’s invoice creation call returned a 403 error until we stopped including an
invoicerobject in the request body. - Webhook events can arrive out of order, so the invoice table reads status directly from PayPal.
- Gemini capacity errors led us to add model fallback.
Accomplishments We’re Proud Of
The full loop works end to end on a hosted URL: message, AI-generated draft, approval, PayPal invoice, verified webhook, payment, overdue status, reminder draft, and a reminder sent through PayPal.
Honest Limits
- Sandbox only
- The risk model is trained on synthetic data and is a demonstration—not a credit-scoring tool
What’s Next for Duewise
- Train the risk model on a business’s real payment history
- Support multiple merchants
- Add payment-plan suggestions for high-risk invoices
Built With
- ag-grid
- fastapi
- google-gemini-api
- httpx
- javascript
- paypal-invoicing-api
- paypal-webhooks
- pydantic
- python
- render
- scikit-learn