Files
MP-Manager/n8n/dryrun_ddUEORBEtZLzsQF2_20260529_215100.json
T
2026-05-30 14:31:19 -06:00

855 lines
25 KiB
JSON

{
"name": "[2004][Monte Providencia] Actualizar \"contact.sucursal\", \"contact.tienda\" al crear contacto",
"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": "1de171d0-af2b-400b-9f13-09fc5ea3526a"
},
{
"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": "8e49d480-89da-4279-9529-774b141eb66e"
},
{
"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": "a5d7de79-61f7-482a-b2a4-67f80cb1b237"
},
{
"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": "c1059239-9e91-4e9a-b757-3111689c73f7"
},
{
"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": "52ce0b09-1c36-43ea-a420-f4a3adb3d5f9"
}
],
"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"
}
}