Inspiration
Most of us have opened a letter from the council, the bank, the hospital or the tax office and thought "what does this actually want from me?" They're written in legal language, the important bit (pay £187.50 by the 9th or lose your instalments) is buried in paragraph four, and getting it wrong costs money. It's even harder if English isn't your first language, or you're older, or you're just tired.
AI is very good at explaining these letters. The problem is what's in them: your full name, home address, account numbers, NI number, phone number, sometimes medical details. Pasting all of that into a chatbot isn't something people should have to do to understand their own post.
So we wanted the explanation without the giveaway. That's exactly what hybrid inference is for.
What it does
Paste a letter (or try one of the examples) and PlainPost gives you:
- What it is and how urgent it is. A one-line summary and an "Act soon / Needs attention / No rush" label.
- What you need to do, and by when. A checklist with deadlines. One click adds them to your calendar with a reminder two days before.
- Every amount of money mentioned, and what each one is for.
- The jargon explained ("Liability Order", "Notice to Owner", "Discharged").
- What happens if you do nothing, and where to get help.
- A polite reply drafted for you. Choose your situation ("I need more time", "I think this is a mistake"…) and it writes the letter. Anything only you know is left as a blank like
[date you paid], never made up. - 12 languages. English, Spanish, Japanese, Polish, Romanian, Urdu, Bengali, Punjabi, Arabic, Portuguese, French and Ukrainian.
Every answer has a badge saying where it was produced: "Stayed on your device", or "Explained in the cloud, anonymised" with a "See exactly what was sent" panel. That panel shows the letter as the cloud saw it, with [NAME_1], [ADDRESS_1], [REF_1] where your details were.
How we built it
Everything AI goes through Firebase AI Logic (firebase/ai), with the routing designed around privacy rather than speed:
- On device first. If Chrome's built-in Gemini Nano is available, can write in the chosen language and the letter fits, the letter is explained with
InferenceMode.ONLY_ON_DEVICEand a JSONresponseConstraint. We use ONLY_ON_DEVICE rather than PREFER_ON_DEVICE on purpose: with PREFER, a hiccup on the device would quietly send the raw letter to the cloud, which is the one thing we promise won't happen. - The privacy airlock. If the device can't help (no Nano, a long letter, or a language Nano can't write yet), PlainPost redacts the letter on the device before anything is sent. Names, addresses, postcodes, emails, phone numbers, NI numbers, sort codes, account and reference numbers become placeholders. Dates and amounts are kept, because those are what you need explained. When Gemini Nano is available it also helps the airlock by listing names the patterns can't know about (a second on-device call).
- Cloud, anonymised. Only the redacted text goes to Gemini in the cloud with
InferenceMode.ONLY_IN_CLOUDandresponseJsonSchema, so the answer always has the same structured shape. Busy-server errors are retried with backoff, and fall back to a second model. - Restore locally. The placeholders in the answer are swapped back for your real details in the browser. So "call [PHONE_1]" comes back as the council's real number, and the drafted reply has your real name, even though the cloud never saw either.
- "Allow cloud help" is a real switch. Turn it off and PlainPost will only ever use the device. If the device can't help, it tells you so instead of sending anything.
- Requests that contain no personal data use
InferenceMode.PREFER_ON_DEVICEand let Firebase choose. - The badge reads
response.inferenceSource, so it reports where the model actually ran rather than where we hoped it would.
App Check with reCAPTCHA Enterprise protects every Gemini call, and the app is on Firebase Hosting. The front end is plain TypeScript and Vite with no framework, so it loads fast on old phones. The airlock, the routing rules, the output schema and the calendar export are covered by 25 unit tests.
Challenges we ran into
- Redaction without wrecking the letter. Early versions treated a sort code (20-45-77) as a date, gave "Mrs Priya Sharma" and "Dear Priya Sharma" two different placeholders, and matched patterns across line breaks. We fixed each one and added a test for it. Keeping titles outside the placeholder ("Mrs [NAME_1]") helped the cloud model write natural replies.
- Choosing ONLY_ON_DEVICE over PREFER_ON_DEVICE. The easy option would have quietly broken our privacy promise, so the routing is explicit and every route explains why it was chosen.
- Models inventing facts. An early reply draft said the person "paid on 30 September", which the letter never said. The prompt now forbids invented facts and asks for blanks instead.
- Busy cloud models. We hit "high demand" 500 errors during testing, so cloud calls now retry with backoff and then fall back to a second model.
Accomplishments that we're proud of
- The privacy story is something you can see, not just read about: the "See exactly what was sent" panel shows the exact anonymised text.
- Placeholders round-trip cleanly, so anonymising doesn't make the help worse.
- It's a finished product, not a demo: calendar export, reply drafting, 12 languages, a phone layout and an honest "I can't help without the cloud" state.
What we learned
Hybrid inference changes what is worth building. The on-device model isn't just a faster or cheaper option; it lets an app make a privacy promise that a cloud-only app can't. Splitting the work so the device handles everything personal (explaining, spotting names, redacting, restoring) and the cloud only does language work on anonymised text is a pattern that would suit health, legal and money apps too.
What's next for PlainPost
- Photo a letter. On-device text recognition, so you can point your phone at the letter instead of pasting text.
- An Android version with Gemini Nano through Firebase AI Logic.
- More redaction patterns for other countries (SSNs, IBANs, NHS numbers) and more on-device languages as Gemini Nano adds them.
- Partnering with advice charities, so the "where to get help" section can point to local services.
Built With
- chrome-prompt-api
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- gemini
- gemini-nano
- recaptcha-enterprise
- typescript
- vite