AutomationFlowsData & Sheets › Etiquetas

Etiquetas

etiquetas. Uses postgres, httpRequest. Webhook trigger; 7 nodes.

Webhook trigger★★★★☆ complexity7 nodesPostgresHTTP Request
Data & Sheets Trigger: Webhook Nodes: 7 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Postgres recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "etiquetas",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "internal/etiquetas",
        "responseMode": "responseNode"
      },
      "id": "wh",
      "name": "Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// body: { tipo: 'producto'|'envio', items: [{sku?, ov_numero?}], copias?: 1 }\nconst { tipo, items: list = [], copias = 1 } = items[0].json.body;\nconst out = [];\nfor (const it of list) for (let i=0;i<copias;i++) out.push({ json: { tipo, ...it } });\nreturn out;"
      },
      "id": "expand",
      "name": "Expandir copias",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT v.sku, p.nombre AS producto,\n       (SELECT string_agg(va.valor, ' / ') FROM variante_valores vv\n        JOIN valores_atributo va ON va.id = vv.valor_atributo_id\n        WHERE vv.variante_id = v.id) AS variante,\n       v.barcode\nFROM variantes v JOIN productos p ON p.id = v.producto_id\nWHERE v.sku = $1;",
        "options": {
          "queryReplacement": "={{ $json.sku }}"
        }
      },
      "id": "data",
      "name": "Datos variante",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        680,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "http://labels:3001/barcode/dataurl",
        "method": "POST",
        "sendBody": true,
        "jsonBody": "={ \"text\": \"{{ $json.barcode || $json.sku }}\", \"type\": \"code128\" }"
      },
      "id": "bar",
      "name": "Generar barcode",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Junta todas las etiquetas en un array para renderizar el grid.\nconst etiquetas = items.map(it => ({\n  sku: it.json.sku, producto: it.json.producto,\n  variante: it.json.variante, barcode_data_url: it.json.dataUrl\n}));\nconst fs = require('fs');\nconst tpl = fs.readFileSync('/templates/etiqueta_producto.html','utf8');\nfunction render(tpl, ctx) {\n  tpl = tpl.replace(/\\{\\{#each (\\w+)\\}\\}([\\s\\S]*?)\\{\\{\\/each\\}\\}/g, (_, k, body) => (ctx[k]||[]).map(it => render(body, { ...ctx, ...it })).join(''));\n  tpl = tpl.replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (_, p) => { const v = p.split('.').reduce((o,k)=>o==null?o:o[k], ctx); return v==null?'':String(v); });\n  return tpl;\n}\nreturn [{ json: { html: render(tpl, { etiquetas }) } }];"
      },
      "id": "compose",
      "name": "Componer HTML",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://gotenberg:3000/forms/chromium/convert/html",
        "method": "POST",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "files",
              "inputDataFieldName": "html_file"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "pdf",
      "name": "PDF",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1340,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "binary",
        "responseBody": "={{$binary.data}}"
      },
      "id": "resp",
      "name": "Devolver PDF",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1560,
        300
      ]
    }
  ],
  "connections": {
    "Trigger": {
      "main": [
        [
          {
            "node": "Expandir copias",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expandir copias": {
      "main": [
        [
          {
            "node": "Datos variante",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Datos variante": {
      "main": [
        [
          {
            "node": "Generar barcode",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generar barcode": {
      "main": [
        [
          {
            "node": "Componer HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Componer HTML": {
      "main": [
        [
          {
            "node": "PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF": {
      "main": [
        [
          {
            "node": "Devolver PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

etiquetas. Uses postgres, httpRequest. Webhook trigger; 7 nodes.

Source: https://github.com/bytemok/P/blob/420be2ab06f74f6499aa4a2b44761aec596e2005/workflows/etiquetas.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.

HTTP Request, Postgres, @Apify/N8N Nodes Apify
Data & Sheets

Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.

HTTP Request, Postgres, Error Trigger
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1