{
  "name": "Build an OpenAI HR assistant for Telegram attendance and salary reports",
  "nodes": [
    {
      "id": "bd1",
      "name": "Main_Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2600,
        800
      ],
      "parameters": {
        "width": 386,
        "height": 516,
        "content": "### 🤖 HR Automated System\n\n#### How it works\n1. **Input:** Receives Telegram messages from employees.\n2. **AI Analysis:** Classifies intent (Attendance, Report, or Registration) using OpenAI.\n3. **Exe"
      }
    },
    {
      "id": "bd2",
      "name": "Section_Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2160,
        1040
      ],
      "parameters": {
        "width": 1900,
        "height": 560,
        "content": "## 1. Input & Intent Classification\nReceives messages, maintains chat history, and uses AI to determine if the user is a new employee, recording a transaction, or asking for a report."
      }
    },
    {
      "id": "bd3",
      "name": "Section_Onboarding",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -120
      ],
      "parameters": {
        "width": 2100,
        "height": 700,
        "content": "## 2. New Employee Onboarding\nHandles the conversational flow to register new staff. Collects Name, ID, Salary, etc., validates the JSON data, and saves to the database."
      }
    },
    {
      "id": "bd4",
      "name": "Section_Transactions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        640
      ],
      "parameters": {
        "width": 1700,
        "height": 950,
        "content": "## 3. Transaction Logic\nHandles existing employees. Logs Attendance, calculates 'Early Departure' penalties based on work hours, and records Salary Advances."
      }
    },
    {
      "id": "bd5",
      "name": "Section_Reports",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        1720
      ],
      "parameters": {
        "width": 1200,
        "height": 450,
        "content": "## 4. Financial Reporting\nFetches employee salary and movement history to calculate net pay (deducting absence/penalties and adding overtime)."
      }
    },
    {
      "id": "bd6",
      "name": "Section_Daily",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2160,
        1680
      ],
      "parameters": {
        "width": 2000,
        "height": 450,
        "content": "## 5. Daily Scheduled Jobs\nRuns automatically (e.g., at 1:00 PM) to compare today's logs against the full employee list and report who is absent."
      }
    },
    {
      "id": "e91f272e-19ae-4903-bc5f-8b012419d324",
      "name": "Telegram_Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -2112,
        1136
      ]
    },
    {
      "id": "9d8e575c-f625-42c9-a16c-aa53e355cbf5",
      "name": "Memory_Chat",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        1424
      ]
    },
    {
      "id": "343f675f-58ab-409e-b0f6-b965b80c308d",
      "name": "Msg_Attendance_Success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1968,
        1488
      ]
    },
    {
      "id": "c1c37e47-d9b8-4358-92c5-d62e194fb9c3",
      "name": "Parse_AI_Response",
      "type": "n8n-nodes-base.code",
      "position": [
        -624,
        1200
      ]
    },
    {
      "id": "05d87ded-fb5b-499e-95fe-43e0f013a877",
      "name": "Lookup_Employee",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -80,
        1120
      ]
    },
    {
      "id": "8905ab06-d258-404c-b9d3-ee60ef5a29ce",
      "name": "Log_Transaction",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1440,
        1488
      ]
    },
    {
      "id": "922eae56-0829-4191-9998-6887c5c85a85",
      "name": "Check_Employee_Found",
      "type": "n8n-nodes-base.if",
      "position": [
        144,
        1120
      ]
    },
    {
      "id": "c15a466a-1e19-427a-9e66-013a45a139de",
      "name": "Msg_Employee_Not_Found",
      "type": "n8n-nodes-base.telegram",
      "position": [
        320,
        1200
      ]
    },
    {
      "id": "1007f64f-4269-4558-9cee-a7cf6d57050c",
      "name": "Route_Intent",
      "type": "n8n-nodes-base.switch",
      "position": [
        -400,
        1200
      ]
    },
    {
      "id": "cd13e552-f0bb-4097-96c6-431cefc5f086",
      "name": "Memory_Analyst",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1696,
        2080
      ]
    },
    {
      "id": "bcc064a5-7e14-40cb-8948-1a03785c1c53",
      "name": "Msg_Analysis_Report",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1984,
        1808
      ]
    },
    {
      "id": "930fd357-49f1-49f4-b70a-d46360b31b95",
      "name": "Agent_Classifier",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1120,
        1184
      ]
    },
    {
      "id": "51a67c9b-73e9-44ac-9c77-bdbf56ee9aff",
      "name": "Agent_Financial",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1552,
        1808
      ]
    },
    {
      "id": "28d59d05-42ae-4325-aa42-edfda12a4da3",
      "name": "Msg_Ask_New_Emp_Data",
      "type": "n8n-nodes-base.telegram",
      "position": [
        208,
        -64
      ]
    },
    {
      "id": "83bce609-761a-46e0-9d87-dd17fdec2e1e",
      "name": "Memory_Onboarding",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        992,
        528
      ]
    },
    {
      "id": "7d49dd78-9d34-40cb-b865-dab0bb81e9bf",
      "name": "Agent_Onboarding",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        928,
        288
      ]
    },
    {
      "id": "08e69c55-7eca-445e-9cc5-b48d926930cb",
      "name": "Validate_New_Emp_JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        1280,
        288
      ]
    },
    {
      "id": "4ebe2121-1ad1-47bd-b187-c625871218ea",
      "name": "Register_New_Emp",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1744,
        288
      ]
    },
    {
      "id": "183fbd9c-8ff9-44ac-9b48-e1b07b739896",
      "name": "Msg_Registration_Success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2048,
        288
      ]
    },
    {
      "id": "4c353579-e15a-4ee6-9736-bd074627c258",
      "name": "Model_Onboarding",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        832,
        528
      ]
    },
    {
      "id": "b34e24ea-45f1-4321-9ee0-3823dae1d2d1",
      "name": "Model_Classifier",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1152,
        1408
      ]
    },
    {
      "id": "e281d6a4-1f02-4d1a-8f16-adddc01a7b6a",
      "name": "Model_Analyst",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1504,
        2080
      ]
    },
    {
      "id": "ef84526d-6f92-44c7-b73e-cff9618c614b",
      "name": "Filter_Valid_Data",
      "type": "n8n-nodes-base.filter",
      "position": [
        1488,
        288
      ]
    },
    {
      "id": "77d625e6-045d-45f7-8ad2-612a47cacec4",
      "name": "Route_New_vs_Existing",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1840,
        1120
      ]
    },
    {
      "id": "04cf0510-c901-4cce-ac4f-67a80a735b00",
      "name": "Fetch_Salary",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1024,
        1808
      ]
    },
    {
      "id": "a80dfc13-348d-4bf4-99f9-b5a3e28ebe62",
      "name": "Fetch_Movement_History",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1312,
        1808
      ]
    },
    {
      "id": "fbdfb942-abec-4873-8d96-ce9d19e8a267",
      "name": "Model_Gemini",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1328,
        1408
      ]
    },
    {
      "id": "1f589c8f-e9dd-4457-9f8f-30eda9b24703",
      "name": "Route_Action_Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        512,
        1088
      ]
    },
    {
      "id": "6b9d65db-09a9-4a82-b726-432d7807904b",
      "name": "Calc_Departure_Stats",
      "type": "n8n-nodes-base.code",
      "position": [
        1456,
        784
      ]
    },
    {
      "id": "e25a56b9-b576-442a-bffa-7726d6db78ed",
      "name": "Get_Arrival_Time",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1200,
        784
      ]
    },
    {
      "id": "8ceb01d2-bc69-448b-854d-ffb0d4142099",
      "name": "Log_Departure",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1728,
        784
      ]
    },
    {
      "id": "3d60b776-91ee-4568-9c23-3c12a65a7c5d",
      "name": "Msg_Departure_Success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1984,
        784
      ]
    },
    {
      "id": "1537466e-940c-4788-8966-c0019d116a38",
      "name": "Msg_Advance_Success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1968,
        1104
      ]
    },
    {
      "id": "a5721408-c091-4591-95f4-d5a2c421ed78",
      "name": "Log_Advance",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1424,
        1104
      ]
    },
    {
      "id": "bfce569a-1307-44b8-b0ec-bd011b2392c4",
      "name": "Daily_Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2080,
        1904
      ]
    },
    {
      "id": "5409f06a-f95d-43c7-830e-239ffb8ccf05",
      "name": "Filter_Today_Attendance",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1200,
        1760
      ]
    },
    {
      "id": "2f455047-b858-44b8-89e2-a2f41d3200dc",
      "name": "Fetch_All_Employees",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1424,
        2048
      ]
    },
    {
      "id": "2191b104-2953-41ee-ade4-9de610e35ad2",
      "name": "Fetch_Today_Logs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1552,
        1744
      ]
    },
    {
      "id": "c0a98dc7-a160-408c-abd5-b9ce5732284a",
      "name": "Calc_Absentees",
      "type": "n8n-nodes-base.code",
      "position": [
        -496,
        1904
      ]
    },
    {
      "id": "05f58671-0c85-411a-b898-4296df21eed8",
      "name": "Msg_Absentee_Report",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -176,
        1904
      ]
    },
    {
      "id": "2a47083b-fddf-4034-baaf-6489650aed3a",
      "name": "Merge_Lists",
      "type": "n8n-nodes-base.merge",
      "position": [
        -784,
        1904
      ]
    }
  ],
  "connections": {
    "Log_Advance": {
      "main": [
        [
          {
            "node": "Msg_Advance_Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Memory_Chat": {
      "ai_memory": [
        [
          {
            "node": "Agent_Classifier",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Merge_Lists": {
      "main": [
        [
          {
            "node": "Calc_Absentees",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_Salary": {
      "main": [
        [
          {
            "node": "Fetch_Movement_History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model_Gemini": {
      "ai_languageModel": [
        []
      ]
    },
    "Route_Intent": {
      "main": [
        [
          {
            "node": "Lookup_Employee",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch_Salary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily_Trigger": {
      "main": [
        [
          {
            "node": "Fetch_Today_Logs",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch_All_Employees",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log_Departure": {
      "main": [
        [
          {
            "node": "Msg_Departure_Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model_Analyst": {
      "ai_languageModel": [
        [
          {
            "node": "Agent_Financial",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Calc_Absentees": {
      "main": [
        [
          {
            "node": "Msg_Absentee_Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Memory_Analyst": {
      "ai_memory": [
        [
          {
            "node": "Agent_Financial",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Agent_Financial": {
      "main": [
        [
          {
            "node": "Msg_Analysis_Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log_Transaction": {
      "main": [
        [
          {
            "node": "Msg_Attendance_Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup_Employee": {
      "main": [
        [
          {
            "node": "Check_Employee_Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent_Classifier": {
      "main": [
        [
          {
            "node": "Parse_AI_Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent_Onboarding": {
      "main": [
        [
          {
            "node": "Validate_New_Emp_JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_Today_Logs": {
      "main": [
        [
          {
            "node": "Filter_Today_Attendance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get_Arrival_Time": {
      "main": [
        [
          {
            "node": "Calc_Departure_Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model_Classifier": {
      "ai_languageModel": [
        [
          {
            "node": "Agent_Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Model_Onboarding": {
      "ai_languageModel": [
        [
          {
            "node": "Agent_Onboarding",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Register_New_Emp": {
      "main": [
        [
          {
            "node": "Msg_Registration_Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram_Trigger": {
      "main": [
        [
          {
            "node": "Route_New_vs_Existing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter_Valid_Data": {
      "main": [
        [
          {
            "node": "Register_New_Emp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Memory_Onboarding": {
      "ai_memory": [
        [
          {
            "node": "Agent_Onboarding",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Parse_AI_Response": {
      "main": [
        [
          {
            "node": "Route_Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route_Action_Type": {
      "main": [
        [
          {
            "node": "Get_Arrival_Time",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log_Advance",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log_Transaction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_All_Employees": {
      "main": [
        [
          {
            "node": "Merge_Lists",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Calc_Departure_Stats": {
      "main": [
        [
          {
            "node": "Log_Departure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check_Employee_Found": {
      "main": [
        [
          {
            "node": "Route_Action_Type",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Msg_Employee_Not_Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Msg_Ask_New_Emp_Data": {
      "main": [
        [
          {
            "node": "Agent_Onboarding",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route_New_vs_Existing": {
      "main": [
        [
          {
            "node": "Msg_Ask_New_Emp_Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Agent_Onboarding",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Agent_Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate_New_Emp_JSON": {
      "main": [
        [
          {
            "node": "Filter_Valid_Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_Movement_History": {
      "main": [
        [
          {
            "node": "Agent_Financial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter_Today_Attendance": {
      "main": [
        [
          {
            "node": "Merge_Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}