Skip to content

Repository files navigation

Alivia

A lab report goes in; a doctor-approved health plan comes out.

Alivia is three n8n workflows that turn a patient's lab report into a personalized supplement, diet, and lifestyle plan, and route every report through a licensed doctor before it reaches the patient.

Table of contents

What this does

A patient submits a lab report through an intake form. A ten-stage AI chain reads it, finds patterns across markers, and drafts supplements, diet changes, and lifestyle actions. A reviewing doctor approves, revises, or escalates the draft from a link in their email. No report reaches the patient without that approval. A third, scheduled workflow delivers approved reports and reminds a doctor who has left a review sitting too long.

  • Reads a lab report and drafts a full plan. workflow-1-intake-to-pipeline.json runs the report through ten Claude API calls: extraction, interpretation, pattern detection, supplements, diet, lifestyle, challenge review, consolidation and safety, top actions, and a final report with a clinical-editor pass.
  • Blocks every report behind a real doctor. workflow-2-doctor-review-loop.json serves the doctor's review page, applies their feedback through an AI arbiter, and escalates to an internal team after 5 revision rounds instead of looping forever.
  • Delivers and follows up on its own schedule. workflow-3-send-reports-and-reminders.json runs every 15 minutes, sends approved reports, and reminds a doctor about a stalled review.
  • Needs: a running n8n instance, an Anthropic API key, and a Google account for Sheets, Drive, and Gmail. See Required credentials.
  • Does not: store any credential in these files. n8n keeps every credential in its own store, separate from the workflow JSON, and this repository does not include a Google Sheets template; see Configuration for the columns a tracking sheet needs.
n8n → Workflows → Import from File → workflow-1-intake-to-pipeline.json

Key numbers

Metric Value
Workflows 3
Total nodes 80 (37 + 34 + 9)
AI analysis stages in Workflow 1 10, of which 4 run in parallel
Revision rounds before escalation 5
Workflow 3 schedule every 15 minutes
External services used Anthropic API, Gmail, Google Sheets, Google Drive

Counted directly from the three workflow JSON files.

Architecture

flowchart TD
    A["Workflow 1: Intake\nPatient submits lab report"] --> B["10-stage AI analysis chain\n(4 stages run in parallel)"]
    B --> C["Session logged, documents filed\nDoctor review email sent"]
    C --> D["Workflow 2: Doctor Review\nApprove / Revise / Escalate"]
    D -->|approved| E["Workflow 3: Send and Follow-Up\nRuns every 15 minutes"]
    E --> F["Report delivered to patient"]
Loading

A shared Google Sheet is the system's record of where every session stands: Workflow 1 creates the row, Workflow 2 updates it on every review action, Workflow 3 reads and updates it again.

Workflow 1: Intake to Pipeline

File: workflow-1-intake-to-pipeline.json · 37 nodes

The intake form starts a ten-stage AI chain:

# Stage What it does
1 Extraction Pulls every marker and value out of the raw lab report
2 Interpretation Scores each marker against standard and functional/optimal ranges
3 Pattern Detection Looks across markers together for patterns a single value would miss
4 Supplements Generates dosed supplement recommendations tied to the patterns found
5 Diet Produces diet additions and reductions from the same patterns
6 Lifestyle Recommends lifestyle changes, ranked by effort and expected impact
7 Challenge Review Stress-tests each pattern and flags weak or alternate explanations
8 Consolidation & Safety Merges supplements, diet, lifestyle, and the challenge review into one plan, checking medication interactions and contraindications
9 Top Actions Ranks the handful of actions that matter most, out of everything generated
10 Final Report + Clinical Editor Pass Writes the patient-facing narrative, then tightens the language

Stages 4 through 7 (Supplements, Diet, Lifestyle, and Challenge Review) run in parallel from the same Pattern Detection output and are joined by a Merge node before Consolidation & Safety.

After the report is drafted, the workflow sends the patient an acknowledgement email, creates a session folder in Google Drive and uploads the source documents, appends a row to the tracking sheet, and emails the reviewing doctor a link to approve or revise the draft.

Workflow 2: Doctor Review Loop

File: workflow-2-doctor-review-loop.json · 34 nodes

This workflow serves the page a doctor opens from their email link and handles everything from there:

Path What happens
Link opened The link's session ID and round number are checked against the tracking sheet; a stale or already-resolved link shows an error page instead of the form
Approve The session is marked approved and an audit log row is appended
Revise The doctor's written feedback goes to an AI arbiter, which either applies the change to the original report or, for a safety-relevant objection, returns a rebuttal without changing the report
Round cap After 5 completed revision rounds the session is escalated to an internal team by email instead of generating another round
Every action Approvals, revisions, and escalations are each appended to an audit-log sheet with a timestamp

