Inbox Triage System
Stop manually sorting clinic emails. This script auto-classifies incoming emails into categories (referrals, prescriptions, bookings, lab results, billing, patient questions), applies Gmail labels, and drafts reply templates.
The problem
The average clinic inbox receives 50–150 emails per day. Staff spend 1–2 hours just sorting and routing messages. Urgent referrals get buried under billing inquiries. Patients wait longer for responses.
How it works
- 1Runs automatically every 5 minutes via a timed trigger
- 2Scans unread emails and classifies by keyword matching
- 3Applies Gmail labels (Clinic/Referrals, Clinic/Bookings, etc.)
- 4Drafts reply templates for common categories
- 5Sends an optional daily digest to the clinic manager
What you need
- ✓A Google Workspace account (Gmail)
- ✓Access to Google Apps Script (Extensions menu in Google Sheets)
- ✓5 minutes for setup
Download
Setup guide
Create a new Google Sheet
Open Google Sheets and create a blank spreadsheet. Name it 'Clinic Inbox Triage'. This sheet will be the host for the script (you don't need to put any data in it).
Open Apps Script
Go to Extensions → Apps Script. This opens the script editor. Delete any existing code in the editor.
Paste the script
Copy the full script below and paste it into the Apps Script editor. Then click the floppy disk icon (or Ctrl+S) to save.
Customise your categories
Edit the CATEGORIES object near the top of the script. Add or remove keywords for each category to match your clinic’s email patterns. For example, add your specialist names to the referral keywords.
Set your notification email (optional)
Find the CONFIG object at the top and set NOTIFY_EMAIL to your clinic manager’s email address. Leave it blank to skip the daily digest.
Run the setup
In the Apps Script editor, select 'setupInboxTriage' from the function dropdown (top bar), then click Run. You’ll be asked to authorise the script — click through the permissions. This creates all Gmail labels and sets up the automatic trigger.
Verify it’s working
Wait 5 minutes, then check your Gmail sidebar. You should see new labels under 'Clinic/'. Send yourself a test email with the word 'referral' in the subject to confirm it gets labelled.
Full code
/**
* TOSC Inbox Triage System
* Auto-labels, routes, and drafts replies for clinic emails.
*
* SETUP:
* 1. Open Google Sheets → Extensions → Apps Script
* 2. Paste this code and save
* 3. Run setupInboxTriage() once to create labels and triggers
* 4. Customise CATEGORIES below for your clinic
*/
// ── Configuration ──────────────────────────────────────────────
const CONFIG = {
CHECK_INTERVAL_MINUTES: 5,
PROCESSED_LABEL: "Triaged",
NOTIFY_EMAIL: "", // set to clinic manager email for daily digest
};
const CATEGORIES = {
referral: {
keywords: ["referral", "refer to", "sp
// ... Enter your email above to see the full codeNeed help setting this up?
Book a free 30-minute call. We'll walk through the setup together and customise it for your clinic.
Book a Setup Call