{
  "updatedAt": "2026-05-30T03:52:09.863Z",
  "createdAt": "2026-04-20T22:29:00.636Z",
  "id": "ddUEORBEtZLzsQF2",
  "name": "[2004][Monte Providencia] Actualizar \"contact.sucursal\", \"contact.tienda\" al crear contacto",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "content": "# De Sucursal a Marca",
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2288,
        -320
      ],
      "typeVersion": 1,
      "id": "d91325e1-1763-486c-a2c9-8cfffddd57b0",
      "name": "Sticky Note3"
    },
    {
      "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": [
        -912,
        -320
      ],
      "id": "50da84c1-c2d3-4a36-91d3-e3745edccdc6",
      "name": "Obtener Info de cuenta origen - SUCURSAL",
      "credentials": {
        "baserowApi": {
          "id": "LZztQ3WMpzXjSTIH",
          "name": "Baserow account"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta Origen - SUCURSAL').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 - SUCURSAL').item.json['Token/API'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -224,
        -320
      ],
      "id": "a0c27c4c-0f20-4bab-bf6b-bcdd8281a92b",
      "name": "Conseguir Custom Cuenta Origen- SUCURSAL"
    },
    {
      "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": [
        -1392,
        -304
      ],
      "id": "d68558b5-52b8-46b1-a359-fd956c7edc09",
      "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": [
        -1568,
        -304
      ],
      "id": "d0e455ac-7ccc-4c55-bda2-1cd22092e2d2",
      "name": "Datos de Lead"
    },
    {
      "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": [
        -720,
        -320
      ],
      "id": "f0cff3ec-8464-45d4-9e64-713c36e247c6",
      "name": "Datos API Cuenta Origen - SUCURSAL",
      "notes": "Esta en modo prueba forzada para Queretaro"
    },
    {
      "parameters": {
        "content": "# CUENTA ORIGEN",
        "height": 240,
        "width": 1744
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -384
      ],
      "typeVersion": 1,
      "id": "16a74d85-1e6c-4fc7-b854-580a2d3827a0",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Webhook').item.json.body.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": [
        -400,
        -320
      ],
      "id": "92f33c6e-ee64-409d-8c60-9fbfe48b3265",
      "name": "Obtener Contacto Cuenta Origen - SUCURSAL"
    },
    {
      "parameters": {
        "content": "",
        "height": 176,
        "width": 608,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -336
      ],
      "typeVersion": 1,
      "id": "768a4001-5109-493f-b12e-e8ba5d30ec2f",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "method": "PUT",
        "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['SC TOKEN BUCEFALO'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"customFields\": [\n    {\n      \"id\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.sucursal.id }}\",\n      \"key\": \"contact.sucursal\",\n      \"field_value\": \"{{ $json.SUCURSAL }}\"\n    },\n    {\n      \"id\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.tienda.id }}\",\n      \"key\": \"contact.tienda\",\n      \"field_value\": \"{{ $json.TIENDA }}\"\n    }\n  ]\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        512,
        -320
      ],
      "id": "794ce5bb-dea0-4720-958a-1f0940c79e6d",
      "name": "Actualizar Contacto Cuenta Objetivo - SUCURSAL"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "8d574598-d977-4052-823a-26def39c6a64",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1776,
        -304
      ],
      "id": "d4312610-e978-424c-a8a0-426026c4d4f6",
      "name": "Webhook",
      "webhookId": "8d574598-d977-4052-823a-26def39c6a64"
    },
    {
      "parameters": {
        "jsCode": "const customFields = $input.first().json.customFields;\n\nfunction findField(key, names) {\n  let f = customFields.find(x => x.fieldKey === key);\n  if (!f) {\n    const wanted = names.map(n => n.toLowerCase().trim());\n    f = customFields.find(x => wanted.includes((x.name || \"\").toLowerCase().trim()));\n  }\n  return f || null;\n}\n\nconst sucursalField = findField(\"contact.sucursal\", [\"Sucursal\"]);\nconst tiendaField = findField(\"contact.tienda\", [\"TIENDA\", \"Tienda\"]);\nconst canalField = findField(\"contact.fuente_de_posible_cliente\", [\"CANAL DE ORIGEN\", \"Canal de Origen\"]);\n\n// createdBy.source SOLO viene del GET individual del contacto.\nconst contactResp = $('Obtener Contacto Cuenta Origen - SUCURSAL').item.json;\nconst createdBySource =\n  (contactResp && contactResp.contact && contactResp.contact.createdBy && contactResp.contact.createdBy.source) ||\n  (contactResp && contactResp.createdBy && contactResp.createdBy.source) ||\n  null;\nconst esUsuario = createdBySource === \"WEB_USER\" || createdBySource === \"MOBILE_USER\";\n\nreturn [\n  {\n    json: {\n      sucursal: {\n        id: sucursalField?.id ?? null,\n        name: sucursalField?.name ?? null,\n        fieldKey: sucursalField?.fieldKey ?? null,\n        picklistOptions: sucursalField?.picklistOptions ?? [],\n      },\n      tienda: {\n        id: tiendaField?.id ?? null,\n        name: tiendaField?.name ?? null,\n        fieldKey: tiendaField?.fieldKey ?? null,\n        picklistOptions: tiendaField?.picklistOptions ?? [],\n      },\n      canal: {\n        id: canalField?.id ?? null,\n        name: canalField?.name ?? null,\n        fieldKey: canalField?.fieldKey ?? null,\n        picklistOptions: canalField?.picklistOptions ?? [],\n      },\n      createdBySource: createdBySource,\n      esUsuario: esUsuario,\n    },\n  },\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        32,
        -320
      ],
      "id": "5a1cfe47-862c-4d28-a4ca-57a9f8c54a7c",
      "name": "Buscar \"contact.sucursal\" y \"contact.tienda\""
    },
    {
      "parameters": {
        "databaseId": 63,
        "tableId": 750,
        "limit": 1,
        "additionalOptions": {
          "filters": {
            "fields": [
              {
                "field": 7247,
                "value": "={{ $('Datos API Cuenta Origen - SUCURSAL').item.json['Name Location'] }}"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.baserow",
      "typeVersion": 1.1,
      "position": [
        256,
        -320
      ],
      "id": "a912fac3-25d4-492a-9648-8c472098b9ca",
      "name": "Buscar Sucursal en Verificador de Sucursales",
      "credentials": {
        "baserowApi": {
          "id": "LZztQ3WMpzXjSTIH",
          "name": "Baserow account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/opportunities/search",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2023-02-21"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.API_token }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"locationId\": \"{{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.Location_ID }}\",\n  \"query\": \"{{ $json.contact.email }}\",\n  \"limit\": 20,\n  \"page\": 1\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1152,
        -320
      ],
      "id": "4b899380-fe4a-40ad-80bb-21ef504b30ac",
      "name": "Actualizar Contacto Cuenta Objetivo - SUCURSAL1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 3
          },
          "conditions": [
            {
              "id": "canal-origen-esusuario",
              "leftValue": "={{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.esUsuario }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        720,
        -120
      ],
      "name": "Creado por usuario (Canal de Origen)",
      "id": "49879f5e-7ce8-4ced-b1a6-96df44ac2e0a"
    },
    {
      "parameters": {
        "method": "PUT",
        "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 {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"customFields\": [\n    {\n      \"id\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.canal.id }}\",\n      \"key\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.canal.fieldKey }}\",\n      \"field_value\": \"SUCURSAL\"\n    }\n  ]\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        940,
        -120
      ],
      "name": "PUT Canal de Origen = SUCURSAL",
      "id": "d0597a9c-aca0-40bb-98d8-bb584d2a2c3e"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}/tags",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"tags\": [\"sucursal\"]\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1160,
        -120
      ],
      "name": "Tag+ sucursal",
      "id": "86bfddcb-c402-413f-9d32-c55050dc470d"
    },
    {
      "parameters": {
        "method": "DELETE",
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}/tags",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"tags\": [\"formulario\"]\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1380,
        -120
      ],
      "name": "Tag- formulario",
      "onError": "continueRegularOutput",
      "id": "cbd3cfb2-28d0-44e1-9567-a269382497ae"
    },
    {
      "parameters": {
        "method": "DELETE",
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}/tags",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"tags\": [\"facebook-ads\"]\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1600,
        -120
      ],
      "name": "Tag- facebook-ads",
      "onError": "continueRegularOutput",
      "id": "19bdc2b2-9345-4294-8e59-7f35963f261d"
    }
  ],
  "connections": {
    "Obtener Info de cuenta origen - SUCURSAL": {
      "main": [
        [
          {
            "node": "Datos API Cuenta Origen - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conseguir Custom Cuenta Origen- SUCURSAL": {
      "main": [
        [
          {
            "node": "Buscar \"contact.sucursal\" y \"contact.tienda\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    },
    "Datos API Cuenta Origen - SUCURSAL": {
      "main": [
        [
          {
            "node": "Obtener Contacto Cuenta Origen - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Contacto Cuenta Origen - SUCURSAL": {
      "main": [
        [
          {
            "node": "Conseguir Custom Cuenta Origen- SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Datos de Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Sucursal en Verificador de Sucursales": {
      "main": [
        [
          {
            "node": "Actualizar Contacto Cuenta Objetivo - SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar \"contact.sucursal\" y \"contact.tienda\"": {
      "main": [
        [
          {
            "node": "Buscar Sucursal en Verificador de Sucursales",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Actualizar Contacto Cuenta Objetivo - SUCURSAL": {
      "main": [
        [
          {
            "node": "Creado por usuario (Canal de Origen)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creado por usuario (Canal de Origen)": {
      "main": [
        [
          {
            "node": "PUT Canal de Origen = SUCURSAL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PUT Canal de Origen = SUCURSAL": {
      "main": [
        [
          {
            "node": "Tag+ sucursal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag+ sucursal": {
      "main": [
        [
          {
            "node": "Tag- formulario",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag- formulario": {
      "main": [
        [
          {
            "node": "Tag- facebook-ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "pinData": {
    "Webhook": [
      {
        "json": {
          "headers": {
            "host": "webhookn8.consultoriae3.com",
            "user-agent": "axios/1.13.2",
            "content-length": "1572",
            "accept": "application/json, text/plain, */*",
            "accept-encoding": "gzip, compress, deflate, br",
            "content-type": "application/json",
            "traceparent": "00-bfdb4ad6378402bf71f61ff3c72d0d02-ee175e0dcbcec88e-01",
            "x-forwarded-for": "35.253.135.103",
            "x-forwarded-host": "webhookn8.consultoriae3.com",
            "x-forwarded-port": "443",
            "x-forwarded-proto": "https",
            "x-forwarded-server": "f569f6e85d30",
            "x-real-ip": "35.253.135.103"
          },
          "params": {},
          "query": {},
          "body": {
            "Canal de Origen": "",
            "¿Qué modalidad prefieres?": "Sin Dejarlo (GPS)",
            "Fuente de Prospecto": "GALLARDETES",
            "Marca del Vehiculo": "VW",
            "[Número de WhatsApp para Atender]": "",
            "TIENDA": "",
            "Presupuesto": "",
            "Acepta los terminos para tu cotización": "",
            "Sucursal": "",
            "ID Contacto Monte Providencia": "",
            "Información Adicional": "",
            "[Número de Teléfono para Atender]": "",
            "Version del Vehiculo": "POLO",
            "[Correo_Canalizados]": "",
            "[Correo_Empresa]": "",
            "Check Comunicaciones de Marketing": "",
            "Descripción": "",
            "[Nombre de la Empresa]": "",
            "Año del Vehículo": "2019",
            "[Dirección de la Empresa]": "",
            "¿Cuándo necesitas el dinero?": "",
            "Archivos Adicionales": "",
            "contact_id": "ZHj8ek6lQ6M6EeCIU7Uj",
            "first_name": "LILIA LISSETH",
            "last_name": "ZAVALA HEREDIA",
            "full_name": "LILIA LISSETH ZAVALA HEREDIA",
            "email": "lilia.zh0209@gmail.com",
            "phone": "+524361175941",
            "tags": "sucursal",
            "country": "MX",
            "date_created": "2026-05-25T23:59:53.804Z",
            "full_address": "",
            "contact_type": "lead",
            "location": {
              "name": "85964 - MP - Morelia 1",
              "address": "Morelia",
              "city": "Morelia",
              "state": "Michoacán",
              "country": "MX",
              "postalCode": "58855",
              "fullAddress": "Morelia, Morelia Michoacán 58855",
              "id": "jE41bVhhnb5T505BFm4F"
            },
            "user": {
              "firstName": "Morelia 1 - 85964",
              "lastName": "Morelia 1",
              "email": "ezstore85964@ezcorp.com",
              "phone": "+524434589152"
            },
            "workflow": {
              "id": "7c92fec9-b858-4a83-b2d9-31891c9b9231",
              "name": "Sincronizar Contacto Creado V2"
            },
            "triggerData": {},
            "contact": {
              "attributionSource": {
                "mediumId": null,
                "medium": "manual",
                "sessionSource": "CRM UI"
              },
              "lastAttributionSource": {}
            },
            "attributionSource": {},
            "customData": {}
          },
          "webhookUrl": "https://webhookn8.consultoriae3.com/webhook/8d574598-d977-4052-823a-26def39c6a64",
          "executionMode": "production"
        },
        "pairedItem": {
          "item": 0
        }
      }
    ]
  },
  "versionId": "069558e3-7ce7-463c-ac06-9c18a19f8635",
  "activeVersionId": "069558e3-7ce7-463c-ac06-9c18a19f8635",
  "versionCounter": 229,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-04-20T22:29:00.636Z",
      "createdAt": "2026-04-20T22:29:00.636Z",
      "role": "workflow:owner",
      "workflowId": "ddUEORBEtZLzsQF2",
      "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": [
    {
      "updatedAt": "2025-11-27T05:48:12.272Z",
      "createdAt": "2025-11-27T05:48:12.272Z",
      "id": "pHkPpq3Httzx4hnb",
      "name": "Bucefalo"
    },
    {
      "updatedAt": "2025-12-01T22:00:17.627Z",
      "createdAt": "2025-12-01T22:00:17.627Z",
      "id": "uIWgqVuJXbqA7m39",
      "name": "PRUEBAS"
    }
  ],
  "activeVersion": {
    "updatedAt": "2026-05-30T03:52:09.866Z",
    "createdAt": "2026-05-30T03:52:09.866Z",
    "versionId": "069558e3-7ce7-463c-ac06-9c18a19f8635",
    "workflowId": "ddUEORBEtZLzsQF2",
    "nodes": [
      {
        "parameters": {
          "content": "# De Sucursal a Marca",
          "color": 5
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          -2288,
          -320
        ],
        "typeVersion": 1,
        "id": "d91325e1-1763-486c-a2c9-8cfffddd57b0",
        "name": "Sticky Note3"
      },
      {
        "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": [
          -912,
          -320
        ],
        "id": "50da84c1-c2d3-4a36-91d3-e3745edccdc6",
        "name": "Obtener Info de cuenta origen - SUCURSAL",
        "credentials": {
          "baserowApi": {
            "id": "LZztQ3WMpzXjSTIH",
            "name": "Baserow account"
          }
        }
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/locations/{{ $('Datos API Cuenta Origen - SUCURSAL').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 - SUCURSAL').item.json['Token/API'] }}"
              }
            ]
          },
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          -224,
          -320
        ],
        "id": "a0c27c4c-0f20-4bab-bf6b-bcdd8281a92b",
        "name": "Conseguir Custom Cuenta Origen- SUCURSAL"
      },
      {
        "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": [
          -1392,
          -304
        ],
        "id": "d68558b5-52b8-46b1-a359-fd956c7edc09",
        "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": [
          -1568,
          -304
        ],
        "id": "d0e455ac-7ccc-4c55-bda2-1cd22092e2d2",
        "name": "Datos de Lead"
      },
      {
        "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": [
          -720,
          -320
        ],
        "id": "f0cff3ec-8464-45d4-9e64-713c36e247c6",
        "name": "Datos API Cuenta Origen - SUCURSAL",
        "notes": "Esta en modo prueba forzada para Queretaro"
      },
      {
        "parameters": {
          "content": "# CUENTA ORIGEN",
          "height": 240,
          "width": 1744
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          -976,
          -384
        ],
        "typeVersion": 1,
        "id": "16a74d85-1e6c-4fc7-b854-580a2d3827a0",
        "name": "Sticky Note"
      },
      {
        "parameters": {
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Webhook').item.json.body.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": [
          -400,
          -320
        ],
        "id": "92f33c6e-ee64-409d-8c60-9fbfe48b3265",
        "name": "Obtener Contacto Cuenta Origen - SUCURSAL"
      },
      {
        "parameters": {
          "content": "",
          "height": 176,
          "width": 608,
          "color": 7
        },
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          -448,
          -336
        ],
        "typeVersion": 1,
        "id": "768a4001-5109-493f-b12e-e8ba5d30ec2f",
        "name": "Sticky Note1"
      },
      {
        "parameters": {
          "method": "PUT",
          "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['SC TOKEN BUCEFALO'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"customFields\": [\n    {\n      \"id\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.sucursal.id }}\",\n      \"key\": \"contact.sucursal\",\n      \"field_value\": \"{{ $json.SUCURSAL }}\"\n    },\n    {\n      \"id\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.tienda.id }}\",\n      \"key\": \"contact.tienda\",\n      \"field_value\": \"{{ $json.TIENDA }}\"\n    }\n  ]\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          512,
          -320
        ],
        "id": "794ce5bb-dea0-4720-958a-1f0940c79e6d",
        "name": "Actualizar Contacto Cuenta Objetivo - SUCURSAL"
      },
      {
        "parameters": {
          "httpMethod": "POST",
          "path": "8d574598-d977-4052-823a-26def39c6a64",
          "options": {}
        },
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2.1,
        "position": [
          -1776,
          -304
        ],
        "id": "d4312610-e978-424c-a8a0-426026c4d4f6",
        "name": "Webhook",
        "webhookId": "8d574598-d977-4052-823a-26def39c6a64"
      },
      {
        "parameters": {
          "jsCode": "const customFields = $input.first().json.customFields;\n\nfunction findField(key, names) {\n  let f = customFields.find(x => x.fieldKey === key);\n  if (!f) {\n    const wanted = names.map(n => n.toLowerCase().trim());\n    f = customFields.find(x => wanted.includes((x.name || \"\").toLowerCase().trim()));\n  }\n  return f || null;\n}\n\nconst sucursalField = findField(\"contact.sucursal\", [\"Sucursal\"]);\nconst tiendaField = findField(\"contact.tienda\", [\"TIENDA\", \"Tienda\"]);\nconst canalField = findField(\"contact.fuente_de_posible_cliente\", [\"CANAL DE ORIGEN\", \"Canal de Origen\"]);\n\n// createdBy.source SOLO viene del GET individual del contacto.\nconst contactResp = $('Obtener Contacto Cuenta Origen - SUCURSAL').item.json;\nconst createdBySource =\n  (contactResp && contactResp.contact && contactResp.contact.createdBy && contactResp.contact.createdBy.source) ||\n  (contactResp && contactResp.createdBy && contactResp.createdBy.source) ||\n  null;\nconst esUsuario = createdBySource === \"WEB_USER\" || createdBySource === \"MOBILE_USER\";\n\nreturn [\n  {\n    json: {\n      sucursal: {\n        id: sucursalField?.id ?? null,\n        name: sucursalField?.name ?? null,\n        fieldKey: sucursalField?.fieldKey ?? null,\n        picklistOptions: sucursalField?.picklistOptions ?? [],\n      },\n      tienda: {\n        id: tiendaField?.id ?? null,\n        name: tiendaField?.name ?? null,\n        fieldKey: tiendaField?.fieldKey ?? null,\n        picklistOptions: tiendaField?.picklistOptions ?? [],\n      },\n      canal: {\n        id: canalField?.id ?? null,\n        name: canalField?.name ?? null,\n        fieldKey: canalField?.fieldKey ?? null,\n        picklistOptions: canalField?.picklistOptions ?? [],\n      },\n      createdBySource: createdBySource,\n      esUsuario: esUsuario,\n    },\n  },\n];"
        },
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          32,
          -320
        ],
        "id": "5a1cfe47-862c-4d28-a4ca-57a9f8c54a7c",
        "name": "Buscar \"contact.sucursal\" y \"contact.tienda\""
      },
      {
        "parameters": {
          "databaseId": 63,
          "tableId": 750,
          "limit": 1,
          "additionalOptions": {
            "filters": {
              "fields": [
                {
                  "field": 7247,
                  "value": "={{ $('Datos API Cuenta Origen - SUCURSAL').item.json['Name Location'] }}"
                }
              ]
            }
          }
        },
        "type": "n8n-nodes-base.baserow",
        "typeVersion": 1.1,
        "position": [
          256,
          -320
        ],
        "id": "a912fac3-25d4-492a-9648-8c472098b9ca",
        "name": "Buscar Sucursal en Verificador de Sucursales",
        "credentials": {
          "baserowApi": {
            "id": "LZztQ3WMpzXjSTIH",
            "name": "Baserow account"
          }
        }
      },
      {
        "parameters": {
          "method": "POST",
          "url": "https://services.leadconnectorhq.com/opportunities/search",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2023-02-21"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.API_token }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"locationId\": \"{{ $('Obtener Info de cuenta origen - SUCURSAL').item.json.Location_ID }}\",\n  \"query\": \"{{ $json.contact.email }}\",\n  \"limit\": 20,\n  \"page\": 1\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          1152,
          -320
        ],
        "id": "4b899380-fe4a-40ad-80bb-21ef504b30ac",
        "name": "Actualizar Contacto Cuenta Objetivo - SUCURSAL1"
      },
      {
        "parameters": {
          "conditions": {
            "options": {
              "caseSensitive": true,
              "leftValue": "",
              "typeValidation": "loose",
              "version": 3
            },
            "conditions": [
              {
                "id": "canal-origen-esusuario",
                "leftValue": "={{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.esUsuario }}",
                "rightValue": "",
                "operator": {
                  "type": "boolean",
                  "operation": "true",
                  "singleValue": true
                }
              }
            ],
            "combinator": "and"
          },
          "options": {}
        },
        "type": "n8n-nodes-base.if",
        "typeVersion": 2.3,
        "position": [
          720,
          -120
        ],
        "name": "Creado por usuario (Canal de Origen)",
        "id": "49879f5e-7ce8-4ced-b1a6-96df44ac2e0a"
      },
      {
        "parameters": {
          "method": "PUT",
          "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 {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"customFields\": [\n    {\n      \"id\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.canal.id }}\",\n      \"key\": \"{{ $('Buscar \"contact.sucursal\" y \"contact.tienda\"').item.json.canal.fieldKey }}\",\n      \"field_value\": \"SUCURSAL\"\n    }\n  ]\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          940,
          -120
        ],
        "name": "PUT Canal de Origen = SUCURSAL",
        "id": "d0597a9c-aca0-40bb-98d8-bb584d2a2c3e"
      },
      {
        "parameters": {
          "method": "POST",
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}/tags",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"tags\": [\"sucursal\"]\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          1160,
          -120
        ],
        "name": "Tag+ sucursal",
        "id": "86bfddcb-c402-413f-9d32-c55050dc470d"
      },
      {
        "parameters": {
          "method": "DELETE",
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}/tags",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"tags\": [\"formulario\"]\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          1380,
          -120
        ],
        "name": "Tag- formulario",
        "onError": "continueRegularOutput",
        "id": "cbd3cfb2-28d0-44e1-9567-a269382497ae"
      },
      {
        "parameters": {
          "method": "DELETE",
          "url": "=https://services.leadconnectorhq.com/contacts/{{ $('Datos de Lead').item.json.Cliente['Contact ID'] }}/tags",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Accept",
                "value": "application/json"
              },
              {
                "name": "Version",
                "value": "2021-07-28"
              },
              {
                "name": "Authorization",
                "value": "=Bearer {{ $('Buscar Sucursal en Verificador de Sucursales').item.json['SC TOKEN BUCEFALO'] }}"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={\n  \"tags\": [\"facebook-ads\"]\n}",
          "options": {
            "redirect": {
              "redirect": {}
            }
          }
        },
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          1600,
          -120
        ],
        "name": "Tag- facebook-ads",
        "onError": "continueRegularOutput",
        "id": "19bdc2b2-9345-4294-8e59-7f35963f261d"
      }
    ],
    "connections": {
      "Obtener Info de cuenta origen - SUCURSAL": {
        "main": [
          [
            {
              "node": "Datos API Cuenta Origen - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Conseguir Custom Cuenta Origen- SUCURSAL": {
        "main": [
          [
            {
              "node": "Buscar \"contact.sucursal\" y \"contact.tienda\"",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "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
            }
          ]
        ]
      },
      "Datos API Cuenta Origen - SUCURSAL": {
        "main": [
          [
            {
              "node": "Obtener Contacto Cuenta Origen - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Obtener Contacto Cuenta Origen - SUCURSAL": {
        "main": [
          [
            {
              "node": "Conseguir Custom Cuenta Origen- SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Webhook": {
        "main": [
          [
            {
              "node": "Datos de Lead",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Buscar Sucursal en Verificador de Sucursales": {
        "main": [
          [
            {
              "node": "Actualizar Contacto Cuenta Objetivo - SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Buscar \"contact.sucursal\" y \"contact.tienda\"": {
        "main": [
          [
            {
              "node": "Buscar Sucursal en Verificador de Sucursales",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Actualizar Contacto Cuenta Objetivo - SUCURSAL": {
        "main": [
          [
            {
              "node": "Creado por usuario (Canal de Origen)",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Creado por usuario (Canal de Origen)": {
        "main": [
          [
            {
              "node": "PUT Canal de Origen = SUCURSAL",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "PUT Canal de Origen = SUCURSAL": {
        "main": [
          [
            {
              "node": "Tag+ sucursal",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Tag+ sucursal": {
        "main": [
          [
            {
              "node": "Tag- formulario",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Tag- formulario": {
        "main": [
          [
            {
              "node": "Tag- facebook-ads",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    },
    "authors": "Consultoria E3 ®",
    "name": null,
    "description": null,
    "autosaved": false,
    "workflowPublishHistory": [
      {
        "createdAt": "2026-05-30T03:52:10.342Z",
        "id": 659,
        "workflowId": "ddUEORBEtZLzsQF2",
        "versionId": "069558e3-7ce7-463c-ac06-9c18a19f8635",
        "event": "activated",
        "userId": "74a7f127-b963-4eb0-aff4-1190428e8409"
      }
    ]
  }
}