Workflow 3: Send Approved Reports and Reminders

File: workflow-3-send-reports-and-reminders.json · 9 nodes

A schedule trigger runs this workflow every 15 minutes. Each run:

  • Reads every row in the tracking sheet, finds sessions marked approved but not yet sent, emails the final report to the patient, and marks the row as sent.
  • Finds reviews that have sat with a doctor too long without action and sends that doctor a reminder email.

Installation

  1. Start an n8n instance: self-hosted or n8n Cloud.
  2. In n8n, go to Workflows → Import from File and import each of the three JSON files in this repository.
  3. Create the credentials listed in Required credentials and attach each one to the matching nodes in all three workflows.
  4. Create a Google Sheet with the columns listed in Configuration and point every Google Sheets node at it.
  5. Activate all three workflows. Workflow 1 and Workflow 2 start from a form submission; Workflow 3 starts on its own 15-minute schedule.

Not run while writing this README: importing into n8n and completing a full session needs a live n8n instance, a paid Anthropic API key, and a Google account, none of which this review had access to.

Configuration

No values are stored in the workflow files; every setting below is a column your own tracking sheet needs; n8n keeps the credential values themselves in its own credential store, never in these JSON files.

Column Written by Read by
session_id Workflow 1 Workflow 2, Workflow 3
customer_id_phone, name, email, age, biological_sex Workflow 1 Workflow 2 (shown on the review page)
current_medications, primary_complaint, diagnosed_conditions, diet_type, regional_food_preference, sleep_quality, physical_activity_days, stress_level Workflow 1 Workflow 1's own AI stages
drive_folder_link, document_count Workflow 1 none
html_output, original_html_output, clinical_data_json Workflow 1 Workflow 2 (arbiter revisions work from these)
edit_history_json Workflow 1, updated by Workflow 2 Workflow 2's arbiter
review_status, review_round Workflow 1, updated by Workflow 2 Workflow 2, Workflow 3
doctor_email, doctor_feedback_latest, ai_backing_latest, doctor_approved_at Workflow 2 Workflow 2, Workflow 3
last_action_at, last_reminder_at Workflow 2, Workflow 3 Workflow 3 (decides who gets a reminder)
email_sent, final_email_sent_at Workflow 3 Workflow 3

Required credentials

Credential Type Used by
Anthropic API Header Auth (calls api.anthropic.com/v1/messages) Every AI analysis and arbiter node in Workflow 1 and Workflow 2
Gmail OAuth2 Patient acknowledgements, doctor review requests, final reports, reminders, and escalation alerts
Google Sheets OAuth2 Session tracking and the audit log
Google Drive OAuth2 Storing uploaded lab reports and session documents

Safety design

  • No report reaches a patient without a doctor's approval; the AI pipeline drafts, the doctor decides.
  • Every recommendation is checked against medication interactions and contraindications during Consolidation & Safety, before it can reach the final report.
  • The arbiter refuses to auto-apply a doctor's feedback that touches a flagged critical marker, a medication caution, or a referral note; it returns a rebuttal instead and leaves the report unchanged.
  • Revisions stop at 5 rounds; a case that is not resolved by then is escalated to an internal team by email rather than looping.
  • Every approval, revision, and escalation is appended to an audit-log sheet with a timestamp.

Troubleshooting

Symptom Likely cause Fix
Doctor's review link shows a "stale link" page The link's round number no longer matches review_round on the tracking sheet row, usually because the session already moved to the next round Ask the doctor to open the latest email for that session instead of an older one
Workflow 1 fails partway through the AI chain An Anthropic API call returned an error or an unexpected response shape Check the Anthropic credential and rate limits; the code nodes before each httpRequest node build the exact request sent
Reports never get marked as sent Workflow 3 is inactive, or its schedule trigger was edited after import Confirm Workflow 3 is activated and its trigger still reads every 15 minutes
Doctor never receives a reminder last_action_at on the row was updated more recently than expected Check what last wrote to last_action_at for that session; Workflow 2 updates it on every doctor action

Limits and non-goals

  • No structured lab-value database: extraction works from free text in the uploaded report, not a fixed schema of known markers.
  • No patient-facing status page: a patient sees only the acknowledgement email and the final report, nothing in between.
  • No support for comparing a new report against a patient's prior one.
  • No credential storage or Google Sheet template ships in this repository; both are set up by whoever installs the workflows.

Status and roadmap

Working, checked against the repository on 2026-09-27. Planned next: a structured lab-value database in place of free-text extraction, a patient-facing status dashboard, and support for comparing a report against a patient's prior results.

License

No license yet.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors