[
  {
    "id": "hrOnboard01",
    "name": "Employee onboarding workflow",
    "nodes": [
      {
        "parameters": {
          "httpMethod": "POST",
          "path": "new-hire",
          "responseMode": "responseNode",
          "options": {}
        },
        "id": "h1",
        "name": "New hire (webhook)",
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2,
        "position": [
          0,
          0
        ],
        "webhookId": "hr-new-hire"
      },
      {
        "parameters": {
          "jsCode": "// Build a dated onboarding checklist for a new hire\nconst b = $input.first().json.body || {};\nconst missing = ['name', 'email', 'role', 'department', 'start_date', 'manager_email'].filter(k => !b[k]);\nif (missing.length) throw new Error('Missing: ' + missing.join(', '));\n\nconst start = new Date(b.start_date + 'T09:00:00Z');\nconst day = n => { const d = new Date(start); d.setUTCDate(d.getUTCDate() + n); return d.toISOString().slice(0, 10); };\n\n// Equipment and access by department. Edit this list to match your company.\nconst KIT = {\n  engineering: ['Laptop (developer spec)', 'Code repository and cloud access', 'VPN'],\n  marketing:   ['Laptop', 'Design tool licence', 'Analytics and ad accounts'],\n  sales:       ['Laptop', 'CRM licence', 'Phone plan'],\n  finance:     ['Laptop', 'Accounting system access', 'Bank portal (view only)'],\n};\nconst items = [...(KIT[String(b.department).toLowerCase()] || ['Laptop']), 'Email account', 'Chat account', 'Calendar invites for week one'];\n\nconst tasks = [\n  { owner: 'IT',      due: day(-5), task: 'Order equipment and create accounts: ' + items.join(', ') },\n  { owner: 'HR',      due: day(-3), task: 'Send the contract and required forms, and check the paperwork is complete' },\n  { owner: 'Manager', due: day(-2), task: 'Prepare the first-week schedule and 30-60-90 day goals' },\n  { owner: 'Manager', due: day(-2), task: 'Assign an onboarding buddy' },\n  { owner: 'HR',      due: day(0),  task: 'Welcome the new hire and give the benefits overview' },\n  { owner: 'Manager', due: day(5),  task: 'Hold the week-one check-in' },\n  { owner: 'HR',      due: day(30), task: 'Send the 30-day feedback survey' },\n];\nreturn [{ json: { ...b, first_name: String(b.name).split(' ')[0], items, tasks } }];"
        },
        "id": "h2",
        "name": "Build onboarding plan",
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          250,
          0
        ]
      },
      {
        "parameters": {
          "respondWith": "json",
          "responseBody": "={{ { \"status\": \"onboarding plan created\", \"name\": $json.name, \"start_date\": $json.start_date, \"tasks\": $json.tasks.length } }}",
          "options": {}
        },
        "id": "h3",
        "name": "Respond to HR",
        "type": "n8n-nodes-base.respondToWebhook",
        "typeVersion": 1.4,
        "position": [
          500,
          0
        ]
      },
      {
        "parameters": {
          "fromEmail": "hr@360automate.test",
          "toEmail": "={{ $json.email }}",
          "subject": "=Welcome to the team, {{ $json.first_name }}!",
          "emailFormat": "text",
          "text": "=Hi {{ $json.first_name }},\n\nWe are looking forward to you joining us as {{ $json.role }} on {{ $json.start_date }}. Your manager, {{ $json.manager_email }}, will send your first-week schedule before you start.\n\nYour laptop and accounts are being prepared. If anything is missing on day one, reply to this email.\n\nSee you soon,\nPeople team",
          "options": {
            "appendAttribution": false
          }
        },
        "id": "h4",
        "name": "Welcome the new hire",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          800,
          -300
        ],
        "credentials": {
          "smtp": {
            "id": "mailpitSmtp01",
            "name": "Local Mailpit SMTP"
          }
        }
      },
      {
        "parameters": {
          "fromEmail": "hr@360automate.test",
          "toEmail": "it@360automate.test",
          "subject": "=New hire: set up {{ $json.name }} ({{ $json.role }}) by {{ $json.tasks[0].due }}",
          "emailFormat": "text",
          "text": "=Please prepare the following for {{ $json.name }}, starting {{ $json.start_date }}:\n\n{{ $json.items.map(i => '- ' + i).join('\\n') }}\n\nManager: {{ $json.manager_email }}",
          "options": {
            "appendAttribution": false
          }
        },
        "id": "h5",
        "name": "Request equipment and accounts",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          800,
          -120
        ],
        "credentials": {
          "smtp": {
            "id": "mailpitSmtp01",
            "name": "Local Mailpit SMTP"
          }
        }
      },
      {
        "parameters": {
          "fromEmail": "hr@360automate.test",
          "toEmail": "={{ $json.manager_email }}",
          "subject": "=Onboarding checklist for {{ $json.name }} (starts {{ $json.start_date }})",
          "emailFormat": "text",
          "text": "=Your tasks for {{ $json.name }}:\n\n{{ $json.tasks.filter(t => t.owner === 'Manager').map(t => '- ' + t.task + ' (due ' + t.due + ')').join('\\n') }}\n\nHR and IT are handling the rest.",
          "options": {
            "appendAttribution": false
          }
        },
        "id": "h6",
        "name": "Send the manager's checklist",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          800,
          60
        ],
        "credentials": {
          "smtp": {
            "id": "mailpitSmtp01",
            "name": "Local Mailpit SMTP"
          }
        }
      },
      {
        "parameters": {
          "amount": 12,
          "unit": "seconds"
        },
        "id": "h7",
        "name": "Wait until the first day",
        "type": "n8n-nodes-base.wait",
        "typeVersion": 1.1,
        "position": [
          800,
          260
        ],
        "webhookId": "hr-wait-1"
      },
      {
        "parameters": {
          "fromEmail": "hr@360automate.test",
          "toEmail": "={{ $('Build onboarding plan').item.json.email }}",
          "subject": "=Your first week at a glance, {{ $('Build onboarding plan').item.json.first_name }}",
          "emailFormat": "text",
          "text": "=Hi {{ $('Build onboarding plan').item.json.first_name }},\n\nWelcome! Today you will meet the team and get set up. Your buddy will find you at 9:30. Tomorrow starts your role-specific training.\n\nPeople team",
          "options": {
            "appendAttribution": false
          }
        },
        "id": "h8",
        "name": "Day 1 email",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          1050,
          260
        ],
        "credentials": {
          "smtp": {
            "id": "mailpitSmtp01",
            "name": "Local Mailpit SMTP"
          }
        }
      },
      {
        "parameters": {
          "amount": 12,
          "unit": "seconds"
        },
        "id": "h9",
        "name": "Wait until week one ends",
        "type": "n8n-nodes-base.wait",
        "typeVersion": 1.1,
        "position": [
          1300,
          260
        ],
        "webhookId": "hr-wait-2"
      },
      {
        "parameters": {
          "fromEmail": "hr@360automate.test",
          "toEmail": "={{ $('Build onboarding plan').item.json.manager_email }}",
          "subject": "=Week 1 check-in: {{ $('Build onboarding plan').item.json.name }}",
          "emailFormat": "text",
          "text": "=It is the end of week one for {{ $('Build onboarding plan').item.json.name }}. Please ask:\n\n- Do you have everything you need to do your job?\n- Is anything unclear about your goals?\n- Who have you met, and who should you meet next?\n\nA short note back to HR helps us improve onboarding.",
          "options": {
            "appendAttribution": false
          }
        },
        "id": "h10",
        "name": "Week 1 check-in",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          1550,
          260
        ],
        "credentials": {
          "smtp": {
            "id": "mailpitSmtp01",
            "name": "Local Mailpit SMTP"
          }
        }
      },
      {
        "parameters": {
          "amount": 12,
          "unit": "seconds"
        },
        "id": "h11",
        "name": "Wait until day 30",
        "type": "n8n-nodes-base.wait",
        "typeVersion": 1.1,
        "position": [
          1800,
          260
        ],
        "webhookId": "hr-wait-3"
      },
      {
        "parameters": {
          "fromEmail": "hr@360automate.test",
          "toEmail": "={{ $('Build onboarding plan').item.json.email }}",
          "subject": "=30 days in: how is it going, {{ $('Build onboarding plan').item.json.first_name }}?",
          "emailFormat": "text",
          "text": "=Hi {{ $('Build onboarding plan').item.json.first_name }},\n\nYou have been with us for a month. Two minutes of feedback helps us make onboarding better for the next person:\nhttps://example.com/onboarding-survey\n\nThank you,\nPeople team",
          "options": {
            "appendAttribution": false
          }
        },
        "id": "h12",
        "name": "30-day survey",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          2050,
          260
        ],
        "credentials": {
          "smtp": {
            "id": "mailpitSmtp01",
            "name": "Local Mailpit SMTP"
          }
        }
      }
    ],
    "connections": {
      "New hire (webhook)": {
        "main": [
          [
            {
              "node": "Build onboarding plan",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Build onboarding plan": {
        "main": [
          [
            {
              "node": "Respond to HR",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Respond to HR": {
        "main": [
          [
            {
              "node": "Welcome the new hire",
              "type": "main",
              "index": 0
            },
            {
              "node": "Request equipment and accounts",
              "type": "main",
              "index": 0
            },
            {
              "node": "Send the manager's checklist",
              "type": "main",
              "index": 0
            },
            {
              "node": "Wait until the first day",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Wait until the first day": {
        "main": [
          [
            {
              "node": "Day 1 email",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Day 1 email": {
        "main": [
          [
            {
              "node": "Wait until week one ends",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Wait until week one ends": {
        "main": [
          [
            {
              "node": "Week 1 check-in",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Week 1 check-in": {
        "main": [
          [
            {
              "node": "Wait until day 30",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Wait until day 30": {
        "main": [
          [
            {
              "node": "30-day survey",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    },
    "settings": {
      "executionOrder": "v1"
    },
    "active": false
  }
]