{"workflow":{"id":13702,"name":"Send WhatsApp medication reminders and caregiver alerts with WATI and Google Sheets","views":23,"recentViews":0,"totalViews":23,"createdAt":"2026-02-25T11:36:17.528Z","description":"# 💊 WhatsApp Medication Adherence & Caregiver Alert Automation\n\nEnsure health and safety with a fully automated medication adherence system. This workflow manages the entire patient care cycle—from scheduled dosage reminders to interactive logging and automated caregiver escalations—all through WhatsApp using WATI and Google Sheets.\n\n---\n\n## 🎯 What This Workflow Does\n\nTurns WhatsApp into a proactive health assistant and caregiver's dashboard:\n\n- 📝 **Timed Dosage Reminders**  \n  A scheduled trigger fires 3x daily (Morning, Afternoon, Night) to identify which medications are due and send personalized WhatsApp alerts.\n\n- 🚦 **Smart Patient Routing**  \n  A Switch node detects patient replies to manage their health data in real-time:\n  - **taken:** Logs the dose as complete and updates the patient's \"Streak\".\n  - **skip:** Records the skipped dose and empathetic feedback while checking for consecutive skips.\n  - **snooze:** Schedules a 30-minute follow-up reminder.\n  - **mystats:** Generates a 7-day adherence report with visual progress bars.\n  - **mymeds:** Provides the full daily medication schedule and instructions.\n\n- 👁️ **Automated Caregiver Alerts**  \n  An hourly check detects \"Pending\" reminders. If a patient hasn't responded within 2 hours, the bot automatically alerts the designated caregiver via WhatsApp.\n\n- 📊 **Comprehensive Analytics**  \n  Caregivers can request a full patient report (e.g., `report &lt;phone&gt;`) to view a categorized summary of taken vs. missed doses.\n\n---\n\n## ✨ Key Features\n\n- **Slot-Based Intelligence:** Automatically determines if it is Morning, Afternoon, or Night to send only relevant medications.\n- **Gamified Adherence:** Tracks \"Streaks\" (consecutive days taken) with motivational emojis to encourage patient consistency.\n- **Visual Bar Charts:** Patients and caregivers receive structured reports using visual bars (`███░░`) to show adherence percentages.\n- **Temporary Snooze Queue:** Uses a dedicated \"SnoozeQueue\" tab to ensure follow-up reminders aren't forgotten.\n- **Proactive Safety:** Built-in logic to detect 2+ consecutive skips, alerting caregivers before it becomes a health risk.\n\n---\n\n## 💼 Perfect For\n\n- **Elderly Care:** Providing automated support for seniors managing multiple daily medications.\n- **Chronic Condition Management:** Ensuring strict adherence for long-term treatments like hypertension or diabetes.\n- **Home Healthcare Agencies:** Scaling patient monitoring without increasing manual staff check-ins.\n- **Clinical Trials:** Tracking participant adherence with a digital, timestamped audit trail.\n\n---\n\n## 🔧 What You'll Need\n\n### Required Integrations\n\n- **WATI** – To deliver medication reminders and process patient responses.\n- **Google Sheets** – To store the master medication list, adherence logs, and snooze queue.\n\n### Optional Customizations\n\n- **AI Analysis:** Integrate OpenAI to answer patient questions about specific medication side effects.\n- **Emergency Escalation:** Add a voice call node if a high-priority medication is missed 3 times in a row.\n\n---\n\n## 🚀 Quick Start\n\n1. **Import Template** – Copy the JSON and import it into your n8n instance.\n2. **Set Credentials** – Connect your WATI and Google Sheets accounts.\n3. **Configure Sheets** – Ensure your Google Sheet has three tabs:\n\n   **Medications:**  \n   `phone`, `patientName`, `medName`, `dosage`, `frequency`, `timeSlots`, `status`, `caregiverPhone`\n\n   **AdherenceLog:**  \n   `logKey`, `phone`, `patientName`, `date`, `slot`, `status`, `sentAt`, `respondedAt`, `caregiverPhone`\n\n   **SnoozeQueue:**  \n   `phone`, `patientName`, `followUpAt`, `snoozedAt`, `status`\n\n4. **Test Reminders** – Add a test row to your sheet and manually trigger the 8 AM node.\n5. **Simulate a Reply** – Reply `taken` or `mystats` to your WATI number to see your report generated live.\n\n---\n\n## 🎨 Customization Options\n\n- **Custom Time Windows:** Modify the Filter Medications by Time Slot code to align with specific clinic hours.\n- **Empathetic Messaging:** Customize the reinforce messages in the Process Taken and Process Skip nodes to match your brand voice.\n- **Adherence Thresholds:** Adjust the caregiver alert logic to trigger after 1 hour or 4 hours depending on medication sensitivity.\n\n---\n\n## 📈 Expected Results\n\n- 95% adherence transparency for caregivers and family members.\n- Reduced health risks by identifying missed doses within a 2-hour window.\n- Improved patient morale through positive streak reinforcement and visual progress.\n- Efficient monitoring: One caregiver can monitor dozens of patients through a single WhatsApp interface.\n\n---\n\nReady to launch your digital health assistant? Import this template and connect your Google Sheets to start improving patient adherence today!","workflow":{"meta":{"instanceId":"277842713620d9f5554de3b1518b865a152c8c4db680008bd8aec536fc18b4a8","templateCredsSetupCompleted":true},"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. Patient replies *taken*, *skip* or *snooze* to log their response\n3. If no response within 2 hours → caregiver is auto-alerted\n4. Patient can type *mystats* to see their weekly adherence report\n5. Patient types *mymeds* to see today's medication schedule\n6. Caregiver types *report <phone>* to get a patient's full adherence summary\n\n**Credentials needed:** WATI, Google Sheets OAuth2"},"typeVersion":1},{"id":"03b70fab-0e5c-4e8d-b85b-04676595348c","name":"Sticky – Scheduled Reminders","type":"n8n-nodes-base.stickyNote","position":[2512,1312],"parameters":{"color":7,"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 medications due in the current time window (morning / afternoon / night).\n**Build & Send Reminder Loop** sends a personalised reminder per patient with taken/skip/snooze options."},"typeVersion":1},{"id":"c532ecf6-0291-44f9-b9b0-a77b205418ff","name":"Sticky – Inbound Routing","type":"n8n-nodes-base.stickyNote","position":[-96,1184],"parameters":{"color":7,"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 30-min follow-up reminder\n- `mystats` → weekly adherence report\n- `mymeds` → today's medication schedule\n- `report <phone>` → caregiver pulls patient report\n- anything else → help message"},"typeVersion":1},{"id":"9cc5de58-5424-440d-bde2-17b4455a3e7e","name":"Sticky – Taken & Skip","type":"n8n-nodes-base.stickyNote","position":[1344,592],"parameters":{"color":7,"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 Skipped. Sends empathetic reminder message. Flags for caregiver alert if 2+ consecutive skips detected."},"typeVersion":1},{"id":"facc287f-8f74-4864-9773-86a300c827b2","name":"Sticky – Snooze & Missed Alert","type":"n8n-nodes-base.stickyNote","position":[1344,1072],"parameters":{"color":7,"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 Dose Check:** Runs hourly. If a reminder was sent but no response logged within 2 hours → sends alert to caregiver WhatsApp with patient name, medication and time."},"typeVersion":1},{"id":"bc02854c-cd3c-4ea7-9ed7-6779edc23c8f","name":"Sticky – Reports","type":"n8n-nodes-base.stickyNote","position":[1360,1696],"parameters":{"color":7,"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 medication schedule with timings and dosage.\n**Caregiver Report:** Caregiver sends *report <phone>* → pulls full adherence history for that patient and sends summary."},"typeVersion":1},{"id":"a51374ef-5515-4379-9a8a-f295007f8883","name":"Schedule Trigger – 8AM 1PM 8PM","type":"n8n-nodes-base.scheduleTrigger","position":[2592,1472],"parameters":{"rule":{"interval":[{"field":"cronExpression","expression":"0 8,13,20 * * *"}]}},"typeVersion":1.2},{"id":"97d52ce9-2530-4477-8830-3f4c3058d990","name":"Google Sheets – Read Medications","type":"n8n-nodes-base.googleSheets","position":[2832,1472],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=0","cachedResultName":"Medications"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"36903a3a-8b63-44a4-9c84-a7c093efb05a","name":"Filter Medications by Time Slot","type":"n8n-nodes-base.code","position":[3072,1472],"parameters":{"jsCode":"// Filter Medications by Current Time Slot\n// Determines if it's morning (8AM), afternoon (1PM) or night (8PM)\n// and returns only medications scheduled for this slot\n\nconst allRows = $input.all();\nconst now = new Date();\nconst hour = now.getHours();\n\n// Determine current time slot\nlet currentSlot = '';\nif (hour >= 6 && hour < 12)  currentSlot = 'morning';\nelse if (hour >= 12 && hour < 17) currentSlot = 'afternoon';\nelse currentSlot = 'night';\n\nconst slotLabel = { morning: '🌅 Morning', afternoon: '☀️ Afternoon', night: '🌙 Night' }[currentSlot];\n\n// Filter active medications for this time slot\nconst dueMeds = allRows.filter(r => {\n  const status = (r.json.status || '').toLowerCase();\n  const frequency = (r.json.frequency || '').toLowerCase();\n  const timeSlots = (r.json.timeSlots || '').toLowerCase();\n\n  if (status !== 'active') return false;\n\n  // Check if this medication is due in current slot\n  if (timeSlots.includes(currentSlot)) return true;\n  if (frequency === 'once daily' && currentSlot === 'morning') return true;\n  if (frequency === 'twice daily' && (currentSlot === 'morning' || currentSlot === 'night')) return true;\n  if (frequency === 'thrice daily') return true;\n  return false;\n});\n\nif (dueMeds.length === 0) {\n  return [{ json: { message: `No medications due for ${currentSlot} slot`, count: 0 } }];\n}\n\n// Group by patient phone — one message per patient with all their meds\nconst byPhone = {};\nfor (const row of dueMeds) {\n  const phone = row.json.phone;\n  if (!byPhone[phone]) {\n    byPhone[phone] = {\n      phone,\n      patientName: row.json.patientName,\n      caregiverPhone: row.json.caregiverPhone,\n      medications: [],\n      currentSlot,\n      slotLabel\n    };\n  }\n  byPhone[phone].medications.push({\n    medName: row.json.medName,\n    dosage: row.json.dosage,\n    instructions: row.json.instructions || '',\n    medId: row.json.medId || row.json.medName\n  });\n}\n\nreturn Object.values(byPhone).map(p => ({ json: p }));"},"typeVersion":2},{"id":"06817ea7-55d0-41ba-b619-813eaa12fdc2","name":"Build Medication Reminder","type":"n8n-nodes-base.code","position":[3312,1472],"parameters":{"jsCode":"// Build Medication Reminder Message\n// Creates a WhatsApp reminder listing all meds due for this slot\n\nconst data = $json;\nconst { phone, patientName, medications, slotLabel, currentSlot } = data;\nconst now = new Date();\nconst logKey = `${phone}_${now.toISOString().split('T')[0]}_${currentSlot}`;\n\nconst medLines = medications.map((m, i) =>\n  `  ${i + 1}. 💊 *${m.medName}* — ${m.dosage}${m.instructions ? `\\n     📝 ${m.instructions}` : ''}`\n).join('\\n');\n\nconst lines = [\n  `${slotLabel} *Medication Reminder* 💊`,\n  `👋 Hi *${patientName}!*`,\n  '',\n  `Please take your ${currentSlot} medications:`,\n  '',\n  medLines,\n  '',\n  '━━━━━━━━━━━━━━━━━━',\n  'Reply with:',\n  '✅ *taken* – I have taken my medication',\n  '😴 *snooze* – Remind me in 30 minutes',\n  '⏭️ *skip* – I am skipping this dose',\n];\n\nreturn {\n  json: {\n    phone,\n    patientName,\n    caregiverPhone: data.caregiverPhone,\n    currentSlot,\n    logKey,\n    reminderMessage: lines.join('\\n'),\n    sentAt: now.toISOString()\n  }\n};"},"typeVersion":2},{"id":"52c8e202-57b7-459a-9bac-97703e11d89b","name":"Google Sheets – Log Reminder Sent","type":"n8n-nodes-base.googleSheets","position":[3552,1472],"parameters":{"columns":{"value":{"date":"={{ new Date().toISOString().split('T')[0] }}","slot":"={{ $json.currentSlot }}","phone":"={{ $json.phone }}","logKey":"={{ $json.logKey }}","sentAt":"={{ $json.sentAt }}","status":"Pending","patientName":"={{ $json.patientName }}","caregiverPhone":"={{ $json.caregiverPhone }}"},"schema":[{"id":"logKey","type":"string","display":true,"required":false,"displayName":"logKey","defaultMatch":false,"canBeUsedToMatch":true},{"id":"phone","type":"string","display":true,"required":false,"displayName":"phone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"patientName","type":"string","display":true,"required":false,"displayName":"patientName","defaultMatch":false,"canBeUsedToMatch":true},{"id":"date","type":"string","display":true,"required":false,"displayName":"date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"slot","type":"string","display":true,"required":false,"displayName":"slot","defaultMatch":false,"canBeUsedToMatch":true},{"id":"status","type":"string","display":true,"required":false,"displayName":"status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"sentAt","type":"string","display":true,"required":false,"displayName":"sentAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"respondAt","type":"string","display":true,"removed":false,"required":false,"displayName":"respondAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"caregiverPhone","type":"string","display":true,"required":false,"displayName":"caregiverPhone","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"8efb5ffd-6859-48da-adc0-cef89cfcaf07","name":"Route Message","type":"n8n-nodes-base.switch","position":[336,1456],"parameters":{"rules":{"values":[{"outputKey":"Taken","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"9ce57f31-b5ab-46dd-9f8e-2b4c7392c2b2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.text.toLowerCase().trim() }}","rightValue":"taken"}]},"renameOutput":true},{"outputKey":"Skip","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"34cea88a-cf1a-4b8d-af85-b07cbc031f67","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.text.toLowerCase().trim() }}","rightValue":"skip"}]},"renameOutput":true},{"outputKey":"Snooze","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"c13d23e0-e6d3-4e0d-bddc-3e9372a76601","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.text.toLowerCase().trim() }}","rightValue":"snooze"}]},"renameOutput":true},{"outputKey":"My Stats","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"499dc0f0-288f-4b63-bfbe-c1e623cebbf1","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.text.toLowerCase().trim() }}","rightValue":"mystats"}]},"renameOutput":true},{"outputKey":"My Meds","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"3ffcee4c-5b30-47a1-8ca5-e5b8ae314fd0","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.text.toLowerCase().trim() }}","rightValue":"mymeds"}]},"renameOutput":true},{"outputKey":"Caregiver Report","conditions":{"options":{"version":1,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"62b48c7a-9d33-466d-aaec-c7c649a71d18","operator":{"type":"string","operation":"startsWith"},"leftValue":"={{ $json.text }}","rightValue":"report "}]},"renameOutput":true}]},"options":{"fallbackOutput":"extra"}},"typeVersion":3},{"id":"d3513e9b-8943-423f-8e7e-e6acce415e18","name":"Google Sheets – Read Log (Taken)","type":"n8n-nodes-base.googleSheets","position":[1424,704],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"159c0619-095a-47df-881c-6225d32b55d2","name":"Process Taken","type":"n8n-nodes-base.code","position":[1680,704],"parameters":{"jsCode":"// Process Taken Response\n// Finds the latest Pending log for this patient\n// Calculates streak and builds positive reinforcement message\n\nconst phone = $('Wati Trigger').first().json.waId|| $('WATI Trigger').item.json.from;\nconst patientName =  $('Wati Trigger').first().json.senderName|| 'Patient';\nconst allRows = $input.all();\nconst now = new Date();\nconst today = now.toISOString().split('T')[0];\n\n// Find latest pending log for this phone\nconst myLogs = allRows\n  .filter(r => r.json.phone === phone)\n  .sort((a, b) => new Date(b.json.sentAt) - new Date(a.json.sentAt));\n\nconst pendingLog = myLogs.find(r => r.json.status === 'Pending');\n\n// Calculate current streak (consecutive taken days)\nconst takenDays = new Set(\n  allRows\n    .filter(r => r.json.phone === phone && r.json.status === 'Taken')\n    .map(r => r.json.date)\n);\n\nlet streak = 0;\nconst checkDate = new Date(today);\nwhile (takenDays.has(checkDate.toISOString().split('T')[0])) {\n  streak++;\n  checkDate.setDate(checkDate.getDate() - 1);\n}\n\n// Streak emoji\nlet streakMsg = '';\nif (streak >= 30) streakMsg = `🏆 Incredible! ${streak}-day streak!`;\nelse if (streak >= 14) streakMsg = `🌟 Amazing! ${streak}-day streak!`;\nelse if (streak >= 7)  streakMsg = `🔥 On fire! ${streak}-day streak!`;\nelse if (streak >= 3)  streakMsg = `💪 ${streak}-day streak! Keep going!`;\nelse streakMsg = `✅ Great job taking your medication!`;\n\nconst lines = [\n  `✅ *Dose Logged – Taken!*`,\n  '',\n  `Well done, *${patientName}!* 🎉`,\n  streakMsg,\n  '',\n  `📅 *Date:* ${today}`,\n  `🕐 *Time:* ${now.toLocaleTimeString('en-IN', { hour: '2-digit', minute: '2-digit' })}`,\n  '',\n  'Consistency is the key to good health! 💚',\n  'Reply *mystats* to see your full adherence report.'\n];\n\nreturn [{ json: {\n  phone,\n  patientName,\n  logKey: pendingLog?.json.logKey || `${phone}_${today}_unknown`,\n  takenMessage: lines.join('\\n'),\n  today,\n  respondedAt: now.toISOString()\n}}];"},"typeVersion":2},{"id":"ce837757-ed51-43ec-804a-536288661a96","name":"Google Sheets – Update Taken","type":"n8n-nodes-base.googleSheets","position":[1920,704],"parameters":{"columns":{"value":{"logKey":"={{ $json.logKey }}","status":"Taken"},"schema":[{"id":"logKey","type":"string","display":true,"required":false,"displayName":"logKey","defaultMatch":false,"canBeUsedToMatch":true},{"id":"phone","type":"string","display":true,"removed":true,"required":false,"displayName":"phone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"patientName","type":"string","display":true,"removed":true,"required":false,"displayName":"patientName","defaultMatch":false,"canBeUsedToMatch":true},{"id":"date","type":"string","display":true,"removed":true,"required":false,"displayName":"date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"slot","type":"string","display":true,"removed":true,"required":false,"displayName":"slot","defaultMatch":false,"canBeUsedToMatch":true},{"id":"status","type":"string","display":true,"required":false,"displayName":"status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"sentAt","type":"string","display":true,"removed":true,"required":false,"displayName":"sentAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"respondAt","type":"string","display":true,"removed":true,"required":false,"displayName":"respondAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"caregiverPhone","type":"string","display":true,"removed":true,"required":false,"displayName":"caregiverPhone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"row_number","type":"number","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"row_number","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["logKey"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"4196c4a3-032e-41b8-9378-46142d7ea711","name":"Google Sheets – Read Log (Skip)","type":"n8n-nodes-base.googleSheets","position":[1424,880],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"2a2bd2d7-421b-4a78-aaa4-380416f9571b","name":"Process Skip","type":"n8n-nodes-base.code","position":[1680,880],"parameters":{"jsCode":"// Process Skip Response\n// Logs the skip, checks for consecutive skips\n// If 2+ consecutive skips → flag for caregiver alert\n\nconst phone = $('Wati Trigger').first().json.waId || $('WATI Trigger').item.json.from;\nconst patientName = $input.first().json.patientName || 'Patient';\nconst allRows = $input.all();\nconst now = new Date();\nconst today = now.toISOString().split('T')[0];\n\nconst myLogs = allRows\n  .filter(r => r.json.phone === phone)\n  .sort((a, b) => new Date(b.json.sentAt) - new Date(a.json.sentAt));\n\nconst pendingLog = myLogs.find(r => r.json.status === 'Pending');\ncaregiverPhone = $input.first().json.caregiverPhone || '';\n\n// Count consecutive recent skips\nconst recentLogs = myLogs.slice(0, 6);\nconst consecutiveSkips = recentLogs.filter(r => r.json.status === 'Skipped').length;\nconst alertCaregiver = consecutiveSkips >= 2;\n\nconst skipLines = [\n  `⏭️ *Dose Logged – Skipped*`,\n  '',\n  `We've noted your skip, *${patientName}.*`,\n  '',\n  '⚠️ Please consult your doctor before skipping medication regularly.',\n  '💡 Tip: If you are experiencing side effects, contact your healthcare provider.',\n  '',\n  'Your next reminder will be sent on schedule.',\n  'Reply *mystats* to see your adherence report.'\n];\n\nconst caregiverLines = alertCaregiver ? [\n  `🚨 *Medication Skip Alert*`,\n  '',\n  `👤 *Patient:* ${patientName}`,\n  `📞 *Phone:* ${phone}`,\n  `⏭️ *Consecutive Skips Detected:* ${consecutiveSkips + 1}`,\n  `📅 *Date:* ${today}`,\n  `🕐 *Time:* ${now.toLocaleTimeString('en-IN', { hour: '2-digit', minute: '2-digit' })}`,\n  '',\n  'Please check in with the patient.'\n] : [];\n\nreturn [{ json: {\n  phone,\n  patientName,\n  caregiverPhone,\n  logKey: $input.first().json.logKey || `${phone}_${today}_unknown`,\n  skipMessage: skipLines.join('\\n'),\n  caregiverMessage: caregiverLines.join('\\n'),\n  alertCaregiver,\n  respondedAt: now.toISOString()\n}}];"},"typeVersion":2},{"id":"c79c62f4-38be-4cf9-964a-b3cc46d1b0a3","name":"Google Sheets – Update Skipped","type":"n8n-nodes-base.googleSheets","position":[1920,880],"parameters":{"columns":{"value":{"logKey":"={{ $json.logKey }}","status":"Skipped"},"schema":[{"id":"logKey","type":"string","display":true,"required":false,"displayName":"logKey","defaultMatch":false,"canBeUsedToMatch":true},{"id":"phone","type":"string","display":true,"removed":true,"required":false,"displayName":"phone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"patientName","type":"string","display":true,"removed":true,"required":false,"displayName":"patientName","defaultMatch":false,"canBeUsedToMatch":true},{"id":"date","type":"string","display":true,"removed":true,"required":false,"displayName":"date","defaultMatch":false,"canBeUsedToMatch":true},{"id":"slot","type":"string","display":true,"removed":true,"required":false,"displayName":"slot","defaultMatch":false,"canBeUsedToMatch":true},{"id":"status","type":"string","display":true,"required":false,"displayName":"status","defaultMatch":false,"canBeUsedToMatch":true},{"id":"sentAt","type":"string","display":true,"removed":true,"required":false,"displayName":"sentAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"respondAt","type":"string","display":true,"removed":true,"required":false,"displayName":"respondAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"caregiverPhone","type":"string","display":true,"removed":true,"required":false,"displayName":"caregiverPhone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"row_number","type":"number","display":true,"removed":true,"readOnly":true,"required":false,"displayName":"row_number","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":["logKey"],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"update","sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"7426d957-e5ad-4f49-8a62-8f8a0d237740","name":"Process Snooze","type":"n8n-nodes-base.code","position":[1440,1200],"parameters":{"jsCode":"// Process Snooze Request\n// Logs snooze with a follow-up time 30 minutes from now\n\nconst phone = $json.waId || $json.from || 'unknown';\nconst patientName = $json.senderName || 'Patient';\nconst now = new Date();\nconst followUpTime = new Date(now.getTime() + 30 * 60 * 1000);\n\nconst snoozeLines = [\n  `😴 *Snooze Set!*`,\n  '',\n  `No problem, *${patientName}!*`,\n  `We'll remind you again at *${followUpTime.toLocaleTimeString('en-IN', { hour: '2-digit', minute: '2-digit' })}*. ⏰`,\n  '',\n  '💊 Please don\\'t forget your medication!'\n];\n\nreturn [{ json: {\n  phone,\n  patientName,\n  snoozeMessage: snoozeLines.join('\\n'),\n  followUpAt: followUpTime.toISOString(),\n  snoozedAt: now.toISOString()\n}}];"},"typeVersion":2},{"id":"c048e9e0-6e80-4a2d-ac9b-6f21caa484e4","name":"Google Sheets – Log Snooze","type":"n8n-nodes-base.googleSheets","position":[1824,1200],"parameters":{"columns":{"value":{"phone":"={{ $json.phone }}","status":"Pending","snoozedAt":"={{ $json.snoozedAt }}","followUpAt":"={{ $json.followUpAt }}"},"schema":[{"id":"phone","type":"string","display":true,"required":false,"displayName":"phone","defaultMatch":false,"canBeUsedToMatch":true},{"id":"patientName ","type":"string","display":true,"removed":false,"required":false,"displayName":"patientName ","defaultMatch":false,"canBeUsedToMatch":true},{"id":"followUpAt","type":"string","display":true,"required":false,"displayName":"followUpAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"snoozedAt","type":"string","display":true,"required":false,"displayName":"snoozedAt","defaultMatch":false,"canBeUsedToMatch":true},{"id":"status","type":"string","display":true,"required":false,"displayName":"status","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":1864808001,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=1864808001","cachedResultName":"SnoozeQueue"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"3980b984-eecf-405b-82a1-04ff9bd4cca0","name":"Schedule Trigger – Every 30 Min","type":"n8n-nodes-base.scheduleTrigger","position":[1440,1328],"parameters":{"rule":{"interval":[{"field":"minutes","minutesInterval":30}]}},"typeVersion":1.2},{"id":"f2bbcd28-3930-44b3-a776-b8703ab598a8","name":"Google Sheets – Read Snooze Queue","type":"n8n-nodes-base.googleSheets","position":[1664,1328],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":1864808001,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=1864808001","cachedResultName":"SnoozeQueue"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"5bb3d95b-41ff-43e8-ab61-e6a78ce8fcbd","name":"Check Snooze Queue","type":"n8n-nodes-base.code","position":[1936,1328],"parameters":{"jsCode":"// Check Snooze Queue & Missed Doses\n// 1. Finds snooze entries where followUpAt <= now → resend reminder\n// 2. Finds AdherenceLog entries that are still Pending after 2 hours → missed dose\n\nconst allSnooze = $input.all();\nconst now = new Date();\n\n// Filter snooze entries due for follow-up\nconst dueSnoozes = allSnooze.filter(r => {\n  const followUpAt = new Date(r.json.followUpAt);\n  return r.json.status === 'Pending' && followUpAt <= now;\n});\n\nif (dueSnoozes.length === 0) {\n  return [{ json: { message: 'No snooze follow-ups due', count: 0, items: [] } }];\n}\n\nreturn dueSnoozes.map(r => ({\n  json: {\n    phone: r.json.phone,\n    patientName: r.json.patientName,\n    followUpMessage: `⏰ *Snooze Reminder!*\\n\\n💊 Hi *${r.json.patientName}!* It\\'s time to take your medication now.\\n\\nReply *taken*, *skip* or *snooze* to log your response.`\n  }\n}));"},"typeVersion":2},{"id":"4d942933-3d56-4f07-b32b-fe7a0fd1d8bc","name":"Schedule Trigger – Every 1 Hour","type":"n8n-nodes-base.scheduleTrigger","position":[1456,1488],"parameters":{"rule":{"interval":[{"field":"hours"}]}},"typeVersion":1.2},{"id":"21749e76-c828-4c3c-9c56-4ea5888fee31","name":"Google Sheets – Read Log (Missed Check)","type":"n8n-nodes-base.googleSheets","position":[1696,1488],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"20aaac89-0f54-4d6a-a99f-95ea10627376","name":"Detect Missed Doses","type":"n8n-nodes-base.code","position":[1936,1488],"parameters":{"jsCode":"// Detect Missed Doses\n// Finds AdherenceLog entries still 'Pending' after 2 hours\n// Groups by caregiver phone and builds alert messages\n\nconst allRows = $input.all();\nconst now = new Date();\nconst twoHoursAgo = new Date(now.getTime() - 2 * 60 * 60 * 1000);\n\nconst missedItems = allRows.filter(r => {\n  const sentAt = new Date(r.json.sentAt || 0);\n  return r.json.status === 'Pending' && sentAt <= twoHoursAgo;\n});\n\nif (missedItems.length === 0) {\n  return [{ json: { message: 'No missed doses detected', count: 0 } }];\n}\n\n// Group by caregiver so one message per caregiver\nconst byCg = {};\nfor (const row of missedItems) {\n  const cg = row.json.caregiverPhone;\n  if (!cg) continue;\n  if (!byCg[cg]) byCg[cg] = [];\n  byCg[cg].push(row.json);\n}\n\nreturn Object.entries(byCg).map(([cgPhone, items]) => {\n  const lines = [\n    `🚨 *Missed Dose Alert*`,\n    '',\n    `The following patient(s) have NOT responded to their medication reminder:`,\n    ''\n  ];\n  for (const item of items) {\n    lines.push(`👤 *${item.patientName}* (${item.phone})`);\n    lines.push(`   📅 Date: ${item.date} | Slot: ${item.slot}`);\n    lines.push(`   ⏰ Reminder sent at: ${new Date(item.sentAt).toLocaleTimeString('en-IN', {hour:'2-digit',minute:'2-digit'})}`);\n    lines.push('');\n  }\n  lines.push('Please follow up with the patient immediately.');\n  return { json: { caregiverPhone: cgPhone, alertMessage: lines.join('\\n') } };\n});"},"typeVersion":2},{"id":"f64cea68-3edf-46bb-b220-4808627a2286","name":"Google Sheets – Read Log (Stats)","type":"n8n-nodes-base.googleSheets","position":[1488,1904],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"59897745-4615-4578-8402-87ccd0b23609","name":"Build My Stats","type":"n8n-nodes-base.code","position":[1744,1904],"parameters":{"jsCode":"// Build My Stats Report\n// 7-day adherence %, streak, best day, visual bar chart\n\nconst phone = $('Wati Trigger').first().json.waId || $('WATI Trigger').item.json.from;\nconst patientName = $('Wati Trigger').first().json.senderName || 'Patient';\nconst allRows = $input.all();\nconst now = new Date();\n\nconst myLogs = allRows.filter(r => r.json.phone === phone);\n\nif (myLogs.length === 0) {\n  return [{ json: { phone, statsMessage: `📊 No medication history found yet, *${patientName}!*\\n\\nStart taking your medications and reply *taken* after each dose.` } }];\n}\n\n// Last 7 days analysis\nconst last7 = [];\nfor (let i = 6; i >= 0; i--) {\n  const d = new Date(now);\n  d.setDate(d.getDate() - i);\n  const dateStr = d.toISOString().split('T')[0];\n  const dayLogs = myLogs.filter(r => r.json.date === dateStr);\n  const taken  = dayLogs.filter(r => r.json.status === 'Taken').length;\n  const total  = dayLogs.filter(r => r.json.status !== 'Pending').length;\n  const pct    = total > 0 ? Math.round((taken / total) * 100) : null;\n  last7.push({ dateStr, taken, total, pct, dayName: d.toLocaleDateString('en-IN', { weekday: 'short' }) });\n}\n\nconst totalTaken   = myLogs.filter(r => r.json.status === 'Taken').length;\nconst totalLogged  = myLogs.filter(r => r.json.status !== 'Pending').length;\nconst overallPct   = totalLogged > 0 ? Math.round((totalTaken / totalLogged) * 100) : 0;\n\n// Current streak\nlet streak = 0;\nconst sortedDates = [...new Set(myLogs.filter(r=>r.json.status==='Taken').map(r=>r.json.date))].sort().reverse();\nconst checkDate = new Date(now);\nfor (const d of sortedDates) {\n  if (d === checkDate.toISOString().split('T')[0]) {\n    streak++;\n    checkDate.setDate(checkDate.getDate() - 1);\n  } else break;\n}\n\n// Bar chart for last 7 days\nconst barLines = last7.map(d => {\n  if (d.pct === null) return `${d.dayName}: ─── No data`;\n  const filled = Math.round(d.pct / 10);\n  const bar = '█'.repeat(filled) + '░'.repeat(10 - filled);\n  const emoji = d.pct === 100 ? '✅' : d.pct >= 50 ? '⚠️' : '❌';\n  return `${d.dayName} ${bar} ${d.pct}% ${emoji}`;\n});\n\n// Overall bar\nconst overallFilled = Math.round(overallPct / 10);\nconst overallBar = '█'.repeat(overallFilled) + '░'.repeat(10 - overallFilled);\n\nconst lines = [\n  `📊 *Medication Adherence Report*`,\n  `👤 *${patientName}*`,\n  '',\n  `${overallBar} *${overallPct}% Overall*`,\n  `🔥 *Current Streak:* ${streak} day${streak !== 1 ? 's' : ''}`,\n  '',\n  '━━ *Last 7 Days* ━━',\n  ...barLines,\n  '',\n  `✅ Taken: ${totalTaken} doses`,\n  `⏭️ Skipped: ${myLogs.filter(r=>r.json.status==='Skipped').length} doses`,\n  `❓ Missed: ${myLogs.filter(r=>r.json.status==='Pending').length} doses`,\n  '',\n  'Keep it up! Consistency saves lives 💚'\n];\n\nreturn [{ json: { phone, statsMessage: lines.join('\\n') } }];"},"typeVersion":2},{"id":"293849b3-4226-4f7b-9eb4-25f47689209d","name":"Google Sheets – Read My Meds","type":"n8n-nodes-base.googleSheets","position":[1488,2080],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=0","cachedResultName":"Medications"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"6ab026e7-4305-47ad-aa40-6a2afaac2905","name":"Build My Meds Schedule","type":"n8n-nodes-base.code","position":[1744,2080],"parameters":{"jsCode":"// Build My Medications Schedule\n// Shows today's full schedule with timings and dosage\n\nconst phone = $('Wati Trigger').first().json.waId|| $('WATI Trigger').item.json.from;\nconst patientName =$('Wati Trigger').first().json.senderName|| 'Patient';\nconst allRows = $input.all();\n\nconst myMeds = allRows.filter(r =>\n  r.json.phone === phone && (r.json.status || '').toLowerCase() === 'active'\n);\n\nif (myMeds.length === 0) {\n  return [{ json: { phone, myMedsMessage: `💊 No active medications found, *${patientName}.*\\n\\nPlease contact your healthcare provider.` } }];\n}\n\nconst slotMap = { morning: '🌅 Morning (8:00 AM)', afternoon: '☀️ Afternoon (1:00 PM)', night: '🌙 Night (8:00 PM)' };\nconst grouped = { morning: [], afternoon: [], night: [] };\n\nfor (const row of myMeds) {\n  const slots = (row.json.timeSlots || 'morning').split(',').map(s => s.trim().toLowerCase());\n  for (const slot of slots) {\n    if (grouped[slot]) grouped[slot].push(row.json);\n  }\n}\n\nconst today = new Date().toLocaleDateString('en-IN', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });\n\nconst lines = [\n  `💊 *Today's Medication Schedule*`,\n  `👤 *${patientName}*`,\n  `📅 ${today}`,\n  ''\n];\n\nfor (const [slot, meds] of Object.entries(grouped)) {\n  if (meds.length === 0) continue;\n  lines.push(slotMap[slot]);\n  for (const m of meds) {\n    lines.push(`  • *${m.medName}* — ${m.dosage}`);\n    if (m.instructions) lines.push(`    📝 ${m.instructions}`);\n  }\n  lines.push('');\n}\n\nlines.push('━━━━━━━━━━━━━━━━━━');\nlines.push('Reply *taken*, *skip* or *snooze* after each dose.');\nlines.push('Reply *mystats* for your adherence report.');\n\nreturn [{ json: { phone, myMedsMessage: lines.join('\\n') } }];"},"typeVersion":2},{"id":"eccbd185-7ba8-49df-aeba-ca654e375606","name":"Google Sheets – Read Log (Caregiver)","type":"n8n-nodes-base.googleSheets","position":[1488,2240],"parameters":{"options":{},"sheetName":{"__rl":true,"mode":"list","value":816163013,"cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit#gid=816163013","cachedResultName":"AdherenceLog"},"documentId":{"__rl":true,"mode":"list","value":"1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1IGGQCHH59cFU-4A_ERv5s-SD0o1rrXwEZ9-jQX049g4/edit?usp=drivesdk","cachedResultName":"Untitled spreadsheet"}},"credentials":{"googleSheetsOAuth2Api":{"id":"Kz2DdSp11rxqwlFt","name":"Google Sheets account - Deepanshi"}},"typeVersion":4.5},{"id":"52f2e40d-c1c9-4f7b-97af-182b0271d0ee","name":"Build Caregiver Report","type":"n8n-nodes-base.code","position":[1744,2240],"parameters":{"jsCode":"// Build Caregiver Patient Report\n// Caregiver sends: 'report 919876543210'\n// Returns full adherence summary for that patient\n\nconst text = $('Wati Trigger').first().json.text||''.trim();\nconst caregiverPhone =  $input.first().json.caregiverPhone|| $('WATI Trigger').item.json.from;\nconst patientPhone = $('Wati Trigger').first().json.waId;\n\nif (!patientPhone) {\n  return [{ json: { phone: caregiverPhone, reportMessage: '⚠️ Please provide a patient phone number.\\nExample: *report 919876543210*' } }];\n}\n\nconst allRows = $input.all();\nconst patientLogs = allRows.filter(r => r.json.phone === patientPhone);\n\nif (patientLogs.length === 0) {\n  return [{ json: { phone: caregiverPhone, reportMessage: `❌ No records found for *${patientPhone}*.` } }];\n}\n\nconst patientName = patientLogs[0].json.patientName || 'Patient';\nconst totalTaken   = patientLogs.filter(r => r.json.status === 'Taken').length;\nconst totalSkipped = patientLogs.filter(r => r.json.status === 'Skipped').length;\nconst totalMissed  = patientLogs.filter(r => r.json.status === 'Pending').length;\nconst totalLogged  = totalTaken + totalSkipped + totalMissed;\nconst adherencePct = totalLogged > 0 ? Math.round((totalTaken / totalLogged) * 100) : 0;\n\n// Last 7 days summary\nconst now = new Date();\nconst recentDays = [];\nfor (let i = 6; i >= 0; i--) {\n  const d = new Date(now);\n  d.setDate(d.getDate() - i);\n  const dateStr = d.toISOString().split('T')[0];\n  const dayLogs = patientLogs.filter(r => r.json.date === dateStr);\n  const t = dayLogs.filter(r => r.json.status === 'Taken').length;\n  const tot = dayLogs.filter(r => r.json.status !== 'Pending').length;\n  const pct = tot > 0 ? Math.round((t / tot) * 100) : null;\n  const dayName = d.toLocaleDateString('en-IN', { weekday: 'short', month: 'short', day: 'numeric' });\n  const emoji = pct === null ? '─' : pct === 100 ? '✅' : pct >= 50 ? '⚠️' : '❌';\n  recentDays.push(`${dayName}: ${pct !== null ? pct + '%' : 'No data'} ${emoji}`);\n}\n\nconst overallFilled = Math.round(adherencePct / 10);\nconst overallBar = '█'.repeat(overallFilled) + '░'.repeat(10 - overallFilled);\n\nconst lines = [\n  `📋 *Patient Adherence Report*`,\n  `👤 *Patient:* ${patientName}`,\n  `📞 *Phone:* ${patientPhone}`,\n  '',\n  `${overallBar} *${adherencePct}% Overall*`,\n  '',\n  `✅ *Taken:* ${totalTaken} doses`,\n  `⏭️ *Skipped:* ${totalSkipped} doses`,\n  `❓ *Missed:* ${totalMissed} doses`,\n  `📦 *Total Logged:* ${totalLogged} doses`,\n  '',\n  '━━ *Last 7 Days* ━━',\n  ...recentDays,\n  '',\n  `Report generated: ${now.toLocaleDateString('en-IN')}`\n];\n\nreturn [{ json: { phone: caregiverPhone, reportMessage: lines.join('\\n') } }];"},"typeVersion":2},{"id":"f03f68e3-a5b4-4f3e-aa07-408a2df7e6b1","name":"Send a text message","type":"n8n-nodes-wati.wati","position":[3776,1472],"parameters":{"target":"=917024935915","messageText":"={{ $('Build Medication Reminder').item.json.reminderMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"509e2d6b-3205-4d08-969c-0b840ddd0eae","name":"Wati Trigger","type":"n8n-nodes-wati.watiTrigger","position":[96,1536],"webhookId":"ceb8d7d4-0ea8-4491-9bec-89f94a3feb35","parameters":{"event":"messageReceived"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1,"alwaysOutputData":true},{"id":"fe701382-9087-4e7a-85a5-6d5acf534f1a","name":"Send a text message1","type":"n8n-nodes-wati.wati","position":[2160,704],"parameters":{"target":"={{ $('Wati Trigger').item.json.waId }}","messageText":"={{ $('Process Taken').item.json.takenMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"be7b476e-74f8-4de5-80fb-787e126b52ac","name":"Send a text message2","type":"n8n-nodes-wati.wati","position":[2160,880],"parameters":{"target":"={{ $('Wati Trigger').item.json.waId }}","messageText":"={{ $('Process Skip').item.json.skipMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"25d4311c-b26d-4dff-b8d9-0d4c781bf224","name":"Send a text message3","type":"n8n-nodes-wati.wati","position":[2096,1200],"parameters":{"target":"={{ $('Wati Trigger').item.json.waId }}","messageText":"={{ $('Process Snooze').item.json.snoozeMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"8f28a3c3-9446-4fed-a69d-effe23c84a71","name":"Send a text message4","type":"n8n-nodes-wati.wati","position":[2000,1904],"parameters":{"target":"={{ $('Wati Trigger').item.json.waId }}","messageText":"={{ $json.statsMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"682c2e3a-49b2-4bc7-a856-c3e8f60f107f","name":"Send a text message5","type":"n8n-nodes-wati.wati","position":[2000,2080],"parameters":{"target":"={{ $('Wati Trigger').item.json.waId }}","messageText":"={{ $json.myMedsMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"0b95e745-e435-4a5f-883b-7346a20178e5","name":"Send a text message6","type":"n8n-nodes-wati.wati","position":[2000,2240],"parameters":{"target":"={{ $('Wati Trigger').item.json.waId }}","messageText":"={{ $json.reportMessage }}"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"34393446-073c-48bb-8b02-9dad32feb24f","name":"Send a text message7","type":"n8n-nodes-wati.wati","position":[2240,1328],"parameters":{"target":"917024935915","messageText":"hi"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1},{"id":"5fc474db-2fd0-4e8a-8b47-609c2cbea911","name":"Send a text message8","type":"n8n-nodes-wati.wati","position":[2144,1488],"parameters":{"target":"917024935915","messageText":"hi"},"credentials":{"watiApi":{"id":"LeAm3lDk4hC1D2Qy","name":"wati - templates"}},"typeVersion":1}],"pinData":{"Wati Trigger":[{"id":"699edd10f8314833aaea72b5","data":null,"text":"report meds","type":"text","waId":"917024935915","owner":false,"created":"2026-02-25T11:29:20.3929056Z","sourceId":null,"ticketId":"699d5bece335b461449f4b91","avatarUrl":null,"eventType":"message","forwarded":false,"listReply":null,"sourceUrl":null,"timestamp":"1772018959","assignedId":null,"senderName":"Deepanshi Singhal","sourceType":7,"buttonReply":null,"operatorName":null,"statusString":"SENT","operatorEmail":null,"conversationId":"699d5becb12153808a3300f0","messageContact":null,"replyContextId":"","whatsappMessageId":"wamid.HBgMOTE3MDI0OTM1OTE1FQIAEhggQUM2QTA1NjJFOTBERDg4NzNCQTBEOTZEMjVFMTM1NkMA","frequentlyForwarded":false,"interactiveButtonReply":null}]},"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}]]}}},"lastUpdatedBy":1,"workflowInfo":{"nodeCount":42,"nodeTypes":{"n8n-nodes-base.code":{"count":10},"n8n-nodes-wati.wati":{"count":9},"n8n-nodes-base.switch":{"count":1},"n8n-nodes-base.stickyNote":{"count":6},"n8n-nodes-wati.watiTrigger":{"count":1},"n8n-nodes-base.googleSheets":{"count":12},"n8n-nodes-base.scheduleTrigger":{"count":3}}},"status":"published","readyToDemo":null,"user":{"name":"Jitesh Dugar","username":"jiteshdugar","bio":"AI Automation Specialist - OpenAI, CRM & Automation Expert with a solid understanding of various tools that include Zapier, Make, Zoho CRM, Hubspot, Google Sheets, Airtable, Pipedrive, Google Analytics, and more.","verified":true,"links":["https://www.linkedin.com/in/jiteshdugar"],"avatar":"https://gravatar.com/avatar/edaa3abb99806b0586dced559d0a5417f24a507e7c4464a63960f0638a4b1b90?r=pg&d=retro&size=200"},"nodes":[{"id":18,"icon":"file:googleSheets.svg","name":"n8n-nodes-base.googleSheets","codex":{"data":{"alias":["CSV","Sheet","Spreadsheet","GS"],"resources":{"generic":[{"url":"https://n8n.io/blog/love-at-first-sight-ricardos-n8n-journey/","icon":"❤️","label":"Love at first sight: Ricardo’s n8n journey"},{"url":"https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/","icon":"🧬","label":"Why business process automation with n8n can change your daily life"},{"url":"https://n8n.io/blog/automatically-adding-expense-receipts-to-google-sheets-with-telegram-mindee-twilio-and-n8n/","icon":"🧾","label":"Automatically Adding Expense Receipts to Google Sheets with Telegram, Mindee, Twilio, and n8n"},{"url":"https://n8n.io/blog/supercharging-your-conference-registration-process-with-n8n/","icon":"🎫","label":"Supercharging your conference registration process with n8n"},{"url":"https://n8n.io/blog/creating-triggers-for-n8n-workflows-using-polling/","icon":"⏲","label":"Creating triggers for n8n workflows using polling"},{"url":"https://n8n.io/blog/no-code-ecommerce-workflow-automations/","icon":"store","label":"6 e-commerce workflows to power up your Shopify s"},{"url":"https://n8n.io/blog/migrating-community-metrics-to-orbit-using-n8n/","icon":"📈","label":"Migrating Community Metrics to Orbit using n8n"},{"url":"https://n8n.io/blog/automate-google-apps-for-productivity/","icon":"💡","label":"15 Google apps you can combine and automate to increase productivity"},{"url":"https://n8n.io/blog/your-business-doesnt-need-you-to-operate/","icon":" 🖥️","label":"Hey founders! Your business doesn't need you to operate"},{"url":"https://n8n.io/blog/how-honest-burgers-use-automation-to-save-100k-per-year/","icon":"🍔","label":"How Honest Burgers Use Automation to Save $100k per year"},{"url":"https://n8n.io/blog/how-a-digital-strategist-uses-n8n-for-online-marketing/","icon":"💻","label":"How a digital strategist uses n8n for online marketing"},{"url":"https://n8n.io/blog/why-this-product-manager-loves-workflow-automation-with-n8n/","icon":"🧠","label":"Why this Product Manager loves workflow automation with n8n"},{"url":"https://n8n.io/blog/sending-automated-congratulations-with-google-sheets-twilio-and-n8n/","icon":"🙌","label":"Sending Automated Congratulations with Google Sheets, Twilio, and n8n "},{"url":"https://n8n.io/blog/how-a-membership-development-manager-automates-his-work-and-investments/","icon":"📈","label":"How a Membership Development Manager automates his work and investments"},{"url":"https://n8n.io/blog/aws-workflow-automation/","label":"7 no-code workflow automations for Amazon Web Services"}],"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/"}],"credentialDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/"}]},"categories":["Data & Storage","Productivity"],"nodeVersion":"1.0","codexVersion":"1.0"}},"group":"[\"input\",\"output\"]","defaults":{"name":"Google Sheets"},"iconData":{"type":"file","fileBuffer":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2MCIgaGVpZ2h0PSI2MCI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGZpbGw9IiMyOEI0NDYiIGQ9Ik0zNS42OSAxIDUyIDE3LjIyNXYzOS4wODdhMy42NyAzLjY3IDAgMCAxLTEuMDg0IDIuNjFBMy43IDMuNyAwIDAgMSA0OC4yOTMgNjBIMTIuNzA3YTMuNyAzLjcgMCAwIDEtMi42MjMtMS4wNzhBMy42NyAzLjY3IDAgMCAxIDkgNTYuMzEyVjQuNjg4YTMuNjcgMy42NyAwIDAgMSAxLjA4NC0yLjYxQTMuNyAzLjcgMCAwIDEgMTIuNzA3IDF6Ii8+PHBhdGggZmlsbD0iIzZBQ0U3QyIgZD0iTTM1LjY5IDEgNTIgMTcuMjI1SDM5LjM5N2MtMi4wNTQgMC0zLjcwNy0xLjgyOS0zLjcwNy0zLjg3MnoiLz48cGF0aCBmaWxsPSIjMjE5QjM4IiBkPSJNMzkuMjExIDE3LjIyNSA1MiAyMi40OHYtNS4yNTV6Ii8+PHBhdGggZmlsbD0iI0ZGRiIgZD0iTTIwLjEyIDMxLjk3NWMwLS44MTcuNjYyLTEuNDc1IDEuNDgzLTEuNDc1aDE3Ljc5NGMuODIxIDAgMS40ODIuNjU4IDEuNDgyIDEuNDc1djE1LjQ4N2MwIC44MTgtLjY2MSAxLjQ3NS0xLjQ4MiAxLjQ3NUgyMS42MDNhMS40NzYgMS40NzYgMCAwIDEtMS40ODItMS40NzRWMzEuOTc0em0yLjIyNSAxLjQ3NWg2LjY3MnYyLjIxMmgtNi42NzJ6bTAgNS4xNjJoNi42NzJ2Mi4yMTNoLTYuNjcyem0wIDUuMTYzaDYuNjcydjIuMjEyaC02LjY3MnptOS42MzgtMTAuMzI1aDYuNjcydjIuMjEyaC02LjY3MnptMCA1LjE2Mmg2LjY3MnYyLjIxM2gtNi42NzJ6bTAgNS4xNjNoNi42NzJ2Mi4yMTJoLTYuNjcyeiIvPjxwYXRoIGZpbGw9IiMyOEI0NDYiIGQ9Ik0zNC42OSAwIDUxIDE2LjIyNXYzOS4wODdhMy42NyAzLjY3IDAgMCAxLTEuMDg0IDIuNjFBMy43IDMuNyAwIDAgMSA0Ny4yOTMgNTlIMTEuNzA3YTMuNyAzLjcgMCAwIDEtMi42MjMtMS4wNzhBMy42NyAzLjY3IDAgMCAxIDggNTUuMzEyVjMuNjg4YTMuNjcgMy42NyAwIDAgMSAxLjA4NC0yLjYxQTMuNyAzLjcgMCAwIDEgMTEuNzA3IDB6Ii8+PHBhdGggZmlsbD0iIzZBQ0U3QyIgZD0iTTM0LjY5IDAgNTEgMTYuMjI1SDM4LjM5N2MtMi4wNTQgMC0zLjcwNy0xLjgyOS0zLjcwNy0zLjg3MnoiLz48cGF0aCBmaWxsPSIjMjE5QjM4IiBkPSJNMzguMjExIDE2LjIyNSA1MSAyMS40OHYtNS4yNTV6Ii8+PHBhdGggZmlsbD0iI0ZGRiIgZD0iTTE5LjEyIDMwLjk3NWMwLS44MTcuNjYyLTEuNDc1IDEuNDgzLTEuNDc1aDE3Ljc5NGMuODIxIDAgMS40ODIuNjU4IDEuNDgyIDEuNDc1djE1LjQ4N2MwIC44MTgtLjY2MSAxLjQ3NS0xLjQ4MiAxLjQ3NUgyMC42MDNhMS40NzYgMS40NzYgMCAwIDEtMS40ODItMS40NzRWMzAuOTc0em0yLjIyNSAxLjQ3NWg2LjY3MnYyLjIxMmgtNi42NzJ6bTAgNS4xNjJoNi42NzJ2Mi4yMTNoLTYuNjcyem0wIDUuMTYzaDYuNjcydjIuMjEyaC02LjY3MnptOS42MzgtMTAuMzI1aDYuNjcydjIuMjEyaC02LjY3MnptMCA1LjE2Mmg2LjY3MnYyLjIxM2gtNi42NzJ6bTAgNS4xNjNoNi42NzJ2Mi4yMTJoLTYuNjcyeiIvPjwvZz48L3N2Zz4="},"displayName":"Google Sheets","typeVersion":5,"nodeCategories":[{"id":3,"name":"Data & Storage"},{"id":4,"name":"Productivity"}]},{"id":112,"icon":"fa:map-signs","name":"n8n-nodes-base.switch","codex":{"data":{"alias":["Router","If","Path","Filter","Condition","Logic","Branch","Case"],"resources":{"generic":[{"url":"https://n8n.io/blog/2021-the-year-to-automate-the-new-you-with-n8n/","icon":"☀️","label":"2021: The Year to Automate the New You with n8n"},{"url":"https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/","icon":"👥","label":"How to get started with CRM automation (with 3 no-code workflow ideas"},{"url":"https://n8n.io/blog/build-your-own-virtual-assistant-with-n8n-a-step-by-step-guide/","icon":"👦","label":"Build your own virtual assistant with n8n: A step by step guide"},{"url":"https://n8n.io/blog/automation-for-maintainers-of-open-source-projects/","icon":"🏷️","label":"How to automatically manage contributions to open-source projects"}],"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.switch/"}]},"categories":["Core Nodes"],"nodeVersion":"1.0","codexVersion":"1.0","subcategories":{"Core Nodes":["Flow"]}}},"group":"[\"transform\"]","defaults":{"name":"Switch","color":"#506000"},"iconData":{"icon":"map-signs","type":"icon"},"displayName":"Switch","typeVersion":3,"nodeCategories":[{"id":9,"name":"Core Nodes"}]},{"id":565,"icon":"fa:sticky-note","name":"n8n-nodes-base.stickyNote","codex":{"data":{"alias":["Comments","Notes","Sticky"],"categories":["Core Nodes"],"nodeVersion":"1.0","codexVersion":"1.0","subcategories":{"Core Nodes":["Helpers"]}}},"group":"[\"input\"]","defaults":{"name":"Sticky Note","color":"#FFD233"},"iconData":{"icon":"sticky-note","type":"icon"},"displayName":"Sticky Note","typeVersion":1,"nodeCategories":[{"id":9,"name":"Core Nodes"}]},{"id":834,"icon":"file:code.svg","name":"n8n-nodes-base.code","codex":{"data":{"alias":["cpde","Javascript","JS","Python","Script","Custom Code","Function"],"details":"The Code node allows you to execute JavaScript in your workflow.","resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/"}]},"categories":["Development","Core Nodes"],"nodeVersion":"1.0","codexVersion":"1.0","subcategories":{"Core Nodes":["Helpers","Data Transformation"]}}},"group":"[\"transform\"]","defaults":{"name":"Code"},"iconData":{"type":"file","fileBuffer":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8xMTcxXzQ0MSkiPgo8cGF0aCBkPSJNMTcwLjI4MyA0OEgxOTYuNUMyMDMuMTI3IDQ4IDIwOC41IDQyLjYyNzQgMjA4LjUgMzZWMTJDMjA4LjUgNS4zNzI1OCAyMDMuMTI3IDAgMTk2LjUgMEgxNzAuMjgzQzEyNi4xIDAgOTAuMjgzIDM1LjgxNzIgOTAuMjgzIDgwVjE3NkM5MC4yODMgMjA2LjkyOCA2NS4yMTA5IDIzMiAzNC4yODMgMjMySDIzQzE2LjM3MjYgMjMyIDExIDIzNy4zNzIgMTEgMjQ0VjI2OEMxMSAyNzQuNjI3IDE2LjM3MjQgMjgwIDIyLjk5OTYgMjgwTDM0LjI4MyAyODBDNjUuMjEwOSAyODAgOTAuMjgzIDMwNS4wNzIgOTAuMjgzIDMzNlY0NDBDOTAuMjgzIDQ3OS43NjQgMTIyLjUxOCA1MTIgMTYyLjI4MyA1MTJIMTk2LjVDMjAzLjEyNyA1MTIgMjA4LjUgNTA2LjYyNyAyMDguNSA1MDBWNDc2QzIwOC41IDQ2OS4zNzMgMjAzLjEyNyA0NjQgMTk2LjUgNDY0SDE2Mi4yODNDMTQ5LjAyOCA0NjQgMTM4LjI4MyA0NTMuMjU1IDEzOC4yODMgNDQwVjMzNkMxMzguMjgzIDMwOS4wMjIgMTI4LjAxMSAyODQuNDQzIDExMS4xNjQgMjY1Ljk2MUMxMDYuMTA5IDI2MC40MTYgMTA2LjEwOSAyNTEuNTg0IDExMS4xNjQgMjQ2LjAzOUMxMjguMDExIDIyNy41NTcgMTM4LjI4MyAyMDIuOTc4IDEzOC4yODMgMTc2VjgwQzEzOC4yODMgNjIuMzI2OSAxNTIuNjEgNDggMTcwLjI4MyA0OFoiIGZpbGw9IiNGRjk5MjIiLz4KPHBhdGggZD0iTTMwNSAzNkMzMDUgNDIuNjI3NCAzMTAuMzczIDQ4IDMxNyA0OEgzNDIuOTc5QzM2MC42NTIgNDggMzc0Ljk3OCA2Mi4zMjY5IDM3NC45NzggODBWMTc2QzM3NC45NzggMjAyLjk3OCAzODUuMjUxIDIyNy41NTcgNDAyLjA5OCAyNDYuMDM5QzQwNy4xNTMgMjUxLjU4NCA0MDcuMTUzIDI2MC40MTYgNDAyLjA5OCAyNjUuOTYxQzM4NS4yNTEgMjg0LjQ0MyAzNzQuOTc4IDMwOS4wMjIgMzc0Ljk3OCAzMzZWNDMyQzM3NC45NzggNDQ5LjY3MyAzNjAuNjUyIDQ2NCAzNDIuOTc5IDQ2NEgzMTdDMzEwLjM3MyA0NjQgMzA1IDQ2OS4zNzMgMzA1IDQ3NlY1MDBDMzA1IDUwNi42MjcgMzEwLjM3MyA1MTIgMzE3IDUxMkgzNDIuOTc5QzM4Ny4xNjEgNTEyIDQyMi45NzggNDc2LjE4MyA0MjIuOTc4IDQzMlYzMzZDNDIyLjk3OCAzMDUuMDcyIDQ0OC4wNTEgMjgwIDQ3OC45NzkgMjgwSDQ5MEM0OTYuNjI3IDI4MCA1MDIgMjc0LjYyOCA1MDIgMjY4VjI0NEM1MDIgMjM3LjM3MyA0OTYuNjI4IDIzMiA0OTAgMjMyTDQ3OC45NzkgMjMyQzQ0OC4wNTEgMjMyIDQyMi45NzggMjA2LjkyOCA0MjIuOTc4IDE3NlY4MEM0MjIuOTc4IDM1LjgxNzIgMzg3LjE2MSAwIDM0Mi45NzkgMEgzMTdDMzEwLjM3MyAwIDMwNSA1LjM3MjU4IDMwNSAxMlYzNloiIGZpbGw9IiNGRjk5MjIiLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF8xMTcxXzQ0MSI+CjxyZWN0IHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo="},"displayName":"Code","typeVersion":2,"nodeCategories":[{"id":5,"name":"Development"},{"id":9,"name":"Core Nodes"}]},{"id":839,"icon":"fa:clock","name":"n8n-nodes-base.scheduleTrigger","codex":{"data":{"alias":["Time","Scheduler","Polling","Cron","Interval"],"resources":{"generic":[],"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/"}]},"categories":["Core Nodes"],"nodeVersion":"1.0","codexVersion":"1.0"}},"group":"[\"trigger\",\"schedule\"]","defaults":{"name":"Schedule Trigger","color":"#31C49F"},"iconData":{"icon":"clock","type":"icon"},"displayName":"Schedule Trigger","typeVersion":1,"nodeCategories":[{"id":9,"name":"Core Nodes"}]}],"categories":[{"id":40,"name":"Support Chatbot"},{"id":47,"name":"AI Chatbot"}],"image":[]}}