π¬ Send prescription PDFs to patients via WhatsApp with Google Gemini and Supabase
β‘ 25 views Β· π¬ Document Extraction & Analysis
Description
Quick overview
This workflow listens for incoming WhatsApp messages from clinic staff, uses Google Gemini to extract prescription details, generates a prescription PDF via an HTML-to-PDF API, uploads it to a public URL, sends the document back over WhatsApp, and logs outcomes to Supabase.
How it works
- Triggers whenever a new WhatsApp message is received on your WhatsApp Business Cloud number.
- Captures configuration values and the incoming message text and sender number.
- Uses Google Gemini to extract patient name, doctor name, and medication details into structured data and flags any missing required fields.
- If required details are missing, replies to staff on WhatsApp with what to fix and inserts a
needs_reviewrecord into Supabase. - If details are complete, renders a prescription HTML document, converts it to a PDF via an external HTML-to-PDF API, and uploads the PDF to an external file-hosting API.
- Sends the prescription PDF to the sender on WhatsApp and inserts a βsentβ log record (including the PDF URL) into Supabase.
Setup
- Connect WhatsApp Business Cloud credentials for the WhatsApp trigger and the WhatsApp send steps, and configure the workflowβs webhook in Meta/WhatsApp so incoming messages reach n8n.
- Add a Google Gemini (PaLM) API credential for the prescription extraction step.
- Add a Supabase credential and create a
prescriptionstable with columns for patient_name, doctor_name, medications (jsonb), status, pdf_url, and created_at. - Provide endpoints and API keys for your HTML-to-PDF service and your upload/file-hosting service, then update the variables in the configuration step (clinic name, staff notification number, and WhatsApp phone number ID).
- Verify which field in your upload API response contains the public file link and update the workflow if it is not returned as
url.
π Nodes Used
HTTP Request, Supabase, WhatsApp Business Cloud, Basic LLM Chain, Structured Output Parser, WhatsApp Trigger
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File