{
  "name": "Tipo de Cambio \u2192 Email",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "exchange-rate",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Tipo de Cambio",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "asunto",
              "name": "asunto",
              "value": "={{ $json.formatted.asunto }}",
              "type": "string"
            },
            {
              "id": "fecha",
              "name": "fecha",
              "value": "={{ $json.formatted.fecha }}",
              "type": "string"
            },
            {
              "id": "hora",
              "name": "hora",
              "value": "={{ $json.formatted.hora }}",
              "type": "string"
            },
            {
              "id": "compra",
              "name": "compra",
              "value": "={{ $json.formatted.compra }}",
              "type": "string"
            },
            {
              "id": "venta",
              "name": "venta",
              "value": "={{ $json.formatted.venta }}",
              "type": "string"
            },
            {
              "id": "fuente",
              "name": "fuente",
              "value": "={{ $json.formatted.fuente }}",
              "type": "string"
            },
            {
              "id": "usuario",
              "name": "usuario",
              "value": "={{ $json.formatted.usuario }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "format-data",
      "name": "Formatear Datos",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        470,
        300
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $env.NOTIFICATION_EMAIL }}",
        "subject": "={{ $json.asunto }}",
        "message": "=<div style=\"font-family: Arial, sans-serif; max-width: 500px; margin: 0 auto;\">\n  <div style=\"background: linear-gradient(135deg, #22c55e, #16a34a); padding: 20px; border-radius: 10px 10px 0 0;\">\n    <h1 style=\"color: white; margin: 0; font-size: 24px;\">\ud83d\udcb1 Tipo de Cambio</h1>\n    <p style=\"color: rgba(255,255,255,0.9); margin: 5px 0 0 0;\">Actualizaci\u00f3n autom\u00e1tica</p>\n  </div>\n  \n  <div style=\"background: #f8fafc; padding: 25px; border: 1px solid #e2e8f0;\">\n    <table style=\"width: 100%; border-collapse: collapse;\">\n      <tr>\n        <td style=\"padding: 10px 0; border-bottom: 1px solid #e2e8f0;\">\n          <strong>\ud83d\udcc5 Fecha:</strong>\n        </td>\n        <td style=\"padding: 10px 0; border-bottom: 1px solid #e2e8f0; text-align: right;\">\n          {{ $json.fecha }}\n        </td>\n      </tr>\n      <tr>\n        <td style=\"padding: 10px 0; border-bottom: 1px solid #e2e8f0;\">\n          <strong>\u23f0 Hora:</strong>\n        </td>\n        <td style=\"padding: 10px 0; border-bottom: 1px solid #e2e8f0; text-align: right;\">\n          {{ $json.hora }}\n        </td>\n      </tr>\n      <tr>\n        <td style=\"padding: 15px 0; border-bottom: 1px solid #e2e8f0;\">\n          <strong style=\"color: #22c55e; font-size: 18px;\">\ud83d\udcb5 Compra:</strong>\n        </td>\n        <td style=\"padding: 15px 0; border-bottom: 1px solid #e2e8f0; text-align: right;\">\n          <span style=\"font-size: 22px; font-weight: bold; color: #22c55e;\">${{ $json.compra }} MXN</span>\n        </td>\n      </tr>\n      <tr>\n        <td style=\"padding: 15px 0; border-bottom: 1px solid #e2e8f0;\">\n          <strong style=\"color: #ef4444; font-size: 18px;\">\ud83d\udcb5 Venta:</strong>\n        </td>\n        <td style=\"padding: 15px 0; border-bottom: 1px solid #e2e8f0; text-align: right;\">\n          <span style=\"font-size: 22px; font-weight: bold; color: #ef4444;\">${{ $json.venta }} MXN</span>\n        </td>\n      </tr>\n      <tr>\n        <td style=\"padding: 10px 0; border-bottom: 1px solid #e2e8f0;\">\n          <strong>\ud83d\udcca Fuente:</strong>\n        </td>\n        <td style=\"padding: 10px 0; border-bottom: 1px solid #e2e8f0; text-align: right;\">\n          <span style=\"background: #3b82f6; color: white; padding: 3px 10px; border-radius: 12px; font-size: 12px;\">{{ $json.fuente }}</span>\n        </td>\n      </tr>\n      <tr>\n        <td style=\"padding: 10px 0;\">\n          <strong>\ud83d\udc64 Registrado por:</strong>\n        </td>\n        <td style=\"padding: 10px 0; text-align: right;\">\n          {{ $json.usuario }}\n        </td>\n      </tr>\n    </table>\n  </div>\n  \n  <div style=\"background: #1e293b; padding: 15px; border-radius: 0 0 10px 10px; text-align: center;\">\n    <p style=\"color: #94a3b8; margin: 0; font-size: 12px;\">Econova KPI Dashboard \u2022 Grupo Orsega</p>\n  </div>\n</div>",
        "options": {}
      },
      "id": "gmail-send",
      "name": "Enviar Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        690,
        300
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, message: 'Email enviado' }) }}"
      },
      "id": "success-response",
      "name": "Respuesta OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        910,
        300
      ]
    }
  ],
  "connections": {
    "Webhook Tipo de Cambio": {
      "main": [
        [
          {
            "node": "Formatear Datos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Formatear Datos": {
      "main": [
        [
          {
            "node": "Enviar Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar Email": {
      "main": [
        [
          {
            "node": "Respuesta OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3",
  "tags": [
    {
      "name": "tesoreria"
    },
    {
      "name": "tipos-de-cambio"
    }
  ]
}