{
  "id": "avWHNKwWwluMcjge",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Student Admission & Onboarding Automation",
  "tags": [],
  "nodes": [
    {
      "id": "7a080e11-1f6a-4bad-be9e-2e791f2339b1",
      "name": "Validate Application Data",
      "type": "n8n-nodes-base.if",
      "position": [
        -500,
        -80
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json.firstName}}",
              "operation": "isNotEmpty"
            },
            {
              "value1": "={{$json.lastName}}",
              "operation": "isNotEmpty"
            },
            {
              "value1": "={{$json.email}}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fdf26268-f331-4a67-826d-541abe266d1a",
      "name": "Process Application Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -280,
        -180
      ],
      "parameters": {
        "jsCode": "// Get existing data from Excel\nconst existingData = $input.all();\n\n// Get new application data from webhook\nconst newApplication = $('Webhook - Application Form').first().json;\n\n// Create new student record\nconst newStudent = {\n  'Application ID': 'APP-' + Date.now(),\n  'First Name': newApplication.firstName,\n  'Last Name': newApplication.lastName,\n  'Email': newApplication.email,\n  'Phone': newApplication.phone || '',\n  'Program Interest': newApplication.program || 'General',\n  'Grade Level': newApplication.gradeLevel || '',\n  'School': newApplication.school || '',\n  'Guardian Name': newApplication.guardianName || '',\n  'Guardian Phone': newApplication.guardianPhone || '',\n  'Application Date': new Date().toISOString().split('T')[0],\n  'Status': 'Pending Review',\n  'Notes': newApplication.additionalNotes || ''\n};\n\n// Combine existing data with new application\nconst allData = [...existingData, newStudent];\n\nreturn allData.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "cf61ad33-7397-4d7b-820d-42f17b88bde8",
      "name": "Update Student Database",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        -60,
        -180
      ],
      "parameters": {
        "options": {},
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "324t5yttre"
        },
        "operation": "append",
        "worksheet": {
          "__rl": true,
          "mode": "id",
          "value": "=23wrhhh"
        }
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "dd051ad2-91b2-411c-a128-26169f78fb3e",
      "name": "Prepare Welcome Email",
      "type": "n8n-nodes-base.code",
      "position": [
        160,
        -180
      ],
      "parameters": {
        "jsCode": "// Get application data\nconst applicationData = $('Webhook - Application Form').first().json;\n\n// Create email content\nconst emailSubject = 'Welcome! Your Application Has Been Received';\nconst emailBody = `Dear ${applicationData.firstName} ${applicationData.lastName},\n\nThank you for your interest in our program! We have successfully received your application and it is currently under review.\n\nApplication Details:\n- Program of Interest: ${applicationData.program || 'General Program'}\n- Grade Level: ${applicationData.gradeLevel || 'Not Specified'}\n- Application Date: ${new Date().toLocaleDateString()}\n\nWhat happens next?\n1. Our admissions team will review your application within 3-5 business days\n2. You will receive an email with next steps or any additional requirements\n3. If you have any questions, please don't hesitate to contact us\n\nThank you for choosing our institution. We look forward to potentially welcoming you to our community!\n\nBest regards,\nAdmissions Team`;\n\nreturn [{\n  json: {\n    to: applicationData.email,\n    subject: emailSubject,\n    body: emailBody,\n    studentName: `${applicationData.firstName} ${applicationData.lastName}`,\n    program: applicationData.program,\n    applicationDate: new Date().toLocaleDateString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "717ebb5a-648c-4748-9ef1-573ec09458c9",
      "name": "Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        600,
        -180
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"message\": \"Application submitted successfully\",\n  \"applicationId\": \"APP-\" + Date.now(),\n  \"status\": \"pending_review\",\n  \"studentName\": $json.firstName + \" \" + $json.lastName,\n  \"program\": $json.program || \"General\",\n  \"submissionTime\": new Date().toISOString(),\n  \"nextSteps\": \"You will receive an email confirmation shortly and our admissions team will review your application within 3-5 business days.\"\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "40c7a9e4-26da-4e54-9598-105e54b1cd28",
      "name": "Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -280,
        20
      ],
      "parameters": {
        "options": {
          "responseCode": 400
        },
        "respondWith": "json",
        "responseBody": "{\n  \"success\": false,\n  \"error\": \"Invalid application data\",\n  \"message\": \"Please ensure all required fields (firstName, lastName, email) are provided.\",\n  \"requiredFields\": [\"firstName\", \"lastName\", \"email\"],\n  \"timestamp\": \"{{ new Date().toISOString() }}\"\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "a0aa2e5a-1d10-4926-8da4-b81402ea0f35",
      "name": "Read Student Data",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        -720,
        -80
      ],
      "parameters": {
        "filters": {},
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "1234567uytr4w"
        }
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "76950d75-bc2f-47a6-b682-6bc46b921f42",
      "name": "Send email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        380,
        -180
      ],
      "parameters": {
        "text": "${applicationData.emailtext}",
        "options": {},
        "subject": "${applicationData.subject}",
        "toEmail": "${applicationData.toemail}",
        "fromEmail": "user@example.com",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0107a249-3bf2-4019-8daf-92eb6a92637a",
      "name": "Trigger at Every Day 7 am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -940,
        -80
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cd5f1386-0912-4666-9a27-2d0feb24ff4a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -980,
        -440
      ],
      "parameters": {
        "color": 5,
        "width": 640,
        "height": 260,
        "content": "### **Main Components**\n* **Trigger at Every Day 7 am** - Scheduled trigger that runs the workflow daily\n* **Read Student Data** - Reads pending applications from Excel/database\n* **Validate Application Data** - Checks data completeness and format\n* **Process Application Data** - Processes validated applications\n* **Update Student Database** - Updates records in the student database\n* **Prepare Welcome Email** - Creates personalized welcome messages\n* **Send Email** - Sends welcome emails to students/guardians\n* **Success Response** - Confirms successful processing\n* **Error Response** - Handles any processing errors\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "39d210c3-6dc0-4dce-8cea-133208caf718",
  "connections": {
    "Send email": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Student Data": {
      "main": [
        [
          {
            "node": "Validate Application Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Welcome Email": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Student Database": {
      "main": [
        [
          {
            "node": "Prepare Welcome Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Application Data": {
      "main": [
        [
          {
            "node": "Update Student Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger at Every Day 7 am": {
      "main": [
        [
          {
            "node": "Read Student Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Application Data": {
      "main": [
        [
          {
            "node": "Process Application Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}