INTGFTQLXAT

    Shared 5/8/2026

    2 views

    Visual Workflow

    JSON Code

    {
      "meta": {
        "instanceId": "caa3a4f3cf4bd1febbc51905d18d8a5e42c73487864ead07712e49c4d72296f4",
        "templateCredsSetupCompleted": true
      },
      "nodes": [
        {
          "id": "bac3f732-448f-4300-9285-a18c1b6f7d67",
          "name": "Handler",
          "type": "n8n-nodes-base.webhook",
          "notes": "Recebe requisição para buscar ficha técnica",
          "position": [
            -368,
            16
          ],
          "webhookId": "c7991897-9557-4b26-b093-d1e487e57340",
          "parameters": {
            "path": "/private/atlas/qualiex/ficha-tecnica",
            "options": {},
            "responseData": "firstEntryBinary",
            "responseMode": "lastNode"
          },
          "typeVersion": 2.1
        },
        {
          "id": "63a7b6c5-f3fd-4231-ae08-fa754f4764b6",
          "name": "GET - Token",
          "type": "n8n-nodes-base.executeWorkflow",
          "notes": "Gera um novo token de autenticação na API da Qualiex",
          "position": [
            -192,
            16
          ],
          "parameters": {
            "options": {},
            "workflowId": {
              "__rl": true,
              "mode": "list",
              "value": "2QMxQAxngIgOultq",
              "cachedResultUrl": "/n8n/workflow/2QMxQAxngIgOultq",
              "cachedResultName": "Login"
            },
            "workflowInputs": {
              "value": {},
              "mappingMode": "defineBelow"
            }
          },
          "typeVersion": 1.3
        },
        {
          "id": "e1785586-aa01-4bfa-a347-1da41b15e854",
          "name": "GET - File",
          "type": "n8n-nodes-base.httpRequest",
          "notes": "Busca identificador do arquivo da respectiva ficha técnica",
          "position": [
            -16,
            16
          ],
          "parameters": {
            "url": "https://api.qualiex.com.br/v1/Files",
            "options": {},
            "sendQuery": true,
            "queryParameters": {
              "parameters": [
                {
                  "name": "token",
                  "value": "={{ $json.Token }}"
                },
                {
                  "name": "folderIdentifier",
                  "value": "5KFOX62Q2ML4F11"
                },
                {
                  "name": "name",
                  "value": "={{ $('Handler').item.json.query.name }}"
                }
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "adfb4a78-f280-4f1c-b9c2-eb833d62a80d",
          "name": "GET - ViewFile HTML",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            160,
            16
          ],
          "parameters": {
            "url": "https://api.qualiex.com.br/v1/Files/ViewFile",
            "options": {
              "response": {
                "response": {
                  "responseFormat": "text"
                }
              }
            },
            "sendQuery": true,
            "queryParameters": {
              "parameters": [
                {
                  "name": "token",
                  "value": "={{ $('GET - Token').item.json.Token }}"
                },
                {
                  "name": "identifier",
                  "value": "={{ $json.identifier }}"
                }
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "48446408-d4a8-4032-95b8-2011433b7371",
          "name": "Extract PDF URL",
          "type": "n8n-nodes-base.code",
          "position": [
            336,
            16
          ],
          "parameters": {
            "mode": "runOnceForEachItem",
            "jsCode": "const { URL } = require('url');\n\nconst html = $input.item.json.data;\n\n// 1. Extrai src do iframe\nconst iframeMatch = html.match(/src=\"(https:\\/\\/apps1\\.qualiex\\.com\\/Shared\\/PDFMobile[^\"]+)\"/);\nif (!iframeMatch) throw new Error('Não foi possível extrair URL do iframe');\n\n// 2. Extrai e decodifica o parâmetro `file`\nconst iframeUrl = new URL(iframeMatch[1]);\nconst fileParam = iframeUrl.searchParams.get('file');\nif (!fileParam) throw new Error('Parâmetro file não encontrado na URL do iframe');\n\nconst decodedFile = decodeURIComponent(fileParam);\n\n// 3. Monta a URL final do PDF\nconst pdfUrl = `https://apps1.qualiex.com${decodedFile}`;\n\nreturn { json: { pdfUrl } };"
          },
          "typeVersion": 2
        },
        {
          "id": "d8add7d0-c72f-435b-ac5c-ccbc3bfdfa90",
          "name": "GET - PDF Binary",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            512,
            16
          ],
          "parameters": {
            "url": "={{ $json.pdfUrl }}",
            "options": {
              "response": {
                "response": {
                  "responseFormat": "file"
                }
              }
            }
          },
          "typeVersion": 4.2
        }
      ],
      "pinData": {
        "Handler": [
          {
            "body": {
              "name": "ESTAMPO FECHAMENTO PAINEL 4Q AGILE 26"
            },
            "query": {},
            "params": {},
            "headers": {
              "host": "app.mify.com.br",
              "accept": "application/json, text/plain, */*",
              "x-real-ip": "172.19.0.6",
              "connection": "close",
              "user-agent": "axios/1.13.6",
              "content-type": "application/json",
              "content-length": "48",
              "accept-encoding": "gzip, compress, deflate, br",
              "x-forwarded-for": "172.19.0.6",
              "x-forwarded-proto": "https"
            },
            "webhookUrl": "https://app.mify.com.br/n8n/webhook/private/atlas/qualiex/ficha-tecnica",
            "executionMode": "production"
          }
        ]
      },
      "connections": {
        "Handler": {
          "main": [
            [
              {
                "node": "GET - Token",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "GET - File": {
          "main": [
            [
              {
                "node": "GET - ViewFile HTML",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "GET - Token": {
          "main": [
            [
              {
                "node": "GET - File",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Extract PDF URL": {
          "main": [
            [
              {
                "node": "GET - PDF Binary",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "GET - ViewFile HTML": {
          "main": [
            [
              {
                "node": "Extract PDF URL",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }