{
  "name": "Logixb2b — Tracker ROI de IA comercial",
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "Schedule lunes → métricas agregadas → ROI simple → Sheets + Slack. Sin PII de leads."
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Madrid"
  },
  "active": false,
  "pinData": {},
  "tags": [
    {
      "name": "Logixb2b"
    },
    {
      "name": "recursos"
    },
    {
      "name": "roi"
    },
    {
      "name": "ia"
    }
  ],
  "nodes": [
    {
      "id": "sticky-instrucciones-logix",
      "name": "INSTRUCCIONES (conectar + VPS)",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -480,
        40
      ],
      "parameters": {
        "content": "## INSTRUCCIONES — Tracker ROI de IA comercial\n\n**Recurso:** `/recursos/roi-ia-tracker-comercial`\n**Guía:** /como-medir-roi-ia-equipo-comercial-b2b\n**Zona:** Europe/Madrid · `active: false` al importar (tú lo activas).\n\n### 1) Importar\n1. n8n → ⋯ → **Import from File** → este JSON.\n2. El flujo llega **inactive**. No pegues secretos en el lienzo ni en el archivo.\n\n### 2) Credenciales y configuración por nodo\n- **Lunes 09:30 Madrid** (`schedule`): sin credencial. Revisa expresión cron / intervalo y zona **Europe/Madrid** (settings del workflow). Solo dispara si n8n está **Active** 24/7.\n- **Config ROI** (`Set` Config): **no lleva credencial**. Aquí van URLs/placeholders (`REEMPLAZA_*`, `example.com`, `TU-CRM`). Sustituye todos antes de Active.\n- **Métricas semanales** (`Set`): sin credencial. Revisa expresiones `={{ }}` y campos de salida.\n- **Calcular ROI** (`Set`): sin credencial. Revisa expresiones `={{ }}` y campos de salida.\n- **Append ROI Sheets** (`HTTP Request` Sheets): mejor migrar a nodo Google Sheets; si dejas HTTP, usa OAuth2 Bearer de Google.\n- **Slack reporte ROI semanal** (`HTTP Request` → Slack/Teams): crea Incoming Webhook en Slack (o Adaptive Card URL en Teams). Pega la URL en **Config** o en este nodo. Auth: none (la URL ya es secreta).\n\n### 3) Orden recomendado de puesta en marcha\n1. Rellena el nodo **Config** (URLs reales, umbrales, webhooks de Slack).\n2. Crea Credentials en n8n (candado de cada nodo HTTP / Sheets / OpenAI) y **enlázalas**.\n3. Ejecuta **una vez** (Manual / Test URL del Webhook / \"Execute workflow\").\n4. Verifica CRM + Slack/Sheets (y que la IA no escriba en producción sin HITL).\n5. Solo entonces: interruptor **Active**.\n\n### 4) Producción 24/7 en VPS (UE)\nImportar en localhost no basta: webhooks y cron necesitan n8n encendido.\n\n1. VPS en UE (Hetzner/OVH/IONOS…) + Docker Compose + **Postgres** + HTTPS (Caddy/Nginx).\n2. Variables mínimas: `GENERIC_TIMEZONE=Europe/Madrid`, `WEBHOOK_URL=https://n8n.tudominio.com/`, `N8N_ENCRYPTION_KEY`, `N8N_HOST` / `N8N_PROTOCOL=https`.\n3. Firewall: solo 80/443 (+ SSH). Backups del volumen Postgres + export de workflows.\n4. Importa este JSON en la instancia de producción, vuelve a crear Credentials (no se copian solas), actualiza URLs del Config al dominio real.\n5. Pon **Active**. Prueba el Webhook de producción o espera el próximo cron.\n6. Alternativa: **n8n Cloud** (mismo JSON; Credentials en la UI Cloud).\n\n### 5) RGPD + EU AI Act (resumen)\nSi hay nodos IA sois **deployers** (Reglamento UE 2024/1689). Art. 4 alfabetización. **HITL** antes de outreach, scores masivos o pausas de cuenta. Minimiza PII en Slack/logs. Informativo — no es asesoramiento legal. /uso-responsable-de-ia-y-transparencia\n",
        "height": 1500,
        "width": 580,
        "color": 4
      }
    },
    {
      "id": "sched-monday",
      "name": "Lunes 09:30 Madrid",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "30 9 * * 1"
            }
          ]
        }
      }
    },
    {
      "id": "set-config",
      "name": "Config ROI",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        300,
        300
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "c1",
              "name": "sheetsAppendUrl",
              "value": "https://sheets.googleapis.com/v4/spreadsheets/TU_SHEET_ID/values/ROI!A1:append?valueInputOption=USER_ENTERED",
              "type": "string"
            },
            {
              "id": "c2",
              "name": "slackWebhookUrl",
              "value": "https://example.com/aviso-equipo-slack",
              "type": "string"
            },
            {
              "id": "c3",
              "name": "hourlyRate",
              "value": 45,
              "type": "number"
            },
            {
              "id": "c4",
              "name": "metricsSourceUrl",
              "value": "https://sheets.googleapis.com/v4/spreadsheets/TU_SHEET_ID/values/InputROI!A2:D2",
              "type": "string"
            },
            {
              "id": "c5",
              "name": "useRemoteMetrics",
              "value": false,
              "type": "boolean"
            }
          ]
        }
      }
    },
    {
      "id": "set-metrics",
      "name": "Métricas semanales",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        600,
        300
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "m1",
              "name": "weekLabel",
              "value": "={{ $now.toFormat('yyyy') + '-W' + $now.weekNumber }}",
              "type": "string"
            },
            {
              "id": "m2",
              "name": "team",
              "value": "Comercial ES",
              "type": "string"
            },
            {
              "id": "m3",
              "name": "hoursSaved",
              "value": 12,
              "type": "number"
            },
            {
              "id": "m4",
              "name": "toolCost",
              "value": 180,
              "type": "number"
            },
            {
              "id": "m5",
              "name": "revenueInfluence",
              "value": 2500,
              "type": "number"
            },
            {
              "id": "m6",
              "name": "hourlyRate",
              "value": "={{ $('Config ROI').item.json.hourlyRate }}",
              "type": "number"
            },
            {
              "id": "m7",
              "name": "sheetsAppendUrl",
              "value": "={{ $('Config ROI').item.json.sheetsAppendUrl }}",
              "type": "string"
            },
            {
              "id": "m8",
              "name": "slackWebhookUrl",
              "value": "={{ $('Config ROI').item.json.slackWebhookUrl }}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "id": "set-calc",
      "name": "Calcular ROI",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        900,
        300
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "r1",
              "name": "weekLabel",
              "value": "={{ $json.weekLabel }}",
              "type": "string"
            },
            {
              "id": "r2",
              "name": "team",
              "value": "={{ $json.team }}",
              "type": "string"
            },
            {
              "id": "r3",
              "name": "hoursSaved",
              "value": "={{ $json.hoursSaved }}",
              "type": "number"
            },
            {
              "id": "r4",
              "name": "toolCost",
              "value": "={{ $json.toolCost }}",
              "type": "number"
            },
            {
              "id": "r5",
              "name": "revenueInfluence",
              "value": "={{ $json.revenueInfluence }}",
              "type": "number"
            },
            {
              "id": "r6",
              "name": "timeValue",
              "value": "={{ Number($json.hoursSaved) * Number($json.hourlyRate) }}",
              "type": "number"
            },
            {
              "id": "r7",
              "name": "netBenefit",
              "value": "={{ Number($json.hoursSaved) * Number($json.hourlyRate) + Number($json.revenueInfluence) - Number($json.toolCost) }}",
              "type": "number"
            },
            {
              "id": "r8",
              "name": "roiPct",
              "value": "={{ Number($json.toolCost) > 0 ? Math.round(((Number($json.hoursSaved) * Number($json.hourlyRate) + Number($json.revenueInfluence) - Number($json.toolCost)) / Number($json.toolCost)) * 10000) / 100 : 0 }}",
              "type": "number"
            },
            {
              "id": "r9",
              "name": "sheetsAppendUrl",
              "value": "={{ $json.sheetsAppendUrl }}",
              "type": "string"
            },
            {
              "id": "r10",
              "name": "slackWebhookUrl",
              "value": "={{ $json.slackWebhookUrl }}",
              "type": "string"
            },
            {
              "id": "r11",
              "name": "reportedAt",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "id": "http-sheets",
      "name": "Append ROI Sheets",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        40
      ],
      "parameters": {
        "method": "POST",
        "url": "={{ $json.sheetsAppendUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ values: [[ $json.reportedAt, $json.weekLabel, $json.team, $json.hoursSaved, $json.toolCost, $json.revenueInfluence, $json.timeValue, $json.netBenefit, $json.roiPct ]] }) }}",
        "options": {
          "timeout": 30000
        }
      }
    },
    {
      "id": "http-slack",
      "name": "Slack reporte ROI semanal",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        560
      ],
      "parameters": {
        "method": "POST",
        "url": "={{ $json.slackWebhookUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: $json.slackText || 'Actualización Logixb2b' }) }}",
        "options": {
          "timeout": 10000
        }
      }
    }
  ],
  "connections": {
    "Lunes 09:30 Madrid": {
      "main": [
        [
          {
            "node": "Config ROI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config ROI": {
      "main": [
        [
          {
            "node": "Métricas semanales",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Métricas semanales": {
      "main": [
        [
          {
            "node": "Calcular ROI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calcular ROI": {
      "main": [
        [
          {
            "node": "Append ROI Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack reporte ROI semanal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
