{
  "id": "cRmLB3c1dzi4VTNG",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Fee Collection, Defaulter Follow-Up & Receipt Automation System",
  "tags": [],
  "nodes": [
    {
      "id": "65353bf1-daf4-45fd-bf8c-831ce41598fa",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        304
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "8c53a79e-6ea8-4a4c-ba39-b5b51e0f0c53",
      "name": "Section: Payment Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        928
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "ff19fdab-03c6-4f7a-b829-15c6f5916494",
      "name": "Section: Record Lookup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        912
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "6febb2dc-b167-4bfd-838d-0c72125ba255",
      "name": "Section: Receipt",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        912
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "93b3e64c-092b-4d48-ac3f-ee3bfceb5ba2",
      "name": "Section: Cron Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        1744
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "585053f2-7582-401d-bd76-6e362d495b92",
      "name": "Section: AI Reminders",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        1744
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "19c6cdf4-e7c6-4aaf-8c5b-005448d22975",
      "name": "Section: Admin Report",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        1744
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "627fe7f5-4aa9-460a-960f-871b74d6350e",
      "name": "Security Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2480,
        2512
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "d2f822a2-b854-44e7-a0fb-8705c87c4d1a",
      "name": "Receive Razorpay Payment Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        160,
        1232
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "f49103c3-a39a-45e6-ae5e-be5c1d8bff90",
      "name": "Parse and Validate Payment Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        432,
        1232
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "2f461d47-4104-4290-9f8e-1a8450983219",
      "name": "Look Up Student Record in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        736,
        1232
      ],
      "parameters": {},
      "typeVersion": 4
    },
    {
      "id": "7593942c-f31b-4cef-b1c5-e8de662de1e9",
      "name": "Calculate Updated Fee Balance",
      "type": "n8n-nodes-base.code",
      "position": [
        1008,
        1232
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "f1c82969-1eda-4934-ab3a-65fee9ad56d7",
      "name": "Update Student Balance in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1280,
        1232
      ],
      "parameters": {},
      "typeVersion": 4
    },
    {
      "id": "d5a4648b-2eb8-48f0-8ab9-21018b51bc2a",
      "name": "Build Branded HTML Receipt",
      "type": "n8n-nodes-base.code",
      "position": [
        1664,
        1232
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "8afb4114-5dd1-4b38-80d7-c64b6db68277",
      "name": "Convert Receipt HTML to PDF",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1936,
        1232
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fec827cb-c855-45ee-b09e-d4a76cc73768",
      "name": "Email PDF Receipt to Parent",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2224,
        1056
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "ca689da4-d6c3-48fc-9284-6565cca85f3d",
      "name": "Log Payment to Audit Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2480,
        1232
      ],
      "parameters": {},
      "typeVersion": 4
    },
    {
      "id": "403e31d1-5c97-4cc5-a09c-a07ce2a6748b",
      "name": "Every Monday 9 AM \u2014 Check Defaulters",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        272,
        1968
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "ad6912b1-1a92-4369-8ca8-f4bf669014bb",
      "name": "Fetch All Student Records",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        544,
        1968
      ],
      "parameters": {},
      "typeVersion": 4
    },
    {
      "id": "5be8a60b-72ae-457a-b1ea-bfd72fd549bb",
      "name": "Identify and Tier Defaulters",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        1968
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "aa1e5110-87f0-4e61-8885-6be623fac91b",
      "name": "Any Defaulters Found?",
      "type": "n8n-nodes-base.if",
      "position": [
        1088,
        1968
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "e990afaa-3bdc-476b-ba39-f633787108c7",
      "name": "AI Draft Personalised Fee Reminder",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1360,
        1968
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c82ce88a-88d2-4fce-876c-c5b98d49fbb3",
      "name": "Merge AI Message with Defaulter Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1712,
        1968
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "e9a393f8-608d-4233-a220-1070442d3cc4",
      "name": "Email Fee Reminder to Parent",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2224,
        2192
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "f120c45c-1062-48cc-8a3d-22a4773c4e1a",
      "name": "Log Reminder Sent to Audit Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2464,
        1968
      ],
      "parameters": {},
      "typeVersion": 4
    },
    {
      "id": "ed270889-a1d2-4a8f-ae23-893e6bac5ad6",
      "name": "Send Commentary to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2224,
        1376
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "41b5f157-70f3-4968-a5bf-ca73ca6d652b",
      "name": "Section: Error Handler",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        2384
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "28958eca-bf1e-436e-ae96-02a8433706e6",
      "name": "On Workflow Error",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        336,
        2592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2af6485f-883d-43a4-9156-43245404340e",
      "name": "Slack \u2014 Send Workflow Error Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        592,
        2592
      ],
      "parameters": {},
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "1d67d03e-939e-4cea-b5b9-cd38e8bba4a6",
  "nodeGroups": [],
  "connections": {
    "On Workflow Error": {
      "main": [
        [
          {
            "node": "Slack \u2014 Send Workflow Error Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any Defaulters Found?": {
      "main": [
        [],
        [
          {
            "node": "AI Draft Personalised Fee Reminder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Student Records": {
      "main": [
        [
          {
            "node": "Identify and Tier Defaulters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Branded HTML Receipt": {
      "main": [
        [
          {
            "node": "Convert Receipt HTML to PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Receipt HTML to PDF": {
      "main": [
        [
          {
            "node": "Email PDF Receipt to Parent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Commentary to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email PDF Receipt to Parent": {
      "main": [
        [
          {
            "node": "Log Payment to Audit Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Commentary to Telegram": {
      "main": [
        [
          {
            "node": "Log Payment to Audit Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Fee Reminder to Parent": {
      "main": [
        [
          {
            "node": "Log Reminder Sent to Audit Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Identify and Tier Defaulters": {
      "main": [
        [
          {
            "node": "Any Defaulters Found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Updated Fee Balance": {
      "main": [
        [
          {
            "node": "Update Student Balance in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Look Up Student Record in Sheets": {
      "main": [
        [
          {
            "node": "Calculate Updated Fee Balance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Razorpay Payment Webhook": {
      "main": [
        [
          {
            "node": "Parse and Validate Payment Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Student Balance in Sheets": {
      "main": [
        [
          {
            "node": "Build Branded HTML Receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Draft Personalised Fee Reminder": {
      "main": [
        [
          {
            "node": "Merge AI Message with Defaulter Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse and Validate Payment Payload": {
      "main": [
        [
          {
            "node": "Look Up Student Record in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge AI Message with Defaulter Data": {
      "main": [
        [
          {
            "node": "Email Fee Reminder to Parent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log Reminder Sent to Audit Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Monday 9 AM \u2014 Check Defaulters": {
      "main": [
        [
          {
            "node": "Fetch All Student Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}