{
  "name": "Notificaciones Inventario",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "inventario/reporte",
        "responseMode": "lastNode",
        "options": {}
      },
      "name": "Webhook Inventario",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        460,
        340
      ]
    },
    {
      "parameters": {
        "authentication": "senderAuth",
        "fromEmail": "sistema@clinica.com",
        "toEmail": "logistica@clinica.com",
        "subject": "={{ $json.body.titulo + ' - ' + $json.body.fecha }}",
        "text": "={{ $json.body.titulo + '\\n\\nProductos:\\n' + $json.body.productos.map(p => '- ' + p.nombre + ': Stock ' + p.stockActual + ' (Min: ' + p.stockMinimo + ') [' + p.estado + ']').join('\\n') }}",
        "html": "={{ '<h1>' + $json.body.titulo + '</h1><p>Fecha: ' + $json.body.fecha + '</p><table border=\"1\"><thead><tr><th>Producto</th><th>Stock Actual</th><th>M\u00ednimo</th><th>Estado</th></tr></thead><tbody>' + $json.body.productos.map(p => '<tr><td>' + p.nombre + '</td><td>' + p.stockActual + '</td><td>' + p.stockMinimo + '</td><td style=\"color: ' + (p.estado === 'CR\u00cdTICO' ? 'red' : 'green') + '\">' + p.estado + '</td></tr>').join('') + '</tbody></table>' }}",
        "options": {}
      },
      "name": "Enviar Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        680,
        340
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook Inventario": {
      "main": [
        [
          {
            "node": "Enviar Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}