{
  "name": "Sync Entra user to Zammad user",
  "nodes": [
    {
      "id": "0007443e-b0d4-4f98-a613-3ec7c2842aa3",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2140,
        140
      ]
    },
    {
      "id": "2b285a4f-7e39-411b-88b9-cb55c5cf62e3",
      "name": "Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1700,
        380
      ],
      "parameters": {
        "width": 1635.910561370123,
        "height": 329.7269624573379,
        "content": "## Select Entra Users in a named Entra Group that should be synced to Zammad\n\n\n\n"
      }
    },
    {
      "id": "929e529e-a4a3-4663-b9dc-e2300a860fed",
      "name": "Get Groups from Entra",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1660,
        480
      ]
    },
    {
      "id": "3390b2ed-6070-429c-bc1a-f0ab324117c7",
      "name": "Remove outer Array",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1400,
        480
      ]
    },
    {
      "id": "b0e9531a-7fc0-4de0-8ec5-4be476b18a26",
      "name": "Select Entra Zammad default Group",
      "type": "n8n-nodes-base.if",
      "position": [
        -1120,
        480
      ]
    },
    {
      "id": "1be2a745-aea3-46ec-ab84-be2e39358b95",
      "name": "Remove outer Array from Entra User",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -700,
        460
      ]
    },
    {
      "id": "3b1fc962-7546-4bad-b637-e018649a0652",
      "name": "Zammad Univeral User Object",
      "type": "n8n-nodes-base.set",
      "position": [
        -240,
        440
      ]
    },
    {
      "id": "9e36e6a9-cf56-4548-a1af-b1e33dbc61dd",
      "name": "Get Zammad Users",
      "type": "n8n-nodes-base.zammad",
      "position": [
        -1020,
        140
      ]
    },
    {
      "id": "c9a342b1-b5f2-4d31-9737-15f145dc7318",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        240,
        140
      ]
    },
    {
      "id": "a04ebfea-e5fe-4903-841a-8ef29d75ff1a",
      "name": "Get Members of the default group",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -880,
        460
      ]
    },
    {
      "id": "2e68992e-3080-41fd-9aae-c44dc60dc3b0",
      "name": "Find new Zammad Users",
      "type": "n8n-nodes-base.compareDatasets",
      "position": [
        240,
        460
      ]
    },
    {
      "id": "86dc2c72-d54a-40a9-a64b-fc0bde9a2387",
      "name": "Update Zammad User",
      "type": "n8n-nodes-base.zammad",
      "position": [
        560,
        140
      ]
    },
    {
      "id": "bc883c6d-ec53-4854-824a-bd76b28077d2",
      "name": "Create Zammad User",
      "type": "n8n-nodes-base.zammad",
      "position": [
        580,
        540
      ]
    },
    {
      "id": "3b57e278-e755-407c-b261-7fe76ce82bb5",
      "name": "Deactivate Zammad User",
      "type": "n8n-nodes-base.zammad",
      "position": [
        600,
        840
      ]
    },
    {
      "id": "cdaf8b51-9b4c-4ad0-b8f0-c6921849ed4c",
      "name": "Find removed Users",
      "type": "n8n-nodes-base.compareDatasets",
      "position": [
        240,
        880
      ]
    },
    {
      "id": "9b37b75e-d694-441e-b5a5-8abeccbf4ed7",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -500,
        460
      ]
    },
    {
      "id": "13ac19a6-6689-4e75-86d4-02ec1c0c64cd",
      "name": "Select only active Users and entra_obect_type=\"user\"",
      "type": "n8n-nodes-base.if",
      "position": [
        -220,
        140
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Zammad Univeral User Object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Update Zammad User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Zammad Users": {
      "main": [
        [
          {
            "node": "Select only active Users and entra_obect_type=\"user\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find removed Users": {
      "main": [
        [
          {
            "node": "Deactivate Zammad User",
            "type": "main",
            "index": 0
          }
        ],
        [],
        []
      ]
    },
    "Remove outer Array": {
      "main": [
        [
          {
            "node": "Select Entra Zammad default Group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find new Zammad Users": {
      "main": [
        [],
        [],
        [],
        [
          {
            "node": "Create Zammad User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Groups from Entra": {
      "main": [
        [
          {
            "node": "Remove outer Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zammad Univeral User Object": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          },
          {
            "node": "Find new Zammad Users",
            "type": "main",
            "index": 1
          },
          {
            "node": "Find removed Users",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get Members of the default group": {
      "main": [
        [
          {
            "node": "Remove outer Array from Entra User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Entra Zammad default Group": {
      "main": [
        [
          {
            "node": "Get Members of the default group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get Zammad Users",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Groups from Entra",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove outer Array from Entra User": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select only active Users and entra_obect_type=\"user\"": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Find new Zammad Users",
            "type": "main",
            "index": 0
          },
          {
            "node": "Find removed Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}