{
  "name": "M09 - Safe Data Mapping & Expressions",
  "nodes": [
    {
      "id": "1bbe8d79-6177-4a23-a865-6c510597a594",
      "parameters": {},
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        220,
        300
      ]
    },
    {
      "id": "2fae8e67-cfb5-477c-a2ae-825756f3d4fe",
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "record_id",
              "value": "={{ $json.record_id }}",
              "type": "string"
            },
            {
              "name": "clean_email",
              "value": "={{ typeof $json.contact?.email === \"string\" ? $json.contact.email.trim().toLowerCase() : \"\" }}",
              "type": "string"
            },
            {
              "name": "iso_date",
              "value": "={{ DateTime.fromFormat(String($json.date ?? \"\"), \"MM/dd/yyyy\").toFormat(\"yyyy-MM-dd\") }}",
              "type": "string"
            }
          ]
        }
      },
      "name": "Clean & Format Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        300
      ]
    },
    {
      "id": "16100936-1f02-46e4-acb4-c5524b8fa6d9",
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.clean_email !== \"\" && Boolean($json.record_id) }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ]
        }
      },
      "name": "Check Required Email",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        700,
        300
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Clean & Format Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Format Fields": {
      "main": [
        [
          {
            "node": "Check Required Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "n8n-learning-hub"
  }
}