{
  "name": "Appointment reminders",
  "active": false,
  "isArchived": false,
  "pinData": {},
  "versionId": "00000000-0000-0000-0000-000000000003",
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "YOUR_N8N_INSTANCE_ID"
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/London",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [],
  "nodes": [
    {
      "id": "c3e3c003-0003-4000-8000-000000000001",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -300,
        120
      ],
      "parameters": {
        "width": 340,
        "height": 560,
        "color": 7,
        "content": "## Setup (placeholders only)\n\n1. Replace `YOUR_SPREADSHEET_ID`.\n2. Sheet tab `Appointments` with headers: `name`, `email`, `appointment_at`, `details`, `reminder_sent_at`, `cancelled`.\n3. Use a clear date-time in `appointment_at`, for example `2026-12-15T10:00:00`.\n4. Put `yes` in `cancelled` if the booking should not be reminded.\n5. Attach your own Google Sheets and SMTP credentials. Replace `YOUR_FROM_EMAIL@example.com`.\n6. Set the workflow timezone to the zone your bookings use (default: Europe/London).\n7. Test with your own address and a booking dated tomorrow, then publish.\n\nDraft template for Kaizen Flourishing. Use tech. Stay human."
      }
    },
    {
      "id": "c3e3c003-0003-4000-8000-000000000002",
      "name": "Every morning",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        120,
        320
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "daysInterval": 1,
              "triggerAtHour": 9,
              "triggerAtMinute": 0
            }
          ]
        }
      }
    },
    {
      "id": "c3e3c003-0003-4000-8000-000000000003",
      "name": "Read Appointments sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        360,
        320
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account (placeholder)"
        }
      },
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Appointments",
          "mode": "name"
        },
        "options": {}
      }
    },
    {
      "id": "c3e3c003-0003-4000-8000-000000000004",
      "name": "Which reminders are due",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        600,
        320
      ],
      "parameters": {
        "jsCode": "const cancelledValues = new Set(['yes', 'y', 'true', '1']);\n\nfunction isCancelled(value) {\n  return cancelledValues.has(String(value || '').trim().toLowerCase());\n}\n\nfunction startOfLocalDay(date) {\n  return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();\n}\n\nconst todayStart = startOfLocalDay(new Date());\nconst tomorrowStart = todayStart + 24 * 60 * 60 * 1000;\nconst dayAfterStart = tomorrowStart + 24 * 60 * 60 * 1000;\n\nreturn $input.all().map((item) => {\n  const row = item.json;\n  const when = row.appointment_at ? new Date(row.appointment_at) : null;\n  const valid = when && !Number.isNaN(when.getTime());\n  const appointmentMs = valid ? when.getTime() : 0;\n  const isTomorrow = valid && appointmentMs >= tomorrowStart && appointmentMs < dayAfterStart;\n  const alreadySent = Boolean(row.reminder_sent_at);\n  const send_reminder = Boolean(\n    row.email && valid && isTomorrow && !alreadySent && !isCancelled(row.cancelled)\n  );\n\n  const name = row.name || 'there';\n  let whenLabel = '';\n  if (valid) {\n    whenLabel = when.toLocaleString('en-GB', {\n      weekday: 'long',\n      day: 'numeric',\n      month: 'long',\n      year: 'numeric',\n      hour: '2-digit',\n      minute: '2-digit',\n    });\n  }\n\n  const details = row.details ? String(row.details) : '';\n  const body =\n    'Hello ' + name + ',\\n\\n' +\n    'This is a reminder of your appointment tomorrow' +\n    (whenLabel ? ' (' + whenLabel + ')' : '') + '.\\n\\n' +\n    (details ? details + '\\n\\n' : '') +\n    'If your plans have changed, please reply to this email.\\n\\n' +\n    '\u2014 [YOUR NAME / BUSINESS]';\n\n  return {\n    json: {\n      ...row,\n      send_reminder: send_reminder ? 'yes' : '',\n      subject: 'Reminder: your appointment tomorrow',\n      body,\n    },\n  };\n});\n"
      }
    },
    {
      "id": "c3e3c003-0003-4000-8000-000000000005",
      "name": "Is a reminder due",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        840,
        320
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c3e3c003-0003-4000-8000-0000000000c1",
              "leftValue": "={{ $json.send_reminder }}",
              "rightValue": "yes",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "c3e3c003-0003-4000-8000-000000000006",
      "name": "Send reminder",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1080,
        240
      ],
      "credentials": {
        "smtp": {
          "id": "YOUR_SMTP_CREDENTIAL_ID",
          "name": "SMTP account (placeholder)"
        }
      },
      "parameters": {
        "fromEmail": "YOUR_FROM_EMAIL@example.com",
        "toEmail": "={{ $json.email }}",
        "subject": "={{ $json.subject }}",
        "emailFormat": "text",
        "text": "={{ $json.body }}",
        "options": {}
      }
    },
    {
      "id": "c3e3c003-0003-4000-8000-000000000007",
      "name": "Mark reminder sent",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1320,
        240
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account (placeholder)"
        }
      },
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Appointments",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $json.row_number }}",
            "reminder_sent_at": "={{ $now.toISO() }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "reminder_sent_at",
              "displayName": "reminder_sent_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Every morning": {
      "main": [
        [
          {
            "node": "Read Appointments sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Appointments sheet": {
      "main": [
        [
          {
            "node": "Which reminders are due",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Which reminders are due": {
      "main": [
        [
          {
            "node": "Is a reminder due",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is a reminder due": {
      "main": [
        [
          {
            "node": "Send reminder",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Send reminder": {
      "main": [
        [
          {
            "node": "Mark reminder sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
