{
  "name": "Service Intake Demo by Ali Elgharabawi",
  "nodes": [
    {
      "id": "8c0ba204-a973-40a9-b86b-1b3f7e7b11f1",
      "name": "Run Sample Intake",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        260,
        300
      ],
      "parameters": {}
    },
    {
      "id": "2317c760-68be-445d-8518-968568d778a9",
      "name": "Fictional Intake Records",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        500,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// Fictional sample data only. This node performs no external calls.\nconst records = [\n  { requestId: 'DEMO-001', name: '  Jordan   Reed ', email: ' JORDAN.REED@example.com ', service: ' Website ', priority: 'Normal', message: ' A five-page service website. ' },\n  { requestId: 'DEMO-002', name: 'Casey Lane', email: 'not-an-email', service: 'automation', priority: 'normal', message: 'Review a service intake process.' },\n  { requestId: 'DEMO-003', name: 'Jordan Reed', email: 'jordan.reed@example.com', service: 'website', priority: 'normal', message: 'Repeated inquiry for the same service.' }\n];\nreturn records.map(json => ({ json }));"
      },
      "notes": "Three fictional records using example.com addresses. Manual sample only.",
      "notesInFlow": true
    },
    {
      "id": "3d8bb2b0-d232-4ac1-a842-12dff4b12dc6",
      "name": "Normalize Validate and Classify",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        760,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// Demonstration: duplicates are checked within this execution only.\n// The route field labels the result; no messages are sent or systems updated.\nconst clean = value => String(value ?? '').trim().replace(/\\s+/g, ' ');\nconst queues = { website: 'website-design', app: 'app-prototype', automation: 'workflow-review' };\nconst seen = new Map();\nreturn $input.all().map((item, index) => {\n  const source = item.json || {};\n  const record = {\n    requestId: clean(source.requestId) || 'ITEM-' + (index + 1),\n    name: clean(source.name),\n    email: clean(source.email).toLowerCase(),\n    service: clean(source.service).toLowerCase(),\n    priority: clean(source.priority).toLowerCase() || 'normal',\n    message: clean(source.message)\n  };\n  const errors = [];\n  if (!record.name) errors.push('Name is required');\n  if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(record.email)) errors.push('A valid email format is required');\n  if (!Object.hasOwn(queues, record.service)) errors.push('Service must be website, app or automation');\n  if (!['normal', 'urgent'].includes(record.priority)) errors.push('Priority must be normal or urgent');\n  if (!record.message) errors.push('A request message is required');\n  let route = 'review';\n  let assignedQueue = 'manual-review';\n  let duplicateOf = null;\n  if (errors.length === 0) {\n    const duplicateKey = record.email + '|' + record.service;\n    if (seen.has(duplicateKey)) {\n      route = 'duplicate';\n      assignedQueue = 'duplicate-review';\n      duplicateOf = seen.get(duplicateKey);\n    } else {\n      route = 'ready';\n      assignedQueue = queues[record.service];\n      seen.set(duplicateKey, record.requestId);\n    }\n  }\n  return { json: { ...record, route, assignedQueue, errors, duplicateOf, sampleData: true }, pairedItem: { item: index } };\n});"
      },
      "notes": "Returns ready, review or duplicate as a route field. Duplicates are scoped to this batch. No external integrations or durable storage.",
      "notesInFlow": true
    }
  ],
  "connections": {
    "Run Sample Intake": {
      "main": [
        [
          {
            "node": "Fictional Intake Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fictional Intake Records": {
      "main": [
        [
          {
            "node": "Normalize Validate and Classify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}
