Just-in-Time Adaptive Intervention for genzapp
A technical blueprint and simulation proof of concept for a wellness app that prompts people only when they can actually act.
What I did
- Designed a contextual multi-armed bandit engine using biometric, GPS, and calendar context
- Architected a three-tier on-device pipeline: hard gates, bandit selection, and LLM wording personalization
- Specified an Apache Parquet feature store on Azure Blob Storage with nightly bandit updates and retraining
- Earned Azure Fundamentals (AZ-900) and Azure AI Fundamentals (AI-900) certifications
The problem
Most wellness apps wait to be opened or send reminders on a fixed clock, so a prompt to meditate at 9:00 AM can land in the middle of a lecture. Badly timed prompts teach people to tune the app out, then mute it.
The client wanted the reverse: an app that uses calendar, biometric, and location context to decide if, when, what, and how to prompt, and that learns from each person's responses with as little per-message human review as possible.
Constraints
- Every data source is opt-in, one signal at a time
- Humans curate at the policy and content level, never per message
- It has to work without a wearable
- It has to be safe and lawful for users under 18
- No real user data existed yet, so it had to be testable on simulated data
How it decides
Decisions run on the phone first, and each tier falls back to the one below it, so an older phone with no wearable loses intelligence but not safety.
- Hard gates
- Consent checks, quiet hours, rate caps, and crisis routing. These rules always run, are never AI-controlled, and can veto everything.
- Bandit selection
- A lightweight contextual bandit chooses whether now is a good moment and which approved intervention fits, learning per user from accept and dismiss feedback.
- LLM wording
- On newer phones, an on-device language model personalizes the wording and micro-timing of the chosen intervention using structured output.
- Cloud escalation
- Optional and opt-in. Complex or conflicting cases can go to a hosted model. Most decisions are designed never to leave the device.
Keeping the AI in bounds
The AI can only choose from an approved intervention library, and doing nothing is always a valid choice. Every tier returns the same structured decision, which a validator checks on the device and again on the server.
{
"decision": "intervene | wait",
"intervention_id": "library id or null",
"message": "personalized nudge copy (≤200 chars) or template ref",
"reasoning": "1–3 sentences, user-showable",
"confidence": 0.0-1.0,
"signals_used": ["calendar_gap", "hr_delta", "..."],
"cooldown_advice_min": 45
}
An off-library pick is downgraded to waiting, and any violation degrades safely rather than inventing content. If someone appears to be in acute distress, the AI tiers are bypassed entirely and the app shows human resources through fixed templates.
Proof of concept
Team 822 built a working simulation of the full loop, with simulated signals, consent toggles that strip data before it reaches the model, and a real LLM decision engine.
- Scenarios covered a user with no wearable and a case where the right answer is to wait
- The validator blocked off-library picks and replaced medical language
- Feedback memory visibly deprioritized dismissed categories
- A rule-based fallback took over when the model was unavailable
This was a desktop simulation tested on simulated data, not a shipped feature. The report's phased roadmap covers the path from this proof of concept to the client's native app.
Tools
- Contextual bandits
- Thompson sampling
- Apache Parquet
- Azure Blob Storage
- Apple Foundation Models
- Gemini Nano
- HealthKit
- Health Connect