{
  "name": "M13 - Tally Intake & Validation Blueprint",
  "nodes": [
    {
      "id": "4a5e256f-d820-43ee-a75f-f241b83f70d8",
      "parameters": {
        "httpMethod": "POST",
        "path": "tally-workshop-intake",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Tally Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "webhookId": "fbd077c5-457d-4b0d-a682-18c21999aea9"
    },
    {
      "id": "7d5dd6bd-0cf1-4d25-a00e-ae2af6559046",
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "submission_id",
              "value": "={{ $json.body?.data?.submissionId ?? \"MANUAL-\" + $now.toMillis() }}",
              "type": "string"
            },
            {
              "name": "full_name",
              "value": "={{ ($json.body?.data?.fields?.find(f => f.label === \"الاسم\")?.value ?? \"\").toString().trim() }}",
              "type": "string"
            },
            {
              "name": "clean_email",
              "value": "={{ ($json.body?.data?.fields?.find(f => f.label === \"البريد\")?.value ?? \"\").toString().trim().toLowerCase() }}",
              "type": "string"
            },
            {
              "name": "category",
              "value": "={{ ($json.body?.data?.fields?.find(f => f.label === \"الفئة\")?.value ?? \"\").toString().trim() }}",
              "type": "string"
            }
          ]
        }
      },
      "name": "Normalize Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        480,
        300
      ]
    },
    {
      "id": "1fcbd6d6-3439-4351-acd2-ce995ef32085",
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true
          },
          "conditions": [
            {
              "leftValue": "={{ $json.full_name !== \"\" && $json.clean_email !== \"\" }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            },
            {
              "leftValue": "={{ [\"Design\", \"Data\", \"Content\"].includes($json.category) }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "name": "Validate Rules",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        720,
        300
      ]
    },
    {
      "id": "0d6c0df2-4b19-480c-afd2-965f97a17e7c",
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"received\": true, \"submission_id\": $json.submission_id } }}",
        "options": {
          "responseCode": 200
        }
      },
      "name": "Respond 200 to Tally",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1160,
        300
      ]
    }
  ],
  "connections": {
    "Tally Webhook": {
      "main": [
        [
          {
            "node": "Normalize Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Fields": {
      "main": [
        [
          {
            "node": "Validate Rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "n8n-learning-hub"
  }
}