{
  "id": "5BSgMV8ZAb6KIsJ8",
  "createdAt": "2023-08-07T22:41:44.287Z",
  "updatedAt": "2024-01-31T13:00:59.736Z",
  "name": "Base Bloqueados a DW",
  "active": true,
  "nodes": [
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nconst uniqueItems = [];\nconst seenValues = {};\n\nfor (let i = $input.all().length - 1; i >= 0; i--) {\n  const item = $input.all()[i];\n  const rut = item.json['Rut'].toString().replace('k', 'K').replace(/[-.\\n]/g, '');\n  \n  if (!seenValues[rut]) {\n    uniqueItems.unshift(item);\n    seenValues[rut] = true;\n  }\n}\n\nreturn uniqueItems;\n\n\n"
      },
      "id": "a5615094-294e-4ad2-af5e-16bac4568b11",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        20
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=insert into banned_enterprises (document_number, comments, pais, condicion)\nvalues ('{{ $json[\"document_number\"] }}','{{ $json[\"comments\"] }}','{{ $json[\"pais\"] }}','{{ $json[\"condicion\"] }}' )\non duplicate key update comments = '{{ $json[\"comments\"] }}', condicion = '{{ $json[\"condicion\"] }}', pais = '{{ $json[\"pais\"] }}';",
        "options": {}
      },
      "id": "f3927862-5af3-429b-89f8-d6f2b5222f44",
      "name": "MySQL",
      "type": "n8n-nodes-base.mySql",
      "position": [
        1080,
        20
      ],
      "typeVersion": 2.1,
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "document_number",
              "value": "={{ $json.Rut }}"
            },
            {
              "name": "comments",
              "value": "={{ $json['Comentarios de bloqueo'] }}"
            },
            {
              "name": "pais",
              "value": "={{ $json.Pais }}"
            },
            {
              "name": "condicion",
              "value": "={{ $json.Condicion }}"
            }
          ]
        },
        "options": {}
      },
      "id": "d93212e6-1ada-42b2-869a-92b232694435",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "position": [
        540,
        20
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.document_number }}",
              "operation": "notEqual",
              "value2": "={{ '' }}"
            }
          ]
        }
      },
      "id": "efa69546-55b5-4acc-bba7-49f297a2f500",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        720,
        20
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "hour": 10
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E/edit?usp=drivesdk",
          "cachedResultName": "CL Panel de Riesgo"
        },
        "sheetName": {
          "__rl": true,
          "value": 1336374792,
          "mode": "list",
          "cachedResultName": "Bloqueados 2",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E/edit#gid=1336374792"
        },
        "options": {}
      },
      "id": "21adb461-a461-4bc4-86c5-221a699b5580",
      "name": "Llamar Bloqueados",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        20,
        20
      ],
      "typeVersion": 1,
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "MySQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Llamar Bloqueados": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "staticData": {
    "node:Llamar Post-confirmado": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 394331852,
      "lastRevision": 5706,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=5706&exportFormat=xlsx"
    },
    "node:Llamar Lista Link": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 1713282289,
      "lastRevision": 5706,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=5706&exportFormat=xlsx"
    },
    "node:Llamar Grupos econ\u00f3micos": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 924453781,
      "lastRevision": 5706,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=5706&exportFormat=xlsx"
    },
    "node:Llamar Bloqueados": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 1336374792,
      "lastRevision": 10334,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=10334&exportFormat=xlsx"
    },
    "node:Llamar Comit\u00e9": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 1052543507,
      "lastRevision": 5706,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=5706&exportFormat=xlsx"
    },
    "node:Llamar Lista Pagadores": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 924696945,
      "lastRevision": 5706,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=5706&exportFormat=xlsx"
    }
  },
  "versionId": "41768bf0-d8e1-420b-8b1f-6d8bb3b5bcda",
  "triggerCount": 1,
  "tags": []
}