{
  "name": "Smart LMS Education Automation",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "student-registration",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "lms1a2b3c-1111-2222-3333-444455556666",
      "name": "Student Registration Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "=Assess this new student's profile and initial quiz answers to determine their level:\n\nStudent Name: {{ $json.student_name }}\nBackground: {{ $json.background }}\nInitial Quiz Answers: {{ $json.quiz_answers }}\n\nReturn JSON with:\n- current_level (beginner/intermediate/advanced)\n- recommended_modules (array of 3-5 module names)\n- learning_style (visual/auditory/reading)\n- estimated_completion_days (number)\n- risk_factors (array of potential challenges)\n\nReturn only valid JSON."
            }
          ]
        },
        "options": {
          "temperature": 0.3
        }
      },
      "id": "lms2b3c4d-2222-3333-4444-555566667777",
      "name": "AI Level Assessment",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Generate Personalized Learning Path\nconst assessment = JSON.parse($('AI Level Assessment').first().json.message.content);\nconst student = $('Student Registration Webhook').first().json;\n\nreturn [{\n  json: {\n    student_id: 'STU-' + Date.now(),\n    student_name: student.student_name,\n    email: student.email,\n    current_level: assessment.current_level,\n    recommended_modules: assessment.recommended_modules,\n    learning_style: assessment.learning_style,\n    estimated_days: assessment.estimated_completion_days,\n    risk_factors: assessment.risk_factors,\n    current_module_index: 0,\n    status: 'active',\n    enrollment_date: $now.toISO()\n  }\n}];"
      },
      "id": "lms3c4d5e-3333-4444-5555-666677778888",
      "name": "Create Learning Path",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        710,
        300
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Students",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "student_id": "={{ $json.student_id }}",
            "student_name": "={{ $json.student_name }}",
            "email": "={{ $json.email }}",
            "current_level": "={{ $json.current_level }}",
            "current_module_index": "={{ $json.current_module_index }}",
            "status": "={{ $json.status }}",
            "enrollment_date": "={{ $json.enrollment_date }}"
          },
          "schema": []
        },
        "options": {}
      },
      "id": "lms4d5e6f-4444-5555-6666-777788889999",
      "name": "Save Student to DB",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        940,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "lms@yourcompany.com",
        "toEmail": "={{ $json.email }}",
        "subject": "=Welcome to the Course! Your Personalized Learning Path",
        "emailType": "text",
        "message": "=Dear {{ $json.student_name }},\n\nWelcome! Based on your assessment, you are at the {{ $json.current_level }} level.\n\nYour first module is: {{ $json.recommended_modules[0] }}\n\nPlease complete it and submit the quiz using the link below.\n\nBest regards,\nLMS Team",
        "options": {}
      },
      "id": "lms5e6f7a-5555-6666-7777-888899990000",
      "name": "Send Welcome Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        1170,
        300
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "quiz-submission",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "lms6f7a8b-6666-7777-8888-999900001111",
      "name": "Quiz Submission Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        600
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "=Grade this student's quiz submission:\n\nStudent ID: {{ $json.student_id }}\nModule: {{ $json.module_name }}\nAnswers: {{ $json.answers }}\n\nReturn JSON with:\n- score (0-100)\n- passed (boolean, true if score >= 70)\n- feedback (personalized string)\n- weak_areas (array of topics to review)\n\nReturn only valid JSON."
            }
          ]
        },
        "options": {
          "temperature": 0.2
        }
      },
      "id": "lms7a8b9c-7777-8888-9999-000011112222",
      "name": "AI Quiz Grading",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        480,
        600
      ]
    },
    {
      "parameters": {
        "jsCode": "// Update Progress and Check Risk\nconst grading = JSON.parse($('AI Quiz Grading').first().json.message.content);\nconst quizData = $('Quiz Submission Webhook').first().json;\n\nlet status = 'active';\nlet is_at_risk = false;\n\nif (grading.score < 50) {\n  is_at_risk = true;\n  status = 'at_risk';\n} else if (grading.passed) {\n  status = 'module_completed';\n}\n\nreturn [{\n  json: {\n    ...quizData,\n    score: grading.score,\n    passed: grading.passed,\n    feedback: grading.feedback,\n    weak_areas: grading.weak_areas,\n    status: status,\n    is_at_risk: is_at_risk,\n    graded_at: $now.toISO()\n  }\n}];"
      },
      "id": "lms8b9c0d-8888-9999-0000-111122223333",
      "name": "Update Progress & Risk Check",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        710,
        600
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "boolean": [
                  {
                    "value1": "={{ $json.is_at_risk }}",
                    "value2": true
                  }
                ]
              },
              "outputKey": "at_risk"
            }
          ]
        },
        "fallbackOutputKey": "passed"
      },
      "id": "lms9c0d1e-9999-0000-1111-222233334444",
      "name": "Check Quiz Result",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        940,
        600
      ]
    },
    {
      "parameters": {
        "fromEmail": "lms@yourcompany.com",
        "toEmail": "={{ $json.email }}",
        "subject": "=Let's Review! Additional Help for {{ $json.module_name }}",
        "emailType": "text",
        "message": "=Dear {{ $json.student_name }},\n\nWe noticed you scored {{ $json.score }} on the {{ $json.module_name }} quiz.\n\nDon't worry! Here is some personalized feedback:\n{{ $json.feedback }}\n\nAreas to review: {{ $json.weak_areas.join(', ') }}\n\nPlease review the material and retake the quiz.\n\nBest regards,\nLMS Support Team",
        "options": {}
      },
      "id": "lms0d1e2f-0000-1111-2222-333344445555",
      "name": "Send Remedial Help",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        1170,
        500
      ]
    },
    {
      "parameters": {
        "fromEmail": "lms@yourcompany.com",
        "toEmail": "={{ $json.email }}",
        "subject": "=\ud83c\udf89 Congratulations! Course Certificate",
        "emailType": "text",
        "message": "=Dear {{ $json.student_name }},\n\nCongratulations on passing the {{ $json.module_name }} module with a score of {{ $json.score }}!\n\nYour digital certificate is attached.\n\nFeedback: {{ $json.feedback }}\n\nKeep up the great work!\n\nBest regards,\nLMS Team",
        "options": {}
      },
      "id": "lms1e2f3a-1111-2222-3333-444455556666",
      "name": "Send Certificate",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        1170,
        700
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * 1"
            }
          ]
        }
      },
      "id": "lms2f3a4b-2222-3333-4444-555566667777",
      "name": "Weekly Analytics Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        250,
        900
      ]
    },
    {
      "parameters": {
        "operation": "getAll",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Students",
          "mode": "name"
        },
        "options": {}
      },
      "id": "lms3a4b5c-3333-4444-5555-666677778888",
      "name": "Fetch All Students",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        480,
        900
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "=Analyze this student data for a weekly LMS report:\n\n{{ JSON.stringify($input.first().json) }}\n\nProvide a JSON response with:\n- total_active_students (number)\n- completion_rate (percentage)\n- at_risk_students (number)\n- top_struggling_module (string)\n- weekly_summary (2-3 sentences)\n- recommended_actions (array of 3 items for admins)\n\nReturn only valid JSON."
            }
          ]
        },
        "options": {
          "temperature": 0.4
        }
      },
      "id": "lms4b5c6d-4444-5555-6666-777788889999",
      "name": "AI Weekly Analytics",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        710,
        900
      ]
    },
    {
      "parameters": {
        "fromEmail": "lms@yourcompany.com",
        "toEmail": "admin@yourcompany.com",
        "subject": "=Weekly LMS Analytics Report - {{ $now.toFormat('yyyy-MM-dd') }}",
        "emailType": "text",
        "message": "=Dear Admin,\n\nHere is your weekly LMS report:\n\n\ud83d\udcca METRICS:\n- Active Students: {{ JSON.parse($('AI Weekly Analytics').first().json.message.content).total_active_students }}\n- Completion Rate: {{ JSON.parse($('AI Weekly Analytics').first().json.message.content).completion_rate }}%\n- At-Risk Students: {{ JSON.parse($('AI Weekly Analytics').first().json.message.content).at_risk_students }}\n\n\ud83d\udcdd SUMMARY:\n{{ JSON.parse($('AI Weekly Analytics').first().json.message.content).weekly_summary }}\n\n\ud83d\udd0d TOP STRUGGLING MODULE:\n{{ JSON.parse($('AI Weekly Analytics').first().json.message.content).top_struggling_module }}\n\n\u2705 ACTION ITEMS:\n{{ JSON.parse($('AI Weekly Analytics').first().json.message.content).recommended_actions.map((a, i) => `${i+1}. ${a}`).join('\\n') }}\n\nBest regards,\nLMS Automation System",
        "options": {}
      },
      "id": "lms5c6d7e-5555-6666-7777-888899990000",
      "name": "Send Admin Report",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        940,
        900
      ]
    }
  ],
  "connections": {
    "Student Registration Webhook": {
      "main": [
        [
          {
            "node": "AI Level Assessment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Level Assessment": {
      "main": [
        [
          {
            "node": "Create Learning Path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Learning Path": {
      "main": [
        [
          {
            "node": "Save Student to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Student to DB": {
      "main": [
        [
          {
            "node": "Send Welcome Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quiz Submission Webhook": {
      "main": [
        [
          {
            "node": "AI Quiz Grading",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Quiz Grading": {
      "main": [
        [
          {
            "node": "Update Progress & Risk Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Progress & Risk Check": {
      "main": [
        [
          {
            "node": "Check Quiz Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Quiz Result": {
      "main": [
        [
          {
            "node": "Send Remedial Help",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Certificate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Analytics Schedule": {
      "main": [
        [
          {
            "node": "Fetch All Students",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Students": {
      "main": [
        [
          {
            "node": "AI Weekly Analytics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Weekly Analytics": {
      "main": [
        [
          {
            "node": "Send Admin Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}