Inspiration
In the Dominican Republic, a large part of small business runs on credit. The hardware store gives cement to the builder, the distributor supplies the corner store, the workshop repairs the truck, and everyone promises to pay "el viernes".
Owners like Rafael, who runs a building-materials store in Santiago, end up with hundreds of thousands of pesos owed to them, and more than half of it overdue. Some customers promised to pay three Fridays ago. Some stopped answering. One sent a transfer screenshot that nobody checked. The owner is busy running the store, so the money just sits there.
These businesses don't need another accounting system. They need someone whose only job is collecting: deciding who to contact today, writing the message, understanding the answer, and checking the "proof". That is CobroFlow.
Debt is personal, though. Names, phone numbers, ID numbers (cédulas) and bank details should not go to a cloud model by default. Hybrid AI makes the product possible: Gemini Nano on the device first, and the cloud only when it helps, without the customers' names.
Demo video (3:00): https://www.youtube.com/watch?v=AFAGBNB6u6Y Web / Chrome app: https://petiht.com/cobroflow/app.html (no sign-up: anonymous account, one click loads invented demo data) Landing page: https://petiht.com/cobroflow/ Android APK: https://petiht.com/cobroflow/download/cobroflow.apk
What it does
- Imports the records the business already has: an Excel/CSV export (read on the device), or a photo of the handwritten credit notebook. Rules remove the TOTAL line and check that the rows add up.
- Collect today: ranks every account from 0 to 100. Disputes are cleared up, not chased. Customers who opted out get a call, never a message. No reminders at night.
- Respectful WhatsApp drafts in Spanish. A local check confirms the exact balance, blocks threats and adds an opt-out line. The owner approves before WhatsApp opens.
- Understands replies: "Estoy esperando que me paguen mañana. El viernes te transfiero." becomes a promise to pay on Friday, December 4. The date is computed by rules, never guessed by the model.
- Checks payment screenshots: reused reference, wrong payee, "in progress" transfers, future dates, photo-editor traces. Money is never marked as received until the owner sees it in the bank.
- Hybrid Intelligence Inspector: for every AI call, it shows where it ran, which model, the time taken, the bytes sent, how many personal details were hidden, and the exact text sent to the cloud.
How we built it
The hybrid routing is the product. Each task runs where it runs best:
| Task | Gemini Nano (device) | Gemini (cloud) | Local rules |
|---|---|---|---|
| Ledger photo, receipt | first read | second read only with consent, image re-encoded without EXIF/GPS | sums, reused references, payee, dates |
| Customer reply | first read | if unsure, long, or disagreeing with the rules, after redaction | intent cross-check, payment date |
| Reminder | simple cases | disputes and broken promises, on anonymized facts | exact amount, no threats, opt-out, quiet hours |
Redaction: before any text leaves the device, names, phones, cédulas, e-mails and account numbers become [CLIENTE], [NEGOCIO], [TEL], [CEDULA] and [CUENTA]. The real values are put back on the device.
Priority: every account gets a score that a person can read and check:
$$ S = 35\sqrt{\frac{b}{b_{\max}}} + 30\,\frac{\min(d,\,90)}{90} + 15\,[\text{promise missed}] + 7\min(k,\,2) + 18\,[\text{promise due today}] + 10\,[\text{no answer}] + 4\,[\text{partial}] $$
Here $b$ is the balance, $b_{\max}$ is the largest open balance, $d$ is the number of days overdue and $k$ is the number of promises broken before. The score is capped at 100. Disputes are routed to "resolve", and an open promise means "wait".
Firebase:
- Firebase AI Logic with hybrid inference. One model definition carries both engines (
onDeviceParams/OnDeviceConfigandinCloudParams), with the same JSON schema.inferenceSourcefeeds the Inspector. On the web this uses the Chrome Prompt API; on Android, AICore throughfirebase-ai-ondevice. - App Check, enforced: reCAPTCHA Enterprise on the web, Play Integrity on Android.
- Remote Config: cloud models, an on/off switch for on-device AI, cloud photos on or off, the confidence threshold, quiet hours and the waiting days between reminders.
- Authentication and Cloud Firestore, with owner-only, shape-checked rules and an offline cache.
Stack: vanilla JavaScript with esbuild for the web, Kotlin with Jetpack Compose for Android. The same rules engine exists in both, with 14 Node tests and 7 JVM tests.
Challenges we ran into
- Small models and dates. On the real reply "…que me paguen mañana. El viernes te transfiero.", Gemini Nano pointed at "mañana" (when Pedro gets paid) instead of "el viernes" (when he will pay). We fixed it properly: rules read the whole message first, and the model's phrase is only a fallback. No number or date comes from the model.
- Spanish on Android. Gemini Nano on Android is validated for English, so Spanish reminders on the phone are written by the cloud model on anonymized facts, or by a safe local template in Private mode. The Inspector says so.
- Busy models. The larger cloud model sometimes answered "high demand". Complex drafts now get 20 s, then retry on the lighter model, then fall back to a guarded template.
- No Nano on our test phone (AICore reports "feature not available"). The Android demo shows the cloud path honestly; the on-device path was measured in Chrome on a laptop.
Accomplishments that we're proud of
Measured on real runs:
- Gemini Nano in Chrome on a CPU-only laptop understood a customer reply on the device: 33.3 s for the first call, 13.7 s once the model was loaded, 0 bytes sent.
- A cloud WhatsApp draft took about 1.4 s, with 2 personal details hidden and the exact amount verified.
- The ledger photo was read 6/6 rows, and the RD$73,550 sum matched the handwritten total.
- A reused reference and a wrong payee were both flagged Suspicious, and a correct transfer matched invoice F-2055.
What we learned
Small on-device models are excellent readers and poor accountants. The winning pattern is:
- Gemini Nano reads language on the device.
- The cloud helps only when it adds value, and never with personal data.
- Plain code owns every number, date and verdict.
Showing the routing in the Inspector also made the privacy promise visible, not just claimed.
What's next
- Paid 7-day pilots with distributors and hardware stores in Santo Domingo and Santiago.
- WhatsApp Business API with explicit customer consent.
- Firebase Cloud Messaging alerts for promises due today.
- Multi-user businesses (owner + collector) with roles.
