{
  "updatedAt": "2026-04-16T17:03:33.451Z",
  "createdAt": "2026-04-16T13:05:10.636Z",
  "id": "EuPdIkCORyh0skoB",
  "name": "[SUCURSAL] - Sincronizar Campo personalizado \"Sucursal\"",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "7832ff1f-ec92-4df1-a5e9-573998102591",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        -16
      ],
      "id": "32c436bc-bd7e-4ac6-81a0-b022d5657d5d",
      "name": "Webhook",
      "webhookId": "7832ff1f-ec92-4df1-a5e9-573998102591"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "44d54b9e-d192-4b54-bf0c-156b79afc6e2",
              "leftValue": "={{ $json.Cliente.Email }}",
              "rightValue": "@ezcorp.com",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            },
            {
              "id": "64f2add6-506c-4950-8026-c04c9547aeeb",
              "leftValue": "",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        384,
        -16
      ],
      "id": "b930d497-1f1a-43ba-a04b-766000317219",
      "name": "Omitir @ezcorp.com"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8a998fd4-2de6-4895-ab3d-e052e823d1b8",
              "name": "Cliente.Fuente Posible Cliente",
              "value": "={{ $json.body['Fuente de Posible cliente'] }}",
              "type": "string"
            },
            {
              "id": "938c6fec-ae16-4e7a-ba2a-f450794fa40d",
              "name": "Cliente.Fecha de creación",
              "value": "={{ $json.body.date_created }}",
              "type": "string"
            },
            {
              "id": "b56a1939-2608-47c8-85ad-b60b557d2a27",
              "name": "Cliente.Sucursal.Sucursal",
              "value": "={{ $json.body.Sucursal }}",
              "type": "string"
            },
            {
              "id": "0d07b9c9-4450-497b-ab81-3baa441787fb",
              "name": "Vehiculo.Versión.Versión",
              "value": "={{ $json.body['Version del Vehiculo'] }}",
              "type": "string"
            },
            {
              "id": "75e3f337-00d1-429d-8d5b-85ec18e6c5e4",
              "name": "Vehiculo.Marca.Marca",
              "value": "={{ $json.body['Marca del Vehiculo'] }}",
              "type": "string"
            },
            {
              "id": "cb09c536-fe84-4598-aaae-aa79f2eda61b",
              "name": "Vehiculo.Marca.fieldKey",
              "value": "=contact.marca_del_vehiculo",
              "type": "string"
            },
            {
              "id": "17d36409-4c54-48dd-8100-f7f667fd2415",
              "name": "Vehiculo.Año.Año",
              "value": "={{ $json.body['Año del Vehículo'] }}",
              "type": "string"
            },
            {
              "id": "a1886afc-b0af-4950-9752-f8bfff594896",
              "name": "Vehiculo.Modalidad.Modalidad",
              "value": "={{ $json.body['¿Qué modalidad prefieres?'] }}",
              "type": "string"
            },
            {
              "id": "33b2c28a-1ad3-4c74-917f-3cd718a3a709",
              "name": "Cliente.Nombre",
              "value": "={{ $json.body['Información Adicional'] }}",
              "type": "string"
            },
            {
              "id": "b36131ac-2d88-41f8-8f0f-7640cdb02b57",
              "name": "Cliente.Apellido",
              "value": "={{ $json.body.first_name }}",
              "type": "string"
            },
            {
              "id": "ae252c8f-f0a1-41d9-a21d-04ca949f01c8",
              "name": "Cliente.Nombre Completo",
              "value": "={{ $json.body.full_name }}",
              "type": "string"
            },
            {
              "id": "342a9377-0ded-4f23-b93b-1f76e57c0cbd",
              "name": "Cliente.Email",
              "value": "={{ $json.body.email }}",
              "type": "string"
            },
            {
              "id": "cf1b7058-96c2-4c73-9250-719a88b68673",
              "name": "Cliente.Telefono",
              "value": "={{ $json.body.phone }}",
              "type": "string"
            },
            {
              "id": "0b916193-15e8-4a91-9ff2-0a6f262b3c38",
              "name": "Cliente.Contact ID",
              "value": "={{ $json.body.contact_id }}",
              "type": "string"
            },
            {
              "id": "67eeaa9b-f703-4521-82af-9d2797131edc",
              "name": "Cliente.Sucursal.fieldKey",
              "value": "contact.sucursal",
              "type": "string"
            },
            {
              "id": "b05ea7bb-bbaa-467b-8247-eabb162ff029",
              "name": "Vehiculo.Versión.fieldKey",
              "value": "contact.version_del_vehiculo",
              "type": "string"
            },
            {
              "id": "9891b919-ef4c-46bd-8414-6d916565d896",
              "name": "Vehiculo.Año.fieldKey",
              "value": "contact.ano_del_vehiculo",
              "type": "string"
            },
            {
              "id": "0b6bf582-49c1-41de-9c2e-6ae85c4e41e8",
              "name": "Vehiculo.Modalidad.fieldKey",
              "value": "contact.que_modalidad_prefieres",
              "type": "string"
            },
            {
              "id": "57199999-2d9b-41c7-8269-5a8183ca8132",
              "name": "Cliente.Cuándo necesitas el dinero",
              "value": "={{ $json.body[\"¿Cuándo necesitas el dinero?\"] }}",
              "type": "string"
            },
            {
              "id": "8060d06e-b1da-4a65-8a0a-3c21d237d77e",
              "name": "Sucursal.Cuenta Bucéfalo",
              "value": "={{ $json.body.location.name }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        208,
        -16
      ],
      "id": "0100a3b3-de2b-44a2-a973-7860c8ecfa67",
      "name": "Datos de Lead"
    },
    {
      "parameters": {
        "content": "# CUENTA ORIGEN",
        "height": 240,
        "width": 1344
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -96
      ],
      "typeVersion": 1,
      "id": "2d89c0aa-0bb9-4ab0-9a16-ddf2c08c47bb",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "",
        "height": 176,
        "width": 608,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        -48
      ],
      "typeVersion": 1,
      "id": "8e2e4f55-6031-4899-8edb-0f946d550eb7",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "# CUENTA OBJETIVO",
        "height": 240,
        "width": 1632
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3536,
        -736
      ],
      "typeVersion": 1,
      "id": "d1234f49-fbc7-466e-a3e0-231adfdf522a",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "",
        "height": 176,
        "width": 592,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5200,
        -672
      ],
      "typeVersion": 1,
      "id": "66a8739b-f782-4b7b-a5f8-0c89ab75b891",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "# REVISIÓN SIEMPRE",
        "height": 240,
        "width": 352,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        -96
      ],
      "typeVersion": 1,
      "id": "9f54c617-bfd2-445e-ae80-af2511f65101",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "91e3e213-9797-4be0-85d5-480bd1a9510c",
              "leftValue": "={{ $json.contacts[1] }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            },
            {
              "id": "01b8ad0c-ac85-470e-a82d-205b5688e5a5",
              "leftValue": "={{ $json.total }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        4208,
        -672
      ],
      "id": "bf7ada82-79d7-4c3b-ae3c-1433040c8da2",
      "name": "Si hay más de un resultado"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "91e3e213-9797-4be0-85d5-480bd1a9510c",
              "leftValue": "={{ $json.contacts[1] }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        4592,
        -848
      ],
      "id": "04925ff6-3b69-413d-8366-e766bcf91f9a",
      "name": "Si hay más de un resultado1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/contacts/search",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json['Token/API'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"locationId\": \"{{ $json['ID LOCATION BUCEFALO'] }}\",\n  \"pageLimit\": 20,\n  \"query\":\"{{ $('DATOS CUENTA A CHECAR').item.json.Contacto.email }}\"\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        3952,
        -672
      ],
      "id": "09ea36fb-7173-48c6-ae14-c04f3a006047",
      "name": "Buscar Contacto Objetivo - SUCURSAL(mail)"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/contacts/search",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"locationId\": \"{{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Location ID'] }}\",\n  \"pageLimit\": 20,\n  \"query\":\"{{ $('Datos de Lead').item.json.Cliente.Telefono }}\"\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        4368,
        -848
      ],
      "id": "287228ac-c42d-45df-974c-8a57e55af92c",
      "name": "Retry - Buscar Contacto Objetivo - SUCURSAL (teléfono)"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/contacts/search",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"locationId\": \"{{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Location ID'] }}\",\n  \"pageLimit\": 20,\n  \"query\": \"{{ $('Datos de Lead').item.json.Cliente['Nombre Completo'] }}\"\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        4880,
        -864
      ],
      "id": "7c0c008d-1a44-4e13-89f2-3225bf558cf3",
      "name": "Retry - Buscar Contacto Objetivo - SUCURSAL (nombre)"
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['ID LOCATION BUCEFALO'] }}/customFields",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        5728,
        -912
      ],
      "id": "69281b5d-8b19-4dac-a7a0-c21afe1b91e5",
      "name": "Conseguir Custom Cuenta objetivo - SUCURSAL"
    },
    {
      "parameters": {
        "jsCode": "var origenData = $('Conseguir Custom Cuenta Origen- SUCURSAL1').first().json;\nvar objetivoData = $('Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL').first().json;\n\nvar origenCustomFields = origenData.customFields;\nvar objetivoCustomFields = objetivoData.customFields;\n\n// Validación defensiva\nif (!Array.isArray(origenCustomFields) || !Array.isArray(objetivoCustomFields)) {\n  return [{ json: { body: JSON.stringify({\n    firstName: origenData.firstName,\n    lastName: origenData.lastName,\n    email: origenData.email,\n    country: origenData.country,\n    tags: origenData.tags,\n    customFields: []\n  }) } }];\n}\n\nvar customFields = [];\n\nfor (var i = 0; i < origenCustomFields.length; i++) {\n  var campoOrigen = origenCustomFields[i];\n  if (!campoOrigen.fieldKey) continue;\n\n  var campoObjetivo = null;\n  for (var j = 0; j < objetivoCustomFields.length; j++) {\n    if (objetivoCustomFields[j].fieldKey === campoOrigen.fieldKey) {\n      campoObjetivo = objetivoCustomFields[j];\n      break;\n    }\n  }\n  if (!campoObjetivo) continue;\n\n  var rawValue = campoOrigen.value;\n  var fieldValue = Array.isArray(rawValue) ? rawValue : (rawValue !== undefined ? rawValue : null);\n\n  customFields.push({\n    id: campoObjetivo.id,\n    key: campoObjetivo.fieldKey,\n    field_value: fieldValue\n  });\n}\n\nvar body = {\n  firstName: origenData.firstName,\n  lastName: origenData.lastName,\n  email: origenData.email,\n  country: origenData.country,\n  tags: origenData.tags,\n  customFields: customFields\n};\n\nreturn [{ json: { body: JSON.stringify(body) } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2768,
        -464
      ],
      "id": "87c42511-033d-4ff1-8e5b-a560c0087fed",
      "name": "Obtener Body para Actualizar Contacto Objetivo - SUCURSAL"
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Obtener Contacto Cuenta Origen - SUCURSAL').item.json.contact.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.API_token }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json.bodyString }}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3344,
        -32
      ],
      "id": "2f5bc952-28a5-4ee2-9ba8-13d3cc0b8011",
      "name": "Actualizar Contacto Cuenta Objetivo - SUCURSAL"
    },
    {
      "parameters": {
        "databaseId": 63,
        "tableId": 750,
        "additionalOptions": {
          "filters": {
            "fields": [
              {
                "field": 7240,
                "value": "={{ $json.Contacto.Sucursal }}"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.baserow",
      "typeVersion": 1,
      "position": [
        2592,
        656
      ],
      "id": "d3195f0d-2c12-4663-8c82-0c7ecbec5944",
      "name": ".BACKUP Obtener Info de cuenta objetivo - SUCURSAL1",
      "credentials": {
        "baserowApi": {
          "id": "LZztQ3WMpzXjSTIH",
          "name": "Baserow account"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta Origen').item.json['Location ID'] }}/customFields",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta Origen').item.json['Token/API'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1552,
        -32
      ],
      "id": "40ec69eb-7d36-4173-be3e-d2613992b07d",
      "name": "Conseguir Custom Cuenta Origen- SUCURSAL"
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json['Token/API'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1376,
        -32
      ],
      "id": "5fb13558-ebf9-41f0-afec-7c9728d872c2",
      "name": "Obtener Contacto Cuenta Origen - SUCURSAL"
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta objetivo - MARCA').item.json['Location ID'] }}/customFields",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        5824,
        -432
      ],
      "id": "0366cd74-7c1d-4a1c-86f9-f37d61aa4c72",
      "name": "Conseguir Custom Cuenta objetivo - MARCA1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "325cb1d8-a045-45a6-a8b1-aca5f6c1f1c4",
              "leftValue": "={{ $json.contact.id }}",
              "rightValue": "AxiosError",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        5456,
        -640
      ],
      "id": "ab6d6fd9-b625-47db-b8b1-487420a616ed",
      "name": "Verificar Existencia de Contcato"
    },
    {
      "parameters": {
        "url": "https://services.leadconnectorhq.com/opportunities/pipelines",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "locationId",
              "value": "={{ $('Datos API Cuenta objetivo - MARCA').item.json['Location ID'] }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        6592,
        -432
      ],
      "id": "fd42e028-9de4-4b23-922e-75570225f23a",
      "name": "Obtener Pipelines"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/opportunities/",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"locationId\": \"{{ $('Datos API Cuenta objetivo - MARCA').item.json['Location ID'] }}\",\n  \"contactId\": \"{{ $('Crear Contacto - Cuenta Objetivo - MARCA').item.json.contact.id }}\",\n  \"name\": \"{{ $('Datos de Lead').item.json.Cliente['Nombre Completo'] }}\",\n  \"pipelineId\": \"{{ $json.pipelines[0].id }}\",\n  \"pipelineStageId\": \"{{ $json.pipelines[0].stages[0].id }}\",\n  \"status\": \"open\",\n  \"monetaryValue\": 0\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        6800,
        -432
      ],
      "id": "1bab44be-484a-4e7d-89bf-fd3f4749e7ab",
      "name": "Crear Oportunidad"
    },
    {
      "parameters": {
        "jsCode": "var origenData = $('Obtener Contacto Cuenta Origen - SUCURSAL').first().json.contact;\nvar marcaCustomDefs = $('Conseguir Custom Cuenta objetivo - MARCA1').first().json.customFields;\nvar origenDefs = $('Conseguir Custom Cuenta Origen- SUCURSAL').first().json.customFields;\nvar locationId = $('Datos API Cuenta objetivo - MARCA').first().json['Location ID'];\n\n// Mapa id -> fieldKey desde las definiciones del origen\nvar idToFieldKey = {};\nfor (var i = 0; i < origenDefs.length; i++) {\n  idToFieldKey[origenDefs[i].id] = origenDefs[i].fieldKey;\n}\n\n// Mapa fieldKey -> value desde el contacto origen\nvar valoresPorFieldKey = {};\nfor (var i = 0; i < origenData.customFields.length; i++) {\n  var cf = origenData.customFields[i];\n  var fk = idToFieldKey[cf.id];\n  if (fk) valoresPorFieldKey[fk] = cf.value;\n}\n\n// Construir customFields omitiendo valores null o undefined\nvar customFields = [];\nfor (var j = 0; j < marcaCustomDefs.length; j++) {\n  var def = marcaCustomDefs[j];\n  var rawValue = valoresPorFieldKey[def.fieldKey];\n  if (rawValue !== undefined && rawValue !== null) {\n    customFields.push({\n      id: def.id,\n      field_value: rawValue\n    });\n  }\n}\n\nvar body = {\n  firstName: origenData.firstName || null,\n  lastName: origenData.lastName || null,\n  name: origenData.fullName || (origenData.firstName + ' ' + origenData.lastName).trim() || null,\n  email: origenData.email || null,\n  locationId: locationId,\n  phone: origenData.phone || null,\n  address1: origenData.address1 || null,\n  city: origenData.city || null,\n  state: origenData.state || null,\n  postalCode: origenData.postalCode || null,\n  website: origenData.website || null,\n  timezone: origenData.timezone || null,\n  country: origenData.country || null,\n  tags: origenData.tags && origenData.tags.length > 0 ? origenData.tags : [],\n  customFields: customFields\n};\n\n// Limpiar keys con valor null para no enviar campos vacíos\nvar bodyLimpio = {};\nfor (var key in body) {\n  if (body[key] !== null) {\n    bodyLimpio[key] = body[key];\n  }\n}\n\nreturn [{ json: { body: JSON.stringify(bodyLimpio) } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        6048,
        -432
      ],
      "id": "06acafc9-fde3-4b4e-bf7b-7fc6d19d3221",
      "name": "Obtener el boy para crear Contacto - MARCA"
    },
    {
      "parameters": {
        "content": "# Crear Contacto & Oportunidad",
        "height": 240,
        "width": 1232,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5792,
        -496
      ],
      "typeVersion": 1,
      "id": "5b0d97c5-a21f-4f7a-95e4-ea3c72e14d04",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://services.leadconnectorhq.com/contacts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json.body }}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        6272,
        -432
      ],
      "id": "fe4a11b7-799a-4001-b468-b4cc43e995f6",
      "name": "Crear Contacto - Cuenta Objetivo - MARCA"
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $json.contacts[0].id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        5248,
        -640
      ],
      "id": "fc3009f9-50eb-43d3-b877-e1615d30b100",
      "name": "Obtener Contacto Cuenta objetivo - SUCURSAL",
      "alwaysOutputData": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "55ff7d12-17b9-4bec-a324-e633020b131d",
              "name": "Name Location",
              "value": "={{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.Nombre }}",
              "type": "string"
            },
            {
              "id": "d877c8cd-db32-4c16-96dd-4eeb2dc48efe",
              "name": "Location ID",
              "value": "={{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.Location_ID }}",
              "type": "string"
            },
            {
              "id": "7698f395-5db8-415b-919e-3ad61c6566f8",
              "name": "Token/API",
              "value": "={{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.API_token }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1056,
        -32
      ],
      "id": "3169d060-08db-4022-87da-dad2b032016e",
      "name": "Datos API Cuenta Origen",
      "notes": "Esta en modo prueba forzada para Queretaro"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f8e50b58-6bb5-4879-b60e-7d23e6a91776",
              "name": "Marca.Nombre de cuenta",
              "value": "Monte Providencia",
              "type": "string"
            },
            {
              "id": "6c1656c9-cb11-4b05-9d37-3213536aaa8a",
              "name": "Marca.LocationID",
              "value": "GbKkBpCmKu2QmloKFHy3",
              "type": "string"
            },
            {
              "id": "61d28849-1504-476d-b754-1ae255fc9a12",
              "name": "Contacto.Nombre",
              "value": "={{ $json.firstName }}",
              "type": "string"
            },
            {
              "id": "096deddd-c321-42b6-a36c-94271101a41c",
              "name": "Contacto.Apellidos",
              "value": "={{ $json.lastName }}",
              "type": "string"
            },
            {
              "id": "9171bd91-7d9c-4f44-8fd4-0a18c738a205",
              "name": "Contacto.email",
              "value": "={{ $json.email }}",
              "type": "string"
            },
            {
              "id": "f5008e38-c604-433f-86c7-efcaa90f908b",
              "name": "Contacto.Sucursal Bucefalo",
              "value": "={{ $('Datos de Lead').item.json.Sucursal['Cuenta Bucéfalo'] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2288,
        -32
      ],
      "id": "def7c13f-e452-4e65-984c-7a130b52fdb8",
      "name": "DATOS CUENTA A CHECAR"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "55ff7d12-17b9-4bec-a324-e633020b131d",
              "name": "Name Location",
              "value": "={{ $json['Agente BUCEFALO'] }}",
              "type": "string"
            },
            {
              "id": "88d3daaf-ad75-4c43-9ee8-d02dbacc0607",
              "name": "ID LOCATION BUCEFALO",
              "value": "={{ $json['ID LOCATION BUCEFALO'] }}",
              "type": "string"
            },
            {
              "id": "7698f395-5db8-415b-919e-3ad61c6566f8",
              "name": "Token/API",
              "value": "={{ $json['SC TOKEN BUCEFALO'] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        3776,
        -672
      ],
      "id": "62ac91d7-8c5b-4a38-a076-7a75a1fb810b",
      "name": "Datos API Cuenta objetivo - SUCURSAL 1",
      "notes": "Esta en modo prueba forzada para Queretaro"
    },
    {
      "parameters": {
        "databaseId": 63,
        "tableId": 750,
        "additionalOptions": {
          "filters": {
            "fields": [
              {
                "field": 7247,
                "operator": "contains",
                "value": "={{ $json.Contacto['Sucursal Bucefalo'] }}"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.baserow",
      "typeVersion": 1,
      "position": [
        2560,
        -32
      ],
      "id": "0149bcda-7fd3-4581-9351-6a8593e13bfb",
      "name": "Buscar Cuenta Sucursal Bucefalo",
      "credentials": {
        "baserowApi": {
          "id": "LZztQ3WMpzXjSTIH",
          "name": "Baserow account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Inputs\nconst contactData = $('Obtener Contacto Cuenta Origen - SUCURSAL').first().json.contact;\nconst allCustomFieldItems = $('Conseguir Custom Cuenta Origen- SUCURSAL').all();\n\n// Consolidar TODOS los customFields de todos los items del nodo\nconst allFieldDefs = [];\nfor (const item of allCustomFieldItems) {\n  const fields = item.json.customFields || [];\n  allFieldDefs.push(...fields);\n}\n\n// Crear mapa id -> definición completa\nconst fieldKeyMap = {};\nfor (const field of allFieldDefs) {\n  fieldKeyMap[field.id] = {\n    fieldKey: field.fieldKey,\n    name: field.name,\n    dataType: field.dataType\n  };\n}\n\n// Enriquecer los customFields del contacto con su fieldKey\nconst enrichedCustomFields = [];\nfor (const cf of contactData.customFields) {\n  const def = fieldKeyMap[cf.id];\n  if (def) {\n    enrichedCustomFields.push({\n      id: cf.id,\n      fieldKey: def.fieldKey,\n      name: def.name,\n      dataType: def.dataType,\n      value: cf.value\n    });\n  } else {\n    // Campo sin definición encontrada — se conserva con id para no perder datos\n    enrichedCustomFields.push({\n      id: cf.id,\n      fieldKey: null,\n      name: null,\n      dataType: null,\n      value: cf.value\n    });\n  }\n}\n\n// Construir objeto de contacto completo\nconst contactoOrigen = {\n  id: contactData.id,\n  firstName: contactData.firstName,\n  lastName: contactData.lastName,\n  email: contactData.email,\n  country: contactData.country,\n  locationId: contactData.locationId,\n  type: contactData.type,\n  tags: contactData.tags,\n  dateAdded: contactData.dateAdded,\n  dateUpdated: contactData.dateUpdated,\n  additionalEmails: contactData.additionalEmails,\n  additionalPhones: contactData.additionalPhones,\n  customFields: enrichedCustomFields\n};\n\nreturn [{ json: contactoOrigen }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1760,
        -32
      ],
      "id": "e127d820-6b3c-433a-96e6-3edd0403fef0",
      "name": "Conseguir Custom Cuenta Origen- SUCURSAL1"
    },
    {
      "parameters": {
        "jsCode": "// Inputs\nconst contactoOrigen = $('Conseguir Custom Cuenta Origen- SUCURSAL1').first().json;\nconst sucursalesData = $('Buscar Cuenta Sucursal Bucefalo').all();\n\n// Tomar el primer resultado de Buscar Cuenta Sucursal Bucefalo\nconst sucursalMatch = sucursalesData.length > 0 ? sucursalesData[0].json : null;\n\n// El ID del customField contact.sucursal — obtenido de Conseguir Custom Cuenta Origen- SUCURSAL\nconst sucursalFieldId = 'WWo4h9uxS8LPzBcl88RL';\n\n// El value a escribir es el nombre de la SUCURSAL del primer resultado\nconst sucursalValue = sucursalMatch ? sucursalMatch['SUCURSAL'] : null;\n\n// Token de la cuenta destino (sucursal Bucefalo)\nconst token = sucursalMatch ? sucursalMatch['SC TOKEN BUCEFALO'] : null;\n\nconst updateBody = {\n  contactId: contactoOrigen.id,\n  token: token,\n  sucursalFieldId: sucursalFieldId,\n  sucursalValue: sucursalValue,\n  scBucefalo: sucursalMatch ? sucursalMatch['SC BUCEFALO'] : null,\n  idLocationBucefalo: sucursalMatch ? sucursalMatch['ID LOCATION BUCEFALO'] : null,\n  tienda: sucursalMatch ? sucursalMatch['TIENDA'] : null,\n  matchFound: sucursalMatch !== null\n};\n\nreturn [{ json: updateBody }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2768,
        -32
      ],
      "id": "5670c042-9b8c-4a99-a2e6-76fa703f66c0",
      "name": "Mapear Sucursal"
    },
    {
      "parameters": {
        "jsCode": "// Inputs\nconst contactoOrigen = $('Conseguir Custom Cuenta Origen- SUCURSAL1').first().json;\nconst sucursalMatch = $('Mapear Sucursal').first().json;\n\n// Custom fields existentes del contacto (excepto sucursal, la sobreescribimos)\nconst customFieldsExistentes = (contactoOrigen.customFields || [])\n  .filter(cf => cf.fieldKey !== 'contact.sucursal')\n  .map(cf => ({\n    id: cf.id,\n    key: cf.fieldKey,\n    field_value: cf.value\n  }));\n\n// Agregar campo sucursal actualizado\ncustomFieldsExistentes.push({\n  id: sucursalMatch.sucursalFieldId,\n  key: 'contact.sucursal',\n  field_value: sucursalMatch.sucursalValue\n});\n\n// Construir body solo con campos que tengan valor\nconst body = { customFields: customFieldsExistentes };\n\nif (contactoOrigen.firstName) body.firstName = contactoOrigen.firstName;\nif (contactoOrigen.lastName) body.lastName = contactoOrigen.lastName;\nif (contactoOrigen.email) body.email = contactoOrigen.email;\nif (contactoOrigen.phone) body.phone = contactoOrigen.phone;\nif (contactoOrigen.country) body.country = contactoOrigen.country;\nif (contactoOrigen.tags && contactoOrigen.tags.length > 0) body.tags = contactoOrigen.tags;\n\nreturn [{\n  json: {\n    contactId: sucursalMatch.contactId,\n    token: sucursalMatch.token,\n    locationId: sucursalMatch.idLocationBucefalo,\n    bodyString: JSON.stringify(body)\n  }\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3120,
        -32
      ],
      "id": "d635df32-ed0a-44e5-83f4-b6245b23154e",
      "name": "Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL"
    },
    {
      "parameters": {
        "databaseId": 63,
        "tableId": 749,
        "additionalOptions": {
          "filters": {
            "fields": [
              {
                "field": 7235,
                "value": "={{ $('Datos de Lead').item.json.Sucursal['Cuenta Bucéfalo'] }}"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.baserow",
      "typeVersion": 1,
      "position": [
        864,
        -32
      ],
      "id": "5bc51b4f-0d71-4594-a8ab-18a56dfa225e",
      "name": "Obtener Info de cuenta origen - SUCURSAL",
      "credentials": {
        "baserowApi": {
          "id": "LZztQ3WMpzXjSTIH",
          "name": "Baserow account"
        }
      }
    },
    {
      "parameters": {
        "amount": 35
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1232,
        -32
      ],
      "id": "2800d221-ea5d-4b1c-abda-9dee8e028f36",
      "name": "Wait",
      "webhookId": "b596f102-2026-4702-bdf7-f68870513bbf"
    }
  ],
  "connections": {
    "Omitir @ezcorp.com": {
      "main": [
        [
          {
            "node": "Obtener Info de cuenta origen - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Datos de Lead": {
      "main": [
        [
          {
            "node": "Omitir @ezcorp.com",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Si hay más de un resultado": {
      "main": [
        [
          {
            "node": "Retry - Buscar Contacto Objetivo - SUCURSAL (teléfono)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Obtener Contacto Cuenta objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Si hay más de un resultado1": {
      "main": [
        [
          {
            "node": "Retry - Buscar Contacto Objetivo - SUCURSAL (nombre)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Obtener Contacto Cuenta objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Contacto Objetivo - SUCURSAL(mail)": {
      "main": [
        [
          {
            "node": "Si hay más de un resultado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retry - Buscar Contacto Objetivo - SUCURSAL (teléfono)": {
      "main": [
        [
          {
            "node": "Si hay más de un resultado1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retry - Buscar Contacto Objetivo - SUCURSAL (nombre)": {
      "main": [
        [
          {
            "node": "Obtener Contacto Cuenta objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conseguir Custom Cuenta objetivo - SUCURSAL": {
      "main": [
        []
      ]
    },
    "Obtener Body para Actualizar Contacto Objetivo - SUCURSAL": {
      "main": [
        []
      ]
    },
    "Conseguir Custom Cuenta Origen- SUCURSAL": {
      "main": [
        [
          {
            "node": "Conseguir Custom Cuenta Origen- SUCURSAL1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Contacto Cuenta Origen - SUCURSAL": {
      "main": [
        [
          {
            "node": "Conseguir Custom Cuenta Origen- SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conseguir Custom Cuenta objetivo - MARCA1": {
      "main": [
        [
          {
            "node": "Obtener el boy para crear Contacto - MARCA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verificar Existencia de Contcato": {
      "main": [
        [
          {
            "node": "Conseguir Custom Cuenta objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Conseguir Custom Cuenta objetivo - MARCA1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Pipelines": {
      "main": [
        [
          {
            "node": "Crear Oportunidad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener el boy para crear Contacto - MARCA": {
      "main": [
        [
          {
            "node": "Crear Contacto - Cuenta Objetivo - MARCA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Contacto Cuenta objetivo - SUCURSAL": {
      "main": [
        [
          {
            "node": "Verificar Existencia de Contcato",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Datos API Cuenta Origen": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DATOS CUENTA A CHECAR": {
      "main": [
        [
          {
            "node": "Buscar Cuenta Sucursal Bucefalo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Datos API Cuenta objetivo - SUCURSAL 1": {
      "main": [
        [
          {
            "node": "Buscar Contacto Objetivo - SUCURSAL(mail)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Datos de Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Cuenta Sucursal Bucefalo": {
      "main": [
        [
          {
            "node": "Mapear Sucursal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conseguir Custom Cuenta Origen- SUCURSAL1": {
      "main": [
        [
          {
            "node": "DATOS CUENTA A CHECAR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapear Sucursal": {
      "main": [
        [
          {
            "node": "Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL": {
      "main": [
        [
          {
            "node": "Actualizar Contacto Cuenta Objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Info de cuenta origen - SUCURSAL": {
      "main": [
        [
          {
            "node": "Datos API Cuenta Origen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Obtener Contacto Cuenta Origen - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "staticData": null,
  "meta": null,
  "pinData": {
    "Webhook": [
      {
        "json": {
          "headers": {
            "host": "webhookn8.consultoriae3.com",
            "user-agent": "axios/1.13.2",
            "content-length": "1461",
            "accept": "application/json, text/plain, */*",
            "accept-encoding": "gzip, compress, deflate, br",
            "content-type": "application/json",
            "traceparent": "00-f1c53a20e94fd22d457592bbcacf08cd-f210e7e890d5fdba-00",
            "x-forwarded-for": "34.123.194.66",
            "x-forwarded-host": "webhookn8.consultoriae3.com",
            "x-forwarded-port": "443",
            "x-forwarded-proto": "https",
            "x-forwarded-server": "f569f6e85d30",
            "x-real-ip": "34.123.194.66"
          },
          "params": {},
          "query": {},
          "body": {
            "Presupuesto": "",
            "[Correo_Canalizados]": "",
            "Descripción": "",
            "Información Adicional": "",
            "[Correo_Empresa]": "",
            "Año del Vehículo": "",
            "Archivos Adicionales": "",
            "¿Qué modalidad prefieres?": "",
            "[Dirección de la Empresa]": "",
            "[Nombre de la Empresa]": "",
            "Version del Vehiculo": "",
            "Sucursal": "Querétaro, Qro.",
            "Fuente De Prospecto": "Prospección",
            "Fuente de Posible cliente": "",
            "[Número de Teléfono para Atender]": "",
            "[Número de WhatsApp para Atender]": "",
            "Marca del Vehiculo": "",
            "contact_id": "lu1qG7BTQ384hUjHwakw",
            "first_name": "Nicolas",
            "last_name": "Rico",
            "full_name": "Nicolas Rico",
            "phone": "+524423350729",
            "tags": "",
            "country": "MX",
            "date_created": "2026-04-14T20:15:04.077Z",
            "full_address": "",
            "contact_type": "lead",
            "location": {
              "name": "85975 - MP - Querétaro",
              "address": "Santiago de Querétaro",
              "city": "Santiago de Querétaro",
              "state": "Querétaro",
              "country": "MX",
              "postalCode": "76000",
              "fullAddress": "Santiago de Querétaro, Santiago de Querétaro Querétaro 76000",
              "id": "blRZ21GlzgUCA7bl2uVw"
            },
            "user": {
              "firstName": "QUERETARO 85975",
              "lastName": "QUERETARO",
              "email": "ezstore85975@ezcorp.com",
              "phone": "+524424310750"
            },
            "workflow": {
              "id": "215ca1e8-bc1c-46c6-93d5-09ea8ee51bcd",
              "name": "[SUCURSAL] - Sincronizar Campo personalizado de contacto \"Sucursal\" con el verificador de sucursal"
            },
            "triggerData": {},
            "contact": {
              "attributionSource": {
                "sessionSource": "CRM UI",
                "medium": "manual",
                "mediumId": null
              },
              "lastAttributionSource": {}
            },
            "attributionSource": {},
            "customData": {}
          },
          "webhookUrl": "https://webhookn8.consultoriae3.com/webhook/7832ff1f-ec92-4df1-a5e9-573998102591",
          "executionMode": "production"
        },
        "pairedItem": {
          "item": 0
        }
      }
    ]
  },
  "versionId": "400d796f-3cf6-4697-bee9-abe553cbeb21",
  "activeVersionId": "400d796f-3cf6-4697-bee9-abe553cbeb21",
  "versionCounter": 102,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-04-16T13:05:10.636Z",
      "createdAt": "2026-04-16T13:05:10.636Z",
      "role": "workflow:owner",
      "workflowId": "EuPdIkCORyh0skoB",
      "projectId": "aycNlMpnzsxvXbfG",
      "project": {
        "updatedAt": "2025-11-27T04:06:26.313Z",
        "createdAt": "2025-11-27T03:54:24.410Z",
        "id": "aycNlMpnzsxvXbfG",
        "name": "Consultoria E3 ® <hola@consultoriae3.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "74a7f127-b963-4eb0-aff4-1190428e8409"
      }
    }
  ],
  "tags": [],
  "activeVersion": {
    "updatedAt": "2026-04-16T15:21:12.751Z",
    "createdAt": "2026-04-16T15:21:10.086Z",
    "versionId": "400d796f-3cf6-4697-bee9-abe553cbeb21",
    "workflowId": "EuPdIkCORyh0skoB",
    "nodes": [
      {
        "parameters": {
          "httpMethod": "POST",
          "path": "7832ff1f-ec92-4df1-a5e9-573998102591",
          "options": {}
        },
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2.1,
        "position": [
          0,
          -16
        ],
        "id": "32c436bc-bd7e-4ac6-81a0-b022d5657d5d",
        "name": "Webhook",
        "webhookId": "7832ff1f-ec92-4df1-a5e9-573998102591"
      },
      {
        "parameters": {
          "conditions": {
            "options": {
              "caseSensitive": true,
              "leftValue": "",
              "typeValidation": "strict",
              "version": 3
            },
            "conditions": [
              {
                "id": "44d54b9e-d192-4b54-bf0c-156b79afc6e2",
                "leftValue": "={{ $json.Cliente.Email }}",
                "rightValue": "@ezcorp.com",
                "operator": {
                  "type": "string",
                  "operation": "notContains"
                }
              },
              {
                "id": "64f2add6-506c-4950-8026-c04c9547aeeb",
                "leftValue": "",
                "rightValue": "",
                "operator": {
                  "type": "string",
                  "operation": "equals",
                  "name": "filter.operator.equals"
                }
              }
            ],
            "combinator": "and"
          },
          "options": {}
        },
        "type": "n8n-nodes-base.if",
        "typeVersion": 2.3,
        "position": [
          384,
          -16
        ],
        "id": "b930d497-1f1a-43ba-a04b-766000317219",
        "name": "Omitir @ezcorp.com"
      },
      {
        "parameters": {
          "assignments": {
            "assignments": [
              {
                "id": "8a998fd4-2de6-4895-ab3d-e052e823d1b8",
                "name": "Cliente.Fuente Posible Cliente",
                "value": "={{ $json.body['Fuente de Posible cliente'] }}",
                "type": "string"
              },
              {
                "id": "938c6fec-ae16-4e7a-ba2a-f450794fa40d",
                "name": "Cliente.Fecha de creación",
                "value": "={{ $json.body.date_created }}",
                "type": "string"
              },
              {
                "id": "b56a1939-2608-47c8-85ad-b60b557d2a27",
                "name": "Cliente.Sucursal.Sucursal",
                "value": "={{ $json.body.Sucursal }}",
                "type": "string"
              },
              {
                "id": "0d07b9c9-4450-497b-ab81-3baa441787fb",
                "name": "Vehiculo.Versión.Versión",
                "value": "={{ $json.body['Version del Vehiculo'] }}",
                "type": "string"
              },
              {
                "id": "75e3f337-00d1-429d-8d5b-85ec18e6c5e4",
                "name": "Vehiculo.Marca.Marca",
                "value": "={{ $json.body['Marca del Vehiculo'] }}",
                "type": "string"
              },
              {
                "id": "cb09c536-fe84-4598-aaae-aa79f2eda61b",
                "name": "Vehiculo.Marca.fieldKey",
                "value": "=contact.marca_del_vehiculo",
                "type": "string"
              },
              {
                "id": "17d36409-4c54-48dd-8100-f7f667fd2415",
                "name": "Vehiculo.Año.Año",
                "value": "={{ $json.body['Año del Vehículo'] }}",
                "type": "string"
              },
              {
                "id": "a1886afc-b0af-4950-9752-f8bfff594896",
                "name": "Vehiculo.Modalidad.Modalidad",
                "value": "={{ $json.body['¿Qué modalidad prefieres?'] }}",
                "type": "string"
              },
              {
                "id": "33b2c28a-1ad3-4c74-917f-3cd718a3a709",
                "name": "Cliente.Nombre",
                "value": "={{ $json.body['Información Adicional'] }}",
                "type": "string"
              },
              {
                "id": "b36131ac-2d88-41f8-8f0f-7640cdb02b57",
                "name": "Cliente.Apellido",
                "value": "={{ $json.body.first_name }}",
                "type": "string"
              },
              {
                "id": "ae252c8f-f0a1-41d9-a21d-04ca949f01c8",
                "name": "Cliente.Nombre Completo",
                "value": "={{ $json.body.full_name }}",
                "type": "string"
              },
              {
                "id": "342a9377-0ded-4f23-b93b-1f76e57c0cbd",
                "name": "Cliente.Email",
                "value": "={{ $json.body.email }}",
                "type": "string"
              },
              {
                "id": "cf1b7058-96c2-4c73-9250-719a88b68673",
                "name": "Cliente.Telefono",
                "value": "={{ $json.body.phone }}",
                "type": "string"
              },
              {
                "id": "0b916193-15e8-4a91-9ff2-0a6f262b3c38",
                "name": "Cliente.Contact ID",
                "value": "={{ $json.body.contact_id }}",
                "type": "string"
              },
              {
                "id": "67eeaa9b-f703-4521-82af-9d2797131edc",
                "name": "Cliente.Sucursal.fieldKey",
                "value": "contact.sucursal",
                "type": "string"
              },
              {
                "id": "b05ea7bb-bbaa-467b-8247-eabb162ff029",
                "name": "Vehiculo.Versión.fieldKey",
                "value": "contact.version_del_vehiculo",
                "type": "string"
              },
              {
                "id": "9891b919-ef4c-46bd-8414-6d916565d896",
                "name": "Vehiculo.Año.fieldKey",
                "value": "contact.ano_del_vehiculo",
                "type": "string"
              },
              {
                "id": "0b6bf582-49c1-41de-9c2e-6ae85c4e41e8",
                "name": "Vehiculo.Modalidad.fieldKey",
                "value": "contact.que_modalidad_prefieres",
                "type": "string"
              },
              {
                "id": "57199999-2d9b-41c7-8269-5a8183ca8132",
                "name": "Cliente.Cuándo necesitas el dinero",
                "value": "={{ $json.body[\"¿Cuándo necesitas el dinero?\"] }}",
                "type": "string"
              },
              {
                "id": "8060d06e-b1da-4a65-8a0a-3c21d237d77e",
                "name": "Sucursal.Cuenta Bucéfalo",
                "value": "={{ $json.body.location.name }}",
                "type": "string"
              }
            ]
          },
          "options": {}
        },
        "type": "n8n-nodes-base.set",
        "typeVersion": 3.4,
        "position": [
          208,
          -16
        ],
        "id": "0100a3b3-de2b-44a2-a973-7860c8ecfa67",
        "name": "Datos de Lead"
      },
      {
        "parameters": {
          "content": "# CUENTA ORIGEN",
          "height": 240,
          "width": 1344
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          800,
          -96
        ],
        "typeVersion": 1,
        "id": "2d89c0aa-0bb9-4ab0-9a16-ddf2c08c47bb",
        "name": "Sticky Note"
      },
      {
        "parameters": {
          "content": "",
          "height": 176,
          "width": 608,
          "color": 7
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          1328,
          -48
        ],
        "typeVersion": 1,
        "id": "8e2e4f55-6031-4899-8edb-0f946d550eb7",
        "name": "Sticky Note1"
      },
      {
        "parameters": {
          "content": "# CUENTA OBJETIVO",
          "height": 240,
          "width": 1632
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          3536,
          -736
        ],
        "typeVersion": 1,
        "id": "d1234f49-fbc7-466e-a3e0-231adfdf522a",
        "name": "Sticky Note2"
      },
      {
        "parameters": {
          "content": "",
          "height": 176,
          "width": 592,
          "color": 7
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          5200,
          -672
        ],
        "typeVersion": 1,
        "id": "66a8739b-f782-4b7b-a5f8-0c89ab75b891",
        "name": "Sticky Note4"
      },
      {
        "parameters": {
          "content": "# REVISIÓN SIEMPRE",
          "height": 240,
          "width": 352,
          "color": 3
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          2160,
          -96
        ],
        "typeVersion": 1,
        "id": "9f54c617-bfd2-445e-ae80-af2511f65101",
        "name": "Sticky Note5"
      },
      {
        "parameters": {
          "conditions": {
            "options": {
              "caseSensitive": true,
              "leftValue": "",
              "typeValidation": "strict",
              "version": 3
            },
            "conditions": [
              {
                "id": "91e3e213-9797-4be0-85d5-480bd1a9510c",
                "leftValue": "={{ $json.contacts[1] }}",
                "rightValue": "",
                "operator": {
                  "type": "object",
                  "operation": "exists",
                  "singleValue": true
                }
              },
              {
                "id": "01b8ad0c-ac85-470e-a82d-205b5688e5a5",
                "leftValue": "={{ $json.total }}",
                "rightValue": 0,
                "operator": {
                  "type": "number",
                  "operation": "equals"
                }
              }
            ],
            "combinator": "and"
          },
          "options": {}
        },
        "type": "n8n-nodes-base.if",
        "typeVersion": 2.3,
        "position": [
          4208,
          -672
        ],
        "id": "bf7ada82-79d7-4c3b-ae3c-1433040c8da2",
        "name": "Si hay más de un resultado"
      },
      {
        "parameters": {
          "conditions": {
            "options": {
              "caseSensitive": true,
              "leftValue": "",
              "typeValidation": "strict",
              "version": 3
            },
            "conditions": [
              {
                "id": "91e3e213-9797-4be0-85d5-480bd1a9510c",
                "leftValue": "={{ $json.contacts[1] }}",
                "rightValue": "",
                "operator": {
                  "type": "object",
                  "operation": "exists",
                  "singleValue": true
                }
              }
            ],
            "combinator": "and"
          },
          "options": {}
        },
        "type": "n8n-nodes-base.if",
        "typeVersion": 2.3,
        "position": [
          4592,
          -848
        ],
        "id": "04925ff6-3b69-413d-8366-e766bcf91f9a",
        "name": "Si hay más de un resultado1"
      },
      {
        "parameters": {
          "method": "POST",
          "url": "https://services.leadconnectorhq.com/contacts/search",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $json['Token/API'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"locationId\": \"{{ $json['ID LOCATION BUCEFALO'] }}\",\n  \"pageLimit\": 20,\n  \"query\":\"{{ $('DATOS CUENTA A CHECAR').item.json.Contacto.email }}\"\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          3952,
          -672
        ],
        "id": "09ea36fb-7173-48c6-ae14-c04f3a006047",
        "name": "Buscar Contacto Objetivo - SUCURSAL(mail)"
      },
      {
        "parameters": {
          "method": "POST",
          "url": "https://services.leadconnectorhq.com/contacts/search",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"locationId\": \"{{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Location ID'] }}\",\n  \"pageLimit\": 20,\n  \"query\":\"{{ $('Datos de Lead').item.json.Cliente.Telefono }}\"\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          4368,
          -848
        ],
        "id": "287228ac-c42d-45df-974c-8a57e55af92c",
        "name": "Retry - Buscar Contacto Objetivo - SUCURSAL (teléfono)"
      },
      {
        "parameters": {
          "method": "POST",
          "url": "https://services.leadconnectorhq.com/contacts/search",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"locationId\": \"{{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Location ID'] }}\",\n  \"pageLimit\": 20,\n  \"query\": \"{{ $('Datos de Lead').item.json.Cliente['Nombre Completo'] }}\"\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          4880,
          -864
        ],
        "id": "7c0c008d-1a44-4e13-89f2-3225bf558cf3",
        "name": "Retry - Buscar Contacto Objetivo - SUCURSAL (nombre)"
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['ID LOCATION BUCEFALO'] }}/customFields",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
              }
            ]
          },
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          5728,
          -912
        ],
        "id": "69281b5d-8b19-4dac-a7a0-c21afe1b91e5",
        "name": "Conseguir Custom Cuenta objetivo - SUCURSAL"
      },
      {
        "parameters": {
          "jsCode": "var origenData = $('Conseguir Custom Cuenta Origen- SUCURSAL1').first().json;\nvar objetivoData = $('Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL').first().json;\n\nvar origenCustomFields = origenData.customFields;\nvar objetivoCustomFields = objetivoData.customFields;\n\n// Validación defensiva\nif (!Array.isArray(origenCustomFields) || !Array.isArray(objetivoCustomFields)) {\n  return [{ json: { body: JSON.stringify({\n    firstName: origenData.firstName,\n    lastName: origenData.lastName,\n    email: origenData.email,\n    country: origenData.country,\n    tags: origenData.tags,\n    customFields: []\n  }) } }];\n}\n\nvar customFields = [];\n\nfor (var i = 0; i < origenCustomFields.length; i++) {\n  var campoOrigen = origenCustomFields[i];\n  if (!campoOrigen.fieldKey) continue;\n\n  var campoObjetivo = null;\n  for (var j = 0; j < objetivoCustomFields.length; j++) {\n    if (objetivoCustomFields[j].fieldKey === campoOrigen.fieldKey) {\n      campoObjetivo = objetivoCustomFields[j];\n      break;\n    }\n  }\n  if (!campoObjetivo) continue;\n\n  var rawValue = campoOrigen.value;\n  var fieldValue = Array.isArray(rawValue) ? rawValue : (rawValue !== undefined ? rawValue : null);\n\n  customFields.push({\n    id: campoObjetivo.id,\n    key: campoObjetivo.fieldKey,\n    field_value: fieldValue\n  });\n}\n\nvar body = {\n  firstName: origenData.firstName,\n  lastName: origenData.lastName,\n  email: origenData.email,\n  country: origenData.country,\n  tags: origenData.tags,\n  customFields: customFields\n};\n\nreturn [{ json: { body: JSON.stringify(body) } }];"
        },
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          2768,
          -464
        ],
        "id": "87c42511-033d-4ff1-8e5b-a560c0087fed",
        "name": "Obtener Body para Actualizar Contacto Objetivo - SUCURSAL"
      },
      {
        "parameters": {
          "method": "PUT",
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Obtener Contacto Cuenta Origen - SUCURSAL').item.json.contact.id }}",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.API_token }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={{ $json.bodyString }}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          3344,
          -32
        ],
        "id": "2f5bc952-28a5-4ee2-9ba8-13d3cc0b8011",
        "name": "Actualizar Contacto Cuenta Objetivo - SUCURSAL"
      },
      {
        "parameters": {
          "databaseId": 63,
          "tableId": 750,
          "additionalOptions": {
            "filters": {
              "fields": [
                {
                  "field": 7240,
                  "value": "={{ $json.Contacto.Sucursal }}"
                }
              ]
            }
          }
        },
        "type": "n8n-nodes-base.baserow",
        "typeVersion": 1,
        "position": [
          2592,
          656
        ],
        "id": "d3195f0d-2c12-4663-8c82-0c7ecbec5944",
        "name": ".BACKUP Obtener Info de cuenta objetivo - SUCURSAL1",
        "credentials": {
          "baserowApi": {
            "id": "LZztQ3WMpzXjSTIH",
            "name": "Baserow account"
          }
        }
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta Origen').item.json['Location ID'] }}/customFields",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta Origen').item.json['Token/API'] }}"
              }
            ]
          },
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          1552,
          -32
        ],
        "id": "40ec69eb-7d36-4173-be3e-d2613992b07d",
        "name": "Conseguir Custom Cuenta Origen- SUCURSAL"
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $json['Token/API'] }}"
              }
            ]
          },
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          1376,
          -32
        ],
        "id": "5fb13558-ebf9-41f0-afec-7c9728d872c2",
        "name": "Obtener Contacto Cuenta Origen - SUCURSAL"
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta objetivo - MARCA').item.json['Location ID'] }}/customFields",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
              }
            ]
          },
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          5824,
          -432
        ],
        "id": "0366cd74-7c1d-4a1c-86f9-f37d61aa4c72",
        "name": "Conseguir Custom Cuenta objetivo - MARCA1"
      },
      {
        "parameters": {
          "conditions": {
            "options": {
              "caseSensitive": true,
              "leftValue": "",
              "typeValidation": "strict",
              "version": 3
            },
            "conditions": [
              {
                "id": "325cb1d8-a045-45a6-a8b1-aca5f6c1f1c4",
                "leftValue": "={{ $json.contact.id }}",
                "rightValue": "AxiosError",
                "operator": {
                  "type": "string",
                  "operation": "exists",
                  "singleValue": true
                }
              }
            ],
            "combinator": "and"
          },
          "options": {}
        },
        "type": "n8n-nodes-base.if",
        "typeVersion": 2.3,
        "position": [
          5456,
          -640
        ],
        "id": "ab6d6fd9-b625-47db-b8b1-487420a616ed",
        "name": "Verificar Existencia de Contcato"
      },
      {
        "parameters": {
          "url": "https://services.leadconnectorhq.com/opportunities/pipelines",
          "sendQuery": true,
          "queryParameters": {
            "parameters": [
              {
                "name": "locationId",
                "value": "={{ $('Datos API Cuenta objetivo - MARCA').item.json['Location ID'] }}"
              }
            ]
          },
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
              }
            ]
          },
          "sendBody": true,
          "bodyParameters": {
            "parameters": [
              {}
            ]
          },
          "options": {}
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          6592,
          -432
        ],
        "id": "fd42e028-9de4-4b23-922e-75570225f23a",
        "name": "Obtener Pipelines"
      },
      {
        "parameters": {
          "method": "POST",
          "url": "https://services.leadconnectorhq.com/opportunities/",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"locationId\": \"{{ $('Datos API Cuenta objetivo - MARCA').item.json['Location ID'] }}\",\n  \"contactId\": \"{{ $('Crear Contacto - Cuenta Objetivo - MARCA').item.json.contact.id }}\",\n  \"name\": \"{{ $('Datos de Lead').item.json.Cliente['Nombre Completo'] }}\",\n  \"pipelineId\": \"{{ $json.pipelines[0].id }}\",\n  \"pipelineStageId\": \"{{ $json.pipelines[0].stages[0].id }}\",\n  \"status\": \"open\",\n  \"monetaryValue\": 0\n}",
          "options": {}
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          6800,
          -432
        ],
        "id": "1bab44be-484a-4e7d-89bf-fd3f4749e7ab",
        "name": "Crear Oportunidad"
      },
      {
        "parameters": {
          "jsCode": "var origenData = $('Obtener Contacto Cuenta Origen - SUCURSAL').first().json.contact;\nvar marcaCustomDefs = $('Conseguir Custom Cuenta objetivo - MARCA1').first().json.customFields;\nvar origenDefs = $('Conseguir Custom Cuenta Origen- SUCURSAL').first().json.customFields;\nvar locationId = $('Datos API Cuenta objetivo - MARCA').first().json['Location ID'];\n\n// Mapa id -> fieldKey desde las definiciones del origen\nvar idToFieldKey = {};\nfor (var i = 0; i < origenDefs.length; i++) {\n  idToFieldKey[origenDefs[i].id] = origenDefs[i].fieldKey;\n}\n\n// Mapa fieldKey -> value desde el contacto origen\nvar valoresPorFieldKey = {};\nfor (var i = 0; i < origenData.customFields.length; i++) {\n  var cf = origenData.customFields[i];\n  var fk = idToFieldKey[cf.id];\n  if (fk) valoresPorFieldKey[fk] = cf.value;\n}\n\n// Construir customFields omitiendo valores null o undefined\nvar customFields = [];\nfor (var j = 0; j < marcaCustomDefs.length; j++) {\n  var def = marcaCustomDefs[j];\n  var rawValue = valoresPorFieldKey[def.fieldKey];\n  if (rawValue !== undefined && rawValue !== null) {\n    customFields.push({\n      id: def.id,\n      field_value: rawValue\n    });\n  }\n}\n\nvar body = {\n  firstName: origenData.firstName || null,\n  lastName: origenData.lastName || null,\n  name: origenData.fullName || (origenData.firstName + ' ' + origenData.lastName).trim() || null,\n  email: origenData.email || null,\n  locationId: locationId,\n  phone: origenData.phone || null,\n  address1: origenData.address1 || null,\n  city: origenData.city || null,\n  state: origenData.state || null,\n  postalCode: origenData.postalCode || null,\n  website: origenData.website || null,\n  timezone: origenData.timezone || null,\n  country: origenData.country || null,\n  tags: origenData.tags && origenData.tags.length > 0 ? origenData.tags : [],\n  customFields: customFields\n};\n\n// Limpiar keys con valor null para no enviar campos vacíos\nvar bodyLimpio = {};\nfor (var key in body) {\n  if (body[key] !== null) {\n    bodyLimpio[key] = body[key];\n  }\n}\n\nreturn [{ json: { body: JSON.stringify(bodyLimpio) } }];"
        },
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          6048,
          -432
        ],
        "id": "06acafc9-fde3-4b4e-bf7b-7fc6d19d3221",
        "name": "Obtener el boy para crear Contacto - MARCA"
      },
      {
        "parameters": {
          "content": "# Crear Contacto & Oportunidad",
          "height": 240,
          "width": 1232,
          "color": 4
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          5792,
          -496
        ],
        "typeVersion": 1,
        "id": "5b0d97c5-a21f-4f7a-95e4-ea3c72e14d04",
        "name": "Sticky Note6"
      },
      {
        "parameters": {
          "method": "POST",
          "url": "=https://services.leadconnectorhq.com/contacts",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - MARCA').item.json['Token/API'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={{ $json.body }}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          6272,
          -432
        ],
        "id": "fe4a11b7-799a-4001-b468-b4cc43e995f6",
        "name": "Crear Contacto - Cuenta Objetivo - MARCA"
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $json.contacts[0].id }}",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Datos API Cuenta objetivo - SUCURSAL 1').item.json['Token/API'] }}"
              }
            ]
          },
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.4,
        "position": [
          5248,
          -640
        ],
        "id": "fc3009f9-50eb-43d3-b877-e1615d30b100",
        "name": "Obtener Contacto Cuenta objetivo - SUCURSAL",
        "alwaysOutputData": true,
        "onError": "continueRegularOutput"
      },
      {
        "parameters": {
          "assignments": {
            "assignments": [
              {
                "id": "55ff7d12-17b9-4bec-a324-e633020b131d",
                "name": "Name Location",
                "value": "={{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.Nombre }}",
                "type": "string"
              },
              {
                "id": "d877c8cd-db32-4c16-96dd-4eeb2dc48efe",
                "name": "Location ID",
                "value": "={{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.Location_ID }}",
                "type": "string"
              },
              {
                "id": "7698f395-5db8-415b-919e-3ad61c6566f8",
                "name": "Token/API",
                "value": "={{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.API_token }}",
                "type": "string"
              }
            ]
          },
          "options": {}
        },
        "type": "n8n-nodes-base.set",
        "typeVersion": 3.4,
        "position": [
          1056,
          -32
        ],
        "id": "3169d060-08db-4022-87da-dad2b032016e",
        "name": "Datos API Cuenta Origen",
        "notes": "Esta en modo prueba forzada para Queretaro"
      },
      {
        "parameters": {
          "assignments": {
            "assignments": [
              {
                "id": "f8e50b58-6bb5-4879-b60e-7d23e6a91776",
                "name": "Marca.Nombre de cuenta",
                "value": "Monte Providencia",
                "type": "string"
              },
              {
                "id": "6c1656c9-cb11-4b05-9d37-3213536aaa8a",
                "name": "Marca.LocationID",
                "value": "GbKkBpCmKu2QmloKFHy3",
                "type": "string"
              },
              {
                "id": "61d28849-1504-476d-b754-1ae255fc9a12",
                "name": "Contacto.Nombre",
                "value": "={{ $json.firstName }}",
                "type": "string"
              },
              {
                "id": "096deddd-c321-42b6-a36c-94271101a41c",
                "name": "Contacto.Apellidos",
                "value": "={{ $json.lastName }}",
                "type": "string"
              },
              {
                "id": "9171bd91-7d9c-4f44-8fd4-0a18c738a205",
                "name": "Contacto.email",
                "value": "={{ $json.email }}",
                "type": "string"
              },
              {
                "id": "f5008e38-c604-433f-86c7-efcaa90f908b",
                "name": "Contacto.Sucursal Bucefalo",
                "value": "={{ $('Datos de Lead').item.json.Sucursal['Cuenta Bucéfalo'] }}",
                "type": "string"
              }
            ]
          },
          "options": {}
        },
        "type": "n8n-nodes-base.set",
        "typeVersion": 3.4,
        "position": [
          2288,
          -32
        ],
        "id": "def7c13f-e452-4e65-984c-7a130b52fdb8",
        "name": "DATOS CUENTA A CHECAR"
      },
      {
        "parameters": {
          "assignments": {
            "assignments": [
              {
                "id": "55ff7d12-17b9-4bec-a324-e633020b131d",
                "name": "Name Location",
                "value": "={{ $json['Agente BUCEFALO'] }}",
                "type": "string"
              },
              {
                "id": "88d3daaf-ad75-4c43-9ee8-d02dbacc0607",
                "name": "ID LOCATION BUCEFALO",
                "value": "={{ $json['ID LOCATION BUCEFALO'] }}",
                "type": "string"
              },
              {
                "id": "7698f395-5db8-415b-919e-3ad61c6566f8",
                "name": "Token/API",
                "value": "={{ $json['SC TOKEN BUCEFALO'] }}",
                "type": "string"
              }
            ]
          },
          "options": {}
        },
        "type": "n8n-nodes-base.set",
        "typeVersion": 3.4,
        "position": [
          3776,
          -672
        ],
        "id": "62ac91d7-8c5b-4a38-a076-7a75a1fb810b",
        "name": "Datos API Cuenta objetivo - SUCURSAL 1",
        "notes": "Esta en modo prueba forzada para Queretaro"
      },
      {
        "parameters": {
          "databaseId": 63,
          "tableId": 750,
          "additionalOptions": {
            "filters": {
              "fields": [
                {
                  "field": 7247,
                  "operator": "contains",
                  "value": "={{ $json.Contacto['Sucursal Bucefalo'] }}"
                }
              ]
            }
          }
        },
        "type": "n8n-nodes-base.baserow",
        "typeVersion": 1,
        "position": [
          2560,
          -32
        ],
        "id": "0149bcda-7fd3-4581-9351-6a8593e13bfb",
        "name": "Buscar Cuenta Sucursal Bucefalo",
        "credentials": {
          "baserowApi": {
            "id": "LZztQ3WMpzXjSTIH",
            "name": "Baserow account"
          }
        }
      },
      {
        "parameters": {
          "jsCode": "// Inputs\nconst contactData = $('Obtener Contacto Cuenta Origen - SUCURSAL').first().json.contact;\nconst allCustomFieldItems = $('Conseguir Custom Cuenta Origen- SUCURSAL').all();\n\n// Consolidar TODOS los customFields de todos los items del nodo\nconst allFieldDefs = [];\nfor (const item of allCustomFieldItems) {\n  const fields = item.json.customFields || [];\n  allFieldDefs.push(...fields);\n}\n\n// Crear mapa id -> definición completa\nconst fieldKeyMap = {};\nfor (const field of allFieldDefs) {\n  fieldKeyMap[field.id] = {\n    fieldKey: field.fieldKey,\n    name: field.name,\n    dataType: field.dataType\n  };\n}\n\n// Enriquecer los customFields del contacto con su fieldKey\nconst enrichedCustomFields = [];\nfor (const cf of contactData.customFields) {\n  const def = fieldKeyMap[cf.id];\n  if (def) {\n    enrichedCustomFields.push({\n      id: cf.id,\n      fieldKey: def.fieldKey,\n      name: def.name,\n      dataType: def.dataType,\n      value: cf.value\n    });\n  } else {\n    // Campo sin definición encontrada — se conserva con id para no perder datos\n    enrichedCustomFields.push({\n      id: cf.id,\n      fieldKey: null,\n      name: null,\n      dataType: null,\n      value: cf.value\n    });\n  }\n}\n\n// Construir objeto de contacto completo\nconst contactoOrigen = {\n  id: contactData.id,\n  firstName: contactData.firstName,\n  lastName: contactData.lastName,\n  email: contactData.email,\n  country: contactData.country,\n  locationId: contactData.locationId,\n  type: contactData.type,\n  tags: contactData.tags,\n  dateAdded: contactData.dateAdded,\n  dateUpdated: contactData.dateUpdated,\n  additionalEmails: contactData.additionalEmails,\n  additionalPhones: contactData.additionalPhones,\n  customFields: enrichedCustomFields\n};\n\nreturn [{ json: contactoOrigen }];"
        },
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          1760,
          -32
        ],
        "id": "e127d820-6b3c-433a-96e6-3edd0403fef0",
        "name": "Conseguir Custom Cuenta Origen- SUCURSAL1"
      },
      {
        "parameters": {
          "jsCode": "// Inputs\nconst contactoOrigen = $('Conseguir Custom Cuenta Origen- SUCURSAL1').first().json;\nconst sucursalesData = $('Buscar Cuenta Sucursal Bucefalo').all();\n\n// Tomar el primer resultado de Buscar Cuenta Sucursal Bucefalo\nconst sucursalMatch = sucursalesData.length > 0 ? sucursalesData[0].json : null;\n\n// El ID del customField contact.sucursal — obtenido de Conseguir Custom Cuenta Origen- SUCURSAL\nconst sucursalFieldId = 'WWo4h9uxS8LPzBcl88RL';\n\n// El value a escribir es el nombre de la SUCURSAL del primer resultado\nconst sucursalValue = sucursalMatch ? sucursalMatch['SUCURSAL'] : null;\n\n// Token de la cuenta destino (sucursal Bucefalo)\nconst token = sucursalMatch ? sucursalMatch['SC TOKEN BUCEFALO'] : null;\n\nconst updateBody = {\n  contactId: contactoOrigen.id,\n  token: token,\n  sucursalFieldId: sucursalFieldId,\n  sucursalValue: sucursalValue,\n  scBucefalo: sucursalMatch ? sucursalMatch['SC BUCEFALO'] : null,\n  idLocationBucefalo: sucursalMatch ? sucursalMatch['ID LOCATION BUCEFALO'] : null,\n  tienda: sucursalMatch ? sucursalMatch['TIENDA'] : null,\n  matchFound: sucursalMatch !== null\n};\n\nreturn [{ json: updateBody }];"
        },
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          2768,
          -32
        ],
        "id": "5670c042-9b8c-4a99-a2e6-76fa703f66c0",
        "name": "Mapear Sucursal"
      },
      {
        "parameters": {
          "jsCode": "// Inputs\nconst contactoOrigen = $('Conseguir Custom Cuenta Origen- SUCURSAL1').first().json;\nconst sucursalMatch = $('Mapear Sucursal').first().json;\n\n// Custom fields existentes del contacto (excepto sucursal, la sobreescribimos)\nconst customFieldsExistentes = (contactoOrigen.customFields || [])\n  .filter(cf => cf.fieldKey !== 'contact.sucursal')\n  .map(cf => ({\n    id: cf.id,\n    key: cf.fieldKey,\n    field_value: cf.value\n  }));\n\n// Agregar campo sucursal actualizado\ncustomFieldsExistentes.push({\n  id: sucursalMatch.sucursalFieldId,\n  key: 'contact.sucursal',\n  field_value: sucursalMatch.sucursalValue\n});\n\n// Construir body solo con campos que tengan valor\nconst body = { customFields: customFieldsExistentes };\n\nif (contactoOrigen.firstName) body.firstName = contactoOrigen.firstName;\nif (contactoOrigen.lastName) body.lastName = contactoOrigen.lastName;\nif (contactoOrigen.email) body.email = contactoOrigen.email;\nif (contactoOrigen.phone) body.phone = contactoOrigen.phone;\nif (contactoOrigen.country) body.country = contactoOrigen.country;\nif (contactoOrigen.tags && contactoOrigen.tags.length > 0) body.tags = contactoOrigen.tags;\n\nreturn [{\n  json: {\n    contactId: sucursalMatch.contactId,\n    token: sucursalMatch.token,\n    locationId: sucursalMatch.idLocationBucefalo,\n    bodyString: JSON.stringify(body)\n  }\n}];"
        },
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          3120,
          -32
        ],
        "id": "d635df32-ed0a-44e5-83f4-b6245b23154e",
        "name": "Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL"
      },
      {
        "parameters": {
          "databaseId": 63,
          "tableId": 749,
          "additionalOptions": {
            "filters": {
              "fields": [
                {
                  "field": 7235,
                  "value": "={{ $('Datos de Lead').item.json.Sucursal['Cuenta Bucéfalo'] }}"
                }
              ]
            }
          }
        },
        "type": "n8n-nodes-base.baserow",
        "typeVersion": 1,
        "position": [
          864,
          -32
        ],
        "id": "5bc51b4f-0d71-4594-a8ab-18a56dfa225e",
        "name": "Obtener Info de cuenta origen - SUCURSAL",
        "credentials": {
          "baserowApi": {
            "id": "LZztQ3WMpzXjSTIH",
            "name": "Baserow account"
          }
        }
      },
      {
        "parameters": {
          "amount": 35
        },
        "type": "n8n-nodes-base.wait",
        "typeVersion": 1.1,
        "position": [
          1232,
          -32
        ],
        "id": "2800d221-ea5d-4b1c-abda-9dee8e028f36",
        "name": "Wait",
        "webhookId": "b596f102-2026-4702-bdf7-f68870513bbf"
      }
    ],
    "connections": {
      "Omitir @ezcorp.com": {
        "main": [
          [
            {
              "node": "Obtener Info de cuenta origen - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Datos de Lead": {
        "main": [
          [
            {
              "node": "Omitir @ezcorp.com",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Si hay más de un resultado": {
        "main": [
          [
            {
              "node": "Retry - Buscar Contacto Objetivo - SUCURSAL (teléfono)",
              "type": "main",
              "index": 0
            }
          ],
          [
            {
              "node": "Obtener Contacto Cuenta objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Si hay más de un resultado1": {
        "main": [
          [
            {
              "node": "Retry - Buscar Contacto Objetivo - SUCURSAL (nombre)",
              "type": "main",
              "index": 0
            }
          ],
          [
            {
              "node": "Obtener Contacto Cuenta objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Buscar Contacto Objetivo - SUCURSAL(mail)": {
        "main": [
          [
            {
              "node": "Si hay más de un resultado",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Retry - Buscar Contacto Objetivo - SUCURSAL (teléfono)": {
        "main": [
          [
            {
              "node": "Si hay más de un resultado1",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Retry - Buscar Contacto Objetivo - SUCURSAL (nombre)": {
        "main": [
          [
            {
              "node": "Obtener Contacto Cuenta objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Conseguir Custom Cuenta objetivo - SUCURSAL": {
        "main": [
          []
        ]
      },
      "Obtener Body para Actualizar Contacto Objetivo - SUCURSAL": {
        "main": [
          []
        ]
      },
      "Conseguir Custom Cuenta Origen- SUCURSAL": {
        "main": [
          [
            {
              "node": "Conseguir Custom Cuenta Origen- SUCURSAL1",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener Contacto Cuenta Origen - SUCURSAL": {
        "main": [
          [
            {
              "node": "Conseguir Custom Cuenta Origen- SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Conseguir Custom Cuenta objetivo - MARCA1": {
        "main": [
          [
            {
              "node": "Obtener el boy para crear Contacto - MARCA",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Verificar Existencia de Contcato": {
        "main": [
          [
            {
              "node": "Conseguir Custom Cuenta objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ],
          [
            {
              "node": "Conseguir Custom Cuenta objetivo - MARCA1",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener Pipelines": {
        "main": [
          [
            {
              "node": "Crear Oportunidad",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener el boy para crear Contacto - MARCA": {
        "main": [
          [
            {
              "node": "Crear Contacto - Cuenta Objetivo - MARCA",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener Contacto Cuenta objetivo - SUCURSAL": {
        "main": [
          [
            {
              "node": "Verificar Existencia de Contcato",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Datos API Cuenta Origen": {
        "main": [
          [
            {
              "node": "Wait",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "DATOS CUENTA A CHECAR": {
        "main": [
          [
            {
              "node": "Buscar Cuenta Sucursal Bucefalo",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Datos API Cuenta objetivo - SUCURSAL 1": {
        "main": [
          [
            {
              "node": "Buscar Contacto Objetivo - SUCURSAL(mail)",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Webhook": {
        "main": [
          [
            {
              "node": "Datos de Lead",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Buscar Cuenta Sucursal Bucefalo": {
        "main": [
          [
            {
              "node": "Mapear Sucursal",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Conseguir Custom Cuenta Origen- SUCURSAL1": {
        "main": [
          [
            {
              "node": "DATOS CUENTA A CHECAR",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Mapear Sucursal": {
        "main": [
          [
            {
              "node": "Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener Body Content para Actualizar Contacto Objetivo - SUCURSAL": {
        "main": [
          [
            {
              "node": "Actualizar Contacto Cuenta Objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener Info de cuenta origen - SUCURSAL": {
        "main": [
          [
            {
              "node": "Datos API Cuenta Origen",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Wait": {
        "main": [
          [
            {
              "node": "Obtener Contacto Cuenta Origen - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    },
    "authors": "Consultoria E3 ®",
    "name": "Version 400d796f",
    "description": "",
    "autosaved": true,
    "workflowPublishHistory": [
      {
        "createdAt": "2026-04-16T15:21:12.746Z",
        "id": 472,
        "workflowId": "EuPdIkCORyh0skoB",
        "versionId": "400d796f-3cf6-4697-bee9-abe553cbeb21",
        "event": "activated",
        "userId": "74a7f127-b963-4eb0-aff4-1190428e8409"
      }
    ]
  }
}