{
  "name": "Send WhatsApp medication reminders and caregiver alerts with WATI and Google Sheets",
  "nodes": [
    {
      "id": "3527dde7-199d-40e0-a68c-f424177655db",
      "name": "📋 Flow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        0
      ],
      "parameters": {
        "width": 640,
        "height": 494,
        "content": "## 💊 WhatsApp Medication Reminder Bot with Dosage Tracking\n\n**How it works:**\n1. Schedule Trigger runs 3x daily (morning, afternoon, night) and sends medication reminders to all active patients\n2. Pat"
      }
    },
    {
      "id": "03b70fab-0e5c-4e8d-b85b-04676595348c",
      "name": "Sticky – Scheduled Reminders",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2512,
        1312
      ],
      "parameters": {
        "width": 1456,
        "height": 338,
        "content": "### 1️⃣ Scheduled Reminder Dispatch\n**Schedule Trigger** fires 3x daily: 8AM, 1PM, 8PM.\n**Sheets – Read Medications** fetches all active medication records.\n**Filter by Time Slot Code** keeps only med"
      }
    },
    {
      "id": "c532ecf6-0291-44f9-b9b0-a77b205418ff",
      "name": "Sticky – Inbound Routing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        1184
      ],
      "parameters": {
        "width": 880,
        "height": 770,
        "content": "### 2️⃣ Inbound Reply Routing\n**WATI Trigger** receives patient replies.\n**Route Message Switch** detects keyword:\n- `taken` → log dose taken ✅\n- `skip` → log dose skipped ⚠️\n- `snooze` → schedule a 3"
      }
    },
    {
      "id": "9cc5de58-5424-440d-bde2-17b4455a3e7e",
      "name": "Sticky – Taken & Skip",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        592
      ],
      "parameters": {
        "width": 1052,
        "height": 456,
        "content": "### 3️⃣ Dose Logging — Taken & Skip\n**Taken Flow:** Logs dose as Taken in AdherenceLog sheet with timestamp. Sends positive reinforcement message. Updates streak counter.\n**Skip Flow:** Logs dose as S"
      }
    },
    {
      "id": "facc287f-8f74-4864-9773-86a300c827b2",
      "name": "Sticky – Snooze & Missed Alert",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        1072
      ],
      "parameters": {
        "width": 1052,
        "height": 584,
        "content": "### 4️⃣ Snooze & Missed Dose Alert\n**Snooze Flow:** Logs snooze request with a follow-up timestamp. A second Schedule Trigger (every 30 min) checks for pending snoozes and re-sends reminders.\n**Missed"
      }
    },
    {
      "id": "bc02854c-cd3c-4ea7-9ed7-6779edc23c8f",
      "name": "Sticky – Reports",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        1696
      ],
      "parameters": {
        "width": 1036,
        "height": 760,
        "content": "### 5️⃣ Reports & Stats\n**My Stats:** Reads AdherenceLog for this patient's phone, calculates 7-day adherence %, streak, best/worst day and sends a visual report.\n**My Meds:** Shows today's full medic"
      }
    },
    {
      "id": "a51374ef-5515-4379-9a8a-f295007f8883",
      "name": "Schedule Trigger – 8AM 1PM 8PM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2592,
        1472
      ]
    },
    {
      "id": "97d52ce9-2530-4477-8830-3f4c3058d990",
      "name": "Google Sheets – Read Medications",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2832,
        1472
      ]
    },
    {
      "id": "36903a3a-8b63-44a4-9c84-a7c093efb05a",
      "name": "Filter Medications by Time Slot",
      "type": "n8n-nodes-base.code",
      "position": [
        3072,
        1472
      ]
    },
    {
      "id": "06817ea7-55d0-41ba-b619-813eaa12fdc2",
      "name": "Build Medication Reminder",
      "type": "n8n-nodes-base.code",
      "position": [
        3312,
        1472
      ]
    },
    {
      "id": "52c8e202-57b7-459a-9bac-97703e11d89b",
      "name": "Google Sheets – Log Reminder Sent",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3552,
        1472
      ]
    },
    {
      "id": "8efb5ffd-6859-48da-adc0-cef89cfcaf07",
      "name": "Route Message",
      "type": "n8n-nodes-base.switch",
      "position": [
        336,
        1456
      ]
    },
    {
      "id": "d3513e9b-8943-423f-8e7e-e6acce415e18",
      "name": "Google Sheets – Read Log (Taken)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1424,
        704
      ]
    },
    {
      "id": "159c0619-095a-47df-881c-6225d32b55d2",
      "name": "Process Taken",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        704
      ]
    },
    {
      "id": "ce837757-ed51-43ec-804a-536288661a96",
      "name": "Google Sheets – Update Taken",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1920,
        704
      ]
    },
    {
      "id": "4196c4a3-032e-41b8-9378-46142d7ea711",
      "name": "Google Sheets – Read Log (Skip)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1424,
        880
      ]
    },
    {
      "id": "2a2bd2d7-421b-4a78-aaa4-380416f9571b",
      "name": "Process Skip",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        880
      ]
    },
    {
      "id": "c79c62f4-38be-4cf9-964a-b3cc46d1b0a3",
      "name": "Google Sheets – Update Skipped",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1920,
        880
      ]
    },
    {
      "id": "7426d957-e5ad-4f49-8a62-8f8a0d237740",
      "name": "Process Snooze",
      "type": "n8n-nodes-base.code",
      "position": [
        1440,
        1200
      ]
    },
    {
      "id": "c048e9e0-6e80-4a2d-ac9b-6f21caa484e4",
      "name": "Google Sheets – Log Snooze",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1824,
        1200
      ]
    },
    {
      "id": "3980b984-eecf-405b-82a1-04ff9bd4cca0",
      "name": "Schedule Trigger – Every 30 Min",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1440,
        1328
      ]
    },
    {
      "id": "f2bbcd28-3930-44b3-a776-b8703ab598a8",
      "name": "Google Sheets – Read Snooze Queue",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1664,
        1328
      ]
    },
    {
      "id": "5bb3d95b-41ff-43e8-ab61-e6a78ce8fcbd",
      "name": "Check Snooze Queue",
      "type": "n8n-nodes-base.code",
      "position": [
        1936,
        1328
      ]
    },
    {
      "id": "4d942933-3d56-4f07-b32b-fe7a0fd1d8bc",
      "name": "Schedule Trigger – Every 1 Hour",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1456,
        1488
      ]
    },
    {
      "id": "21749e76-c828-4c3c-9c56-4ea5888fee31",
      "name": "Google Sheets – Read Log (Missed Check)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1696,
        1488
      ]
    },
    {
      "id": "20aaac89-0f54-4d6a-a99f-95ea10627376",
      "name": "Detect Missed Doses",
      "type": "n8n-nodes-base.code",
      "position": [
        1936,
        1488
      ]
    },
    {
      "id": "f64cea68-3edf-46bb-b220-4808627a2286",
      "name": "Google Sheets – Read Log (Stats)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1488,
        1904
      ]
    },
    {
      "id": "59897745-4615-4578-8402-87ccd0b23609",
      "name": "Build My Stats",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        1904
      ]
    },
    {
      "id": "293849b3-4226-4f7b-9eb4-25f47689209d",
      "name": "Google Sheets – Read My Meds",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1488,
        2080
      ]
    },
    {
      "id": "6ab026e7-4305-47ad-aa40-6a2afaac2905",
      "name": "Build My Meds Schedule",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        2080
      ]
    },
    {
      "id": "eccbd185-7ba8-49df-aeba-ca654e375606",
      "name": "Google Sheets – Read Log (Caregiver)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1488,
        2240
      ]
    },
    {
      "id": "52f2e40d-c1c9-4f7b-97af-182b0271d0ee",
      "name": "Build Caregiver Report",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        2240
      ]
    },
    {
      "id": "f03f68e3-a5b4-4f3e-aa07-408a2df7e6b1",
      "name": "Send a text message",
      "type": "n8n-nodes-wati.wati",
      "position": [
        3776,
        1472
      ]
    },
    {
      "id": "509e2d6b-3205-4d08-969c-0b840ddd0eae",
      "name": "Wati Trigger",
      "type": "n8n-nodes-wati.watiTrigger",
      "position": [
        96,
        1536
      ]
    },
    {
      "id": "fe701382-9087-4e7a-85a5-6d5acf534f1a",
      "name": "Send a text message1",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2160,
        704
      ]
    },
    {
      "id": "be7b476e-74f8-4de5-80fb-787e126b52ac",
      "name": "Send a text message2",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2160,
        880
      ]
    },
    {
      "id": "25d4311c-b26d-4dff-b8d9-0d4c781bf224",
      "name": "Send a text message3",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2096,
        1200
      ]
    },
    {
      "id": "8f28a3c3-9446-4fed-a69d-effe23c84a71",
      "name": "Send a text message4",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2000,
        1904
      ]
    },
    {
      "id": "682c2e3a-49b2-4bc7-a856-c3e8f60f107f",
      "name": "Send a text message5",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2000,
        2080
      ]
    },
    {
      "id": "0b95e745-e435-4a5f-883b-7346a20178e5",
      "name": "Send a text message6",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2000,
        2240
      ]
    },
    {
      "id": "34393446-073c-48bb-8b02-9dad32feb24f",
      "name": "Send a text message7",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2240,
        1328
      ]
    },
    {
      "id": "5fc474db-2fd0-4e8a-8b47-609c2cbea911",
      "name": "Send a text message8",
      "type": "n8n-nodes-wati.wati",
      "position": [
        2144,
        1488
      ]
    }
  ],
  "connections": {
    "Process Skip": {
      "main": [
        [
          {
            "node": "Google Sheets – Update Skipped",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wati Trigger": {
      "main": [
        [
          {
            "node": "Route Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Taken": {
      "main": [
        [
          {
            "node": "Google Sheets – Update Taken",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Message": {
      "main": [
        [
          {
            "node": "Google Sheets – Read Log (Taken)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets – Read Log (Skip)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Snooze",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets – Read Log (Stats)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets – Read My Meds",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets – Read Log (Caregiver)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build My Stats": {
      "main": [
        [
          {
            "node": "Send a text message4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Snooze": {
      "main": [
        [
          {
            "node": "Google Sheets – Log Snooze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Snooze Queue": {
      "main": [
        [
          {
            "node": "Send a text message7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Missed Doses": {
      "main": [
        [
          {
            "node": "Send a text message8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Caregiver Report": {
      "main": [
        [
          {
            "node": "Send a text message6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build My Meds Schedule": {
      "main": [
        [
          {
            "node": "Send a text message5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Medication Reminder": {
      "main": [
        [
          {
            "node": "Google Sheets – Log Reminder Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Log Snooze": {
      "main": [
        [
          {
            "node": "Send a text message3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read My Meds": {
      "main": [
        [
          {
            "node": "Build My Meds Schedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Update Taken": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Medications by Time Slot": {
      "main": [
        [
          {
            "node": "Build Medication Reminder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Update Skipped": {
      "main": [
        [
          {
            "node": "Send a text message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger – 8AM 1PM 8PM": {
      "main": [
        [
          {
            "node": "Google Sheets – Read Medications",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Log (Skip)": {
      "main": [
        [
          {
            "node": "Process Skip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger – Every 1 Hour": {
      "main": [
        [
          {
            "node": "Google Sheets – Read Log (Missed Check)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger – Every 30 Min": {
      "main": [
        [
          {
            "node": "Google Sheets – Read Snooze Queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Log (Stats)": {
      "main": [
        [
          {
            "node": "Build My Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Log (Taken)": {
      "main": [
        [
          {
            "node": "Process Taken",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Medications": {
      "main": [
        [
          {
            "node": "Filter Medications by Time Slot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Log Reminder Sent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Snooze Queue": {
      "main": [
        [
          {
            "node": "Check Snooze Queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Log (Caregiver)": {
      "main": [
        [
          {
            "node": "Build Caregiver Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets – Read Log (Missed Check)": {
      "main": [
        [
          {
            "node": "Detect Missed Doses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}