{ "name": "Cruces GLM - Reporte de Usuario", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "cruces-glm-reportar", "responseMode": "responseNode", "options": { "allowedOrigins": "*" } }, "type": "n8n-nodes-base.webhook", "typeVersion": 2.1, "position": [ -520, 0 ], "id": "afc06b7b-4fb3-4ea2-997d-4656ede7e206", "name": "Webhook - Reportar", "webhookId": "0baf1e89-c6ee-4c05-805f-0a42c5cd6045" }, { "parameters": { "jsCode": "const body = $json.body ?? {};\n\nconst clean = (value, fallback = \"\") => {\n const text = typeof value === \"string\" ? value.trim() : \"\";\n return text || fallback;\n};\n\nconst escapeHtml = (value) =>\n String(value)\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n\nconst userEmail = clean(body.userEmail, \"Usuario no identificado\");\nconst userName = clean(body.userName, userEmail);\nconst rawMessage = clean(body.message);\n\nif (!rawMessage) {\n throw new Error(\"El reporte llegó sin mensaje. No se enviará el correo.\");\n}\n\nconst message = rawMessage.slice(0, 5000);\nconst submittedAt = clean(body.submittedAt, new Date().toISOString());\n\nlet dateLabel = submittedAt;\ntry {\n dateLabel = new Intl.DateTimeFormat(\"es-DO\", {\n dateStyle: \"long\",\n timeStyle: \"short\",\n timeZone: \"America/Santo_Domingo\",\n }).format(new Date(submittedAt));\n} catch {}\n\nconst htmlMessage = escapeHtml(message).replace(/\\n/g, \"
\");\nconst safeName = escapeHtml(userName);\nconst safeEmail = escapeHtml(userEmail);\nconst safeDate = escapeHtml(dateLabel);\n\nconst html = `\n\n\n \n \n\n\n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 
\n \"GomezLee\n
\n
CRUCES GLM · REPORTE DE USUARIO
\n

Nuevo reporte recibido

\n

Un usuario envió un reporte desde la aplicación Cruces GLM.

\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
Usuario${safeName}
Correo${safeEmail}
Fecha${safeDate}
\n
\n
MENSAJE DEL USUARIO
\n
${htmlMessage}
\n
\n
CONFIDENCIAL — Uso interno GomezLee Marketing · Mensaje generado automáticamente desde Cruces GLM.
\n
\n
\n\n`;\n\nreturn [{\n json: {\n to: \"iaracena@gomezleemarketing.com\",\n subject: `[Cruces GLM] Reporte de usuario - ${userName}`,\n html,\n userEmail,\n userName,\n message,\n submittedAt,\n },\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -260, 0 ], "id": "d02ea9a9-8bab-4389-beb6-67b6cb430968", "name": "Preparar correo GLM" }, { "parameters": { "sendTo": "={{ $json.to }}", "subject": "={{ $json.subject }}", "emailType": "html", "message": "={{ $json.html }}", "options": { "appendAttribution": false, "senderName": "Cruces GLM" } }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [ 0, 0 ], "id": "aedf8c14-992d-4c68-a8ed-d3fb82633b57", "name": "Enviar a Isaac - Seleccionar credencial Gmail" }, { "parameters": { "respondWith": "json", "responseBody": "={{ { ok: true, message: 'Reporte enviado correctamente.' } }}", "options": { "responseCode": 200 } }, "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.4, "position": [ 280, 0 ], "id": "6c112a4a-74e7-440d-92db-c0cb5d442bf4", "name": "Responder OK" } ], "connections": { "Preparar correo GLM": { "main": [ [ { "node": "Enviar a Isaac - Seleccionar credencial Gmail", "type": "main", "index": 0 } ] ] }, "Enviar a Isaac - Seleccionar credencial Gmail": { "main": [ [ { "node": "Responder OK", "type": "main", "index": 0 } ] ] }, "Webhook - Reportar": { "main": [ [ { "node": "Preparar correo GLM", "type": "main", "index": 0 } ] ] } }, "pinData": {}, "settings": { "executionOrder": "v1" }, "active": false, "versionId": "1237b5ba-d249-4b3e-b361-664fdc821f60", "meta": { "templateCredsSetupCompleted": false }, "tags": [] }