{
  "id": "5BjmEGmHyXKxm61l",
  "name": "parse encoded WebHook for amoCRM",
  "tags": [],
  "nodes": [
    {
      "id": "57ecb69b-4f2d-4b26-8534-84288c654ffa",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -220,
        0
      ],
      "parameters": {
        "path": "72b4b381-4474-46dc-af61-c7c0c49b1ab1",
        "options": {
          "rawBody": true
        },
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "540f10af-a63c-4c4b-83d3-d759ed63854e",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "edf41443-4225-47ab-a419-8449ee8589c7",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        200,
        0
      ],
      "parameters": {
        "jsCode": "const result = {};\nvar str = $input.all(0)[0].json.data;\nstr.split('&').forEach(pair => {\n    const [key, value] = pair.split('=');\n    let currentObj = result;\n\n    const keys = key.split('%5B').map(k => k.replace(/%5D/g, ''));\n    keys.forEach((k, index) => {\n        if (index === keys.length - 1) {\n            currentObj[k] = decodeURIComponent(value || '');\n        } else {\n            if (!currentObj[k]) {\n                currentObj[k] = {};\n            }\n            currentObj = currentObj[k];\n        }\n    });\n});\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2e0037b6-fc11-4fa7-8a8e-b0f0fbe53c4d",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        400,
        0
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "leads.update['0'].custom_fields"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f73a89ca-a645-4f08-a474-8b25ccb8bf64",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}