{
  "id": "fgDemoLeads01",
  "name": "Fork Guy SAMPLE - lead-intake",
  "active": false,
  "nodes": [
    {
      "parameters": {},
      "id": "manual",
      "name": "Run demo manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return [{json:{\"leads\":[{\"name\":\"Alex Example\",\"email\":\" ALEX@example.test \",\"brief\":\"Sample website inquiry\"},{\"name\":\"Duplicate Alex\",\"email\":\"alex@example.test\",\"brief\":\"Repeated fixture\"},{\"name\":\"Invalid Example\",\"email\":\"invalid\",\"brief\":\"Rejected fixture\"},{\"name\":\"Sam Example\",\"email\":\"sam@example.test\",\"brief\":\"Sample automation inquiry\",\"simulateNotificationFailure\":true},{\"name\":\"\",\"email\":\"missing@example.test\",\"brief\":\"Rejected fixture\"}]}}];"
      },
      "id": "fixture",
      "name": "Fictional fixture",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const leads = $input.first().json.leads;\nif (!Array.isArray(leads) || leads.length > 100) throw new Error('Expected at most 100 sample leads');\nconst contacts = new Map();\nconst results = [];\nconst notifications = [];\nfor (const lead of leads) {\n  const name = typeof lead.name === 'string' ? lead.name.trim() : '';\n  const email = typeof lead.email === 'string' ? lead.email.trim().toLowerCase() : '';\n  const brief = typeof lead.brief === 'string' ? lead.brief.trim() : '';\n  if (!name || name.length > 120 || !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email) || email.length > 254 || !brief || brief.length > 2000) {\n    results.push({ status: 'rejected', reason: 'Invalid required fields' });\n    continue;\n  }\n  if (contacts.has(email)) {\n    results.push({ status: 'duplicate', contactId: contacts.get(email).id });\n    continue;\n  }\n  // This Map is a CRM STUB. It resets on every execution; no external writes occur.\n  const contact = { id: `demo-${contacts.size + 1}`, name, email, brief };\n  contacts.set(email, contact);\n  try {\n    if (lead.simulateNotificationFailure === true) throw new Error('Simulated notifier outage');\n    notifications.push({ contactId: contact.id, message: 'New sample inquiry saved' });\n    results.push({ status: 'created', contactId: contact.id, notification: 'recorded-locally' });\n  } catch {\n    results.push({ status: 'created', contactId: contact.id, notification: 'failed-simulation' });\n  }\n}\nreturn [{ json: { demonstration: true, persistence: 'memory for this execution only', contacts: [...contacts.values()], notifications, results } }];\n"
      },
      "id": "logic",
      "name": "Validate - CRM stub - Notification stub",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        500,
        0
      ]
    }
  ],
  "connections": {
    "Run demo manually": {
      "main": [
        [
          {
            "node": "Fictional fixture",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fictional fixture": {
      "main": [
        [
          {
            "node": "Validate - CRM stub - Notification stub",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}
