Files
cotizador-walmart-connect-r…/cotizador-walmart-connect-reporte-usuario-seguro-sin-env.json
T

1015 lines
34 KiB
JSON

{
"updatedAt": "2026-08-22T15:03:47.407Z",
"createdAt": "2026-08-22T15:03:47.407Z",
"id": "5JALWgQdOiSV2uSN",
"name": "Cotizador Walmart Connect - Reporte Usuario Seguro - SIN ENV",
"description": null,
"active": true,
"isArchived": false,
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "cotizador-wmc-reportar",
"responseMode": "responseNode",
"options": {
"allowedOrigins": "*"
}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-1968,
128
],
"id": "99fe33b3-7138-40ee-b129-d8c790365090",
"name": "Webhook - Reportar",
"webhookId": "9d4920cc-7e4a-4168-a84f-8bdc846eb5eb"
},
{
"parameters": {
"jsCode": "const body=$json.body??{}; const headers=$json.headers??{}; const clean=(v,m=5000)=>typeof v==='string'?v.trim().slice(0,m):''; const auth=clean(headers.authorization||headers.Authorization,12000); if(!auth.startsWith('Bearer ')) throw new Error('Falta sesión Supabase.'); const message=clean(body.message,5000); if(!message) throw new Error('El reporte no contiene descripción.'); return [{json:{auth,message,claimedEmail:clean(body.userEmail,320).toLowerCase(),claimedName:clean(body.userName,200),submittedAt:clean(body.submittedAt,100)||new Date().toISOString(),appSessionId:clean(body.appSessionId,250)||`report-${Date.now()}`}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1520,
128
],
"id": "5c2a3294-468b-4d56-970c-f98a1c3eb30c",
"name": "Normalizar reporte"
},
{
"parameters": {
"url": "https://dbit.digitalcompass.agency/auth/v1/user",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
},
{
"name": "Authorization",
"value": "={{ $json.auth }}"
}
]
},
"options": {
"timeout": 20000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-1328,
128
],
"id": "30d516a2-c309-44d7-bdfd-618b91725c06",
"name": "Supabase - validar JWT",
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const req=$node[\"Normalizar reporte\"].json; const u=$json??{}; const id=String(u.id||''); const email=String(u.email||'').trim().toLowerCase(); const jwtValid=Boolean(id&&email.endsWith('@gomezleemarketing.com')&&(!req.claimedEmail||req.claimedEmail===email)); return [{json:{...req,userId:id,verifiedEmail:email,jwtValid}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1104,
128
],
"id": "1e5af2a0-8d05-417a-9a54-d967ebb4d307",
"name": "Validar identidad"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "a9aae0ad-df78-43c8-8bee-eea1e1575b5b",
"leftValue": "={{ $json.jwtValid }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-880,
128
],
"id": "80bd0a76-bf67-4d9f-a672-873579105458",
"name": "JWT válido?"
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ {ok:false,message:'Sesión inválida.'} }}",
"options": {
"responseCode": 401
}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
-656,
368
],
"id": "7ddfb8ce-50b6-437c-882d-4c9a2a92f232",
"name": "Responder 401"
},
{
"parameters": {
"url": "={{ 'https://dbit.digitalcompass.agency/rest/v1/cotizador_wmc_access?select=email,full_name,is_active&email=eq.' + encodeURIComponent($json.verifiedEmail) + '&is_active=eq.true' }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
},
{
"name": "Authorization",
"value": "={{ $json.auth }}"
}
]
},
"options": {
"timeout": 20000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-656,
48
],
"id": "d60c3747-4932-4cd8-8354-12ac0aa85f8c",
"name": "Supabase - acceso",
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const req=$node[\"Validar identidad\"].json; const rows=Array.isArray($json)?$json:[]; const row=rows[0]||null; return [{json:{...req,accessAllowed:Boolean(row&&row.is_active===true),fullName:row?.full_name||req.claimedName||req.verifiedEmail}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-448,
48
],
"id": "e0f173b2-d1ab-4e46-a8ac-4d603b647bbe",
"name": "Validar acceso"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "69a74499-ad7d-4093-9921-133166609367",
"leftValue": "={{ $json.accessAllowed }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-224,
48
],
"id": "d6aff02f-55b6-48f0-85a3-1061b3181974",
"name": "Acceso permitido?"
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ {ok:false,message:'No tienes acceso activo al Cotizador WMC.'} }}",
"options": {
"responseCode": 403
}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
0,
352
],
"id": "12c9912b-4e40-4a3f-aba2-ae583b6c4431",
"name": "Responder 403"
},
{
"parameters": {
"jsCode": "const x=$node[\"Validar acceso\"].json;\nconst esc=v=>String(v??'').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\"/g,'&quot;').replace(/'/g,'&#039;');\nlet date=x.submittedAt; try{date=new Intl.DateTimeFormat('es-DO',{dateStyle:'long',timeStyle:'short',timeZone:'America/Santo_Domingo'}).format(new Date(x.submittedAt));}catch{}\nconst html=`<!doctype html><html lang=\"es\"><body style=\"margin:0;background:#F5F5F5;font-family:Arial,Helvetica,sans-serif;color:#4A4A4A\"><table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding:28px 12px;background:#F5F5F5\"><tr><td align=\"center\"><table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"max-width:660px;background:#fff;border:1px solid #D0D0D0\"><tr><td style=\"height:4px;background:#6CC24A\"></td></tr><tr><td style=\"padding:28px 34px 10px\"><img src=\"https://dbit.digitalcompass.agency/storage/v1/object/public/public-assets/GLM_completo.png\" width=\"190\" alt=\"GomezLee Marketing\" style=\"display:block;max-width:100%;height:auto\"></td></tr><tr><td style=\"padding:18px 34px 0\"><div style=\"font-size:11px;font-weight:700;letter-spacing:1.5px;color:#6CC24A\">COTIZADOR WMC · REPORTE DE USUARIO</div><h1 style=\"margin:8px 0 0;font-size:24px;line-height:30px;color:#4F758B\">Nuevo reporte recibido</h1></td></tr><tr><td style=\"padding:24px 34px 0\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;font-size:13px\"><tr><td style=\"width:125px;padding:9px 12px;background:#EEF6E8;border:1px solid #D0D0D0;font-weight:700;color:#4F758B\">Usuario</td><td style=\"padding:9px 12px;border:1px solid #D0D0D0\">${esc(x.fullName)}</td></tr><tr><td style=\"padding:9px 12px;background:#EEF6E8;border:1px solid #D0D0D0;font-weight:700;color:#4F758B\">Correo</td><td style=\"padding:9px 12px;border:1px solid #D0D0D0\">${esc(x.verifiedEmail)}</td></tr><tr><td style=\"padding:9px 12px;background:#EEF6E8;border:1px solid #D0D0D0;font-weight:700;color:#4F758B\">Fecha</td><td style=\"padding:9px 12px;border:1px solid #D0D0D0\">${esc(date)}</td></tr></table></td></tr><tr><td style=\"padding:24px 34px 0\"><div style=\"font-size:11px;font-weight:700;letter-spacing:1px;color:#4F758B;border-bottom:2px solid #6CC24A;padding-bottom:7px\">DESCRIPCIÓN DEL REPORTE</div><div style=\"margin-top:14px;padding:16px 18px;background:#F5F5F5;border:1px solid #D0D0D0;font-size:14px;line-height:22px\">${esc(x.message).replace(/\\n/g,'<br>')}</div></td></tr><tr><td style=\"padding:28px 34px 30px\"><div style=\"border-top:1px solid #D0D0D0;padding-top:12px;font-size:11px;font-style:italic;color:#6B8FA3\">CONFIDENCIAL — Uso interno GomezLee Marketing · Mensaje generado automáticamente desde Cotizador Walmart Connect.</div></td></tr></table></td></tr></table></body></html>`;\nreturn [{json:{...x,to:'iaracena@gomezleemarketing.com',subject:`[Cotizador WMC] Reporte de usuario - ${x.fullName}`,html}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
0,
0
],
"id": "2926807e-09e5-4e6a-950e-04935eea8692",
"name": "Preparar correo GLM"
},
{
"parameters": {
"sendTo": "={{ $json.to }}",
"subject": "={{ $json.subject }}",
"message": "={{ $json.html }}",
"options": {
"appendAttribution": false,
"senderName": "Cotizador Walmart Connect"
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
224,
0
],
"id": "31e372fb-0f07-411e-804a-76c37850aa6e",
"name": "Enviar a Isaac",
"webhookId": "26bd0d0a-d6b2-4c16-b3da-6b22456cc880",
"credentials": {
"gmailOAuth2": {
"id": "UDcO1FLJqA453V2D",
"name": "Gmail account 3"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/glm_track_app_event",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
},
{
"name": "Authorization",
"value": "={{ $node[\"Preparar correo GLM\"].json.auth }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/json",
"body": "={{ JSON.stringify({p_app_key:'cotizador_wmc',p_event_name:'report_submitted',p_session_id:$node[\"Preparar correo GLM\"].json.appSessionId,p_metadata:{length:$node[\"Preparar correo GLM\"].json.message.length},p_entity_type:'report',p_entity_id:null,p_display_name:$node[\"Preparar correo GLM\"].json.fullName}) }}",
"options": {
"timeout": 20000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
448,
0
],
"id": "c2bd31d4-3755-4434-9287-0931224f9b90",
"name": "Registrar métrica reporte",
"continueOnFail": true
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ {ok:true,message:'Reporte enviado correctamente.'} }}",
"options": {
"responseCode": 200
}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
672,
0
],
"id": "1d11fc02-2e04-44bb-a728-31d3d626e28f",
"name": "Responder OK"
},
{
"parameters": {
"jsCode": "// Configuración local del workflow: no usa variables de entorno.\nreturn [{json:{...$json,config:{supabaseUrl:\"https://dbit.digitalcompass.agency\",supabaseAnonKey:\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE\"}}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1744,
128
],
"id": "9d1eb2b2-8fb9-4689-8b9b-3ddeefbf05b4",
"name": "Configuración - sin ENV"
}
],
"connections": {
"Webhook - Reportar": {
"main": [
[
{
"node": "Configuración - sin ENV",
"type": "main",
"index": 0
}
]
]
},
"Normalizar reporte": {
"main": [
[
{
"node": "Supabase - validar JWT",
"type": "main",
"index": 0
}
]
]
},
"Supabase - validar JWT": {
"main": [
[
{
"node": "Validar identidad",
"type": "main",
"index": 0
}
]
]
},
"Validar identidad": {
"main": [
[
{
"node": "JWT válido?",
"type": "main",
"index": 0
}
]
]
},
"JWT válido?": {
"main": [
[
{
"node": "Supabase - acceso",
"type": "main",
"index": 0
}
],
[
{
"node": "Responder 401",
"type": "main",
"index": 0
}
]
]
},
"Supabase - acceso": {
"main": [
[
{
"node": "Validar acceso",
"type": "main",
"index": 0
}
]
]
},
"Validar acceso": {
"main": [
[
{
"node": "Acceso permitido?",
"type": "main",
"index": 0
}
]
]
},
"Acceso permitido?": {
"main": [
[
{
"node": "Preparar correo GLM",
"type": "main",
"index": 0
}
],
[
{
"node": "Responder 403",
"type": "main",
"index": 0
}
]
]
},
"Preparar correo GLM": {
"main": [
[
{
"node": "Enviar a Isaac",
"type": "main",
"index": 0
}
]
]
},
"Registrar métrica reporte": {
"main": [
[
{
"node": "Responder OK",
"type": "main",
"index": 0
}
]
]
},
"Enviar a Isaac": {
"main": [
[
{
"node": "Registrar métrica reporte",
"type": "main",
"index": 0
}
]
]
},
"Configuración - sin ENV": {
"main": [
[
{
"node": "Normalizar reporte",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1",
"binaryMode": "separate"
},
"staticData": null,
"meta": null,
"versionId": "595e83c9-ea18-4d33-855a-8666fbcb0304",
"activeVersionId": "595e83c9-ea18-4d33-855a-8666fbcb0304",
"versionCounter": 3,
"triggerCount": 1,
"shared": [
{
"updatedAt": "2026-08-22T15:03:47.414Z",
"createdAt": "2026-08-22T15:03:47.414Z",
"role": "workflow:owner",
"workflowId": "5JALWgQdOiSV2uSN",
"projectId": "PJpTANzTXIFibWsW",
"project": {
"updatedAt": "2026-04-22T14:25:09.686Z",
"createdAt": "2026-04-22T14:22:54.790Z",
"id": "PJpTANzTXIFibWsW",
"name": "Isaac Aracena <iaracena@gomezleemarketing.com>",
"type": "personal",
"icon": null,
"description": null,
"creatorId": "0a88c0b1-928e-4412-896e-c5d1c99b2029"
}
}
],
"tags": [],
"activeVersion": {
"updatedAt": "2026-08-22T15:04:29.000Z",
"createdAt": "2026-08-22T15:03:47.417Z",
"versionId": "595e83c9-ea18-4d33-855a-8666fbcb0304",
"workflowId": "5JALWgQdOiSV2uSN",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "cotizador-wmc-reportar",
"responseMode": "responseNode",
"options": {
"allowedOrigins": "*"
}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-1968,
128
],
"id": "99fe33b3-7138-40ee-b129-d8c790365090",
"name": "Webhook - Reportar",
"webhookId": "9d4920cc-7e4a-4168-a84f-8bdc846eb5eb"
},
{
"parameters": {
"jsCode": "const body=$json.body??{}; const headers=$json.headers??{}; const clean=(v,m=5000)=>typeof v==='string'?v.trim().slice(0,m):''; const auth=clean(headers.authorization||headers.Authorization,12000); if(!auth.startsWith('Bearer ')) throw new Error('Falta sesión Supabase.'); const message=clean(body.message,5000); if(!message) throw new Error('El reporte no contiene descripción.'); return [{json:{auth,message,claimedEmail:clean(body.userEmail,320).toLowerCase(),claimedName:clean(body.userName,200),submittedAt:clean(body.submittedAt,100)||new Date().toISOString(),appSessionId:clean(body.appSessionId,250)||`report-${Date.now()}`}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1520,
128
],
"id": "5c2a3294-468b-4d56-970c-f98a1c3eb30c",
"name": "Normalizar reporte"
},
{
"parameters": {
"url": "https://dbit.digitalcompass.agency/auth/v1/user",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
},
{
"name": "Authorization",
"value": "={{ $json.auth }}"
}
]
},
"options": {
"timeout": 20000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-1328,
128
],
"id": "30d516a2-c309-44d7-bdfd-618b91725c06",
"name": "Supabase - validar JWT",
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const req=$node[\"Normalizar reporte\"].json; const u=$json??{}; const id=String(u.id||''); const email=String(u.email||'').trim().toLowerCase(); const jwtValid=Boolean(id&&email.endsWith('@gomezleemarketing.com')&&(!req.claimedEmail||req.claimedEmail===email)); return [{json:{...req,userId:id,verifiedEmail:email,jwtValid}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1104,
128
],
"id": "1e5af2a0-8d05-417a-9a54-d967ebb4d307",
"name": "Validar identidad"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "a9aae0ad-df78-43c8-8bee-eea1e1575b5b",
"leftValue": "={{ $json.jwtValid }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-880,
128
],
"id": "80bd0a76-bf67-4d9f-a672-873579105458",
"name": "JWT válido?"
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ {ok:false,message:'Sesión inválida.'} }}",
"options": {
"responseCode": 401
}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
-656,
368
],
"id": "7ddfb8ce-50b6-437c-882d-4c9a2a92f232",
"name": "Responder 401"
},
{
"parameters": {
"url": "={{ 'https://dbit.digitalcompass.agency/rest/v1/cotizador_wmc_access?select=email,full_name,is_active&email=eq.' + encodeURIComponent($json.verifiedEmail) + '&is_active=eq.true' }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
},
{
"name": "Authorization",
"value": "={{ $json.auth }}"
}
]
},
"options": {
"timeout": 20000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-656,
48
],
"id": "d60c3747-4932-4cd8-8354-12ac0aa85f8c",
"name": "Supabase - acceso",
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const req=$node[\"Validar identidad\"].json; const rows=Array.isArray($json)?$json:[]; const row=rows[0]||null; return [{json:{...req,accessAllowed:Boolean(row&&row.is_active===true),fullName:row?.full_name||req.claimedName||req.verifiedEmail}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-448,
48
],
"id": "e0f173b2-d1ab-4e46-a8ac-4d603b647bbe",
"name": "Validar acceso"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "69a74499-ad7d-4093-9921-133166609367",
"leftValue": "={{ $json.accessAllowed }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-224,
48
],
"id": "d6aff02f-55b6-48f0-85a3-1061b3181974",
"name": "Acceso permitido?"
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ {ok:false,message:'No tienes acceso activo al Cotizador WMC.'} }}",
"options": {
"responseCode": 403
}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
0,
352
],
"id": "12c9912b-4e40-4a3f-aba2-ae583b6c4431",
"name": "Responder 403"
},
{
"parameters": {
"jsCode": "const x=$node[\"Validar acceso\"].json;\nconst esc=v=>String(v??'').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\"/g,'&quot;').replace(/'/g,'&#039;');\nlet date=x.submittedAt; try{date=new Intl.DateTimeFormat('es-DO',{dateStyle:'long',timeStyle:'short',timeZone:'America/Santo_Domingo'}).format(new Date(x.submittedAt));}catch{}\nconst html=`<!doctype html><html lang=\"es\"><body style=\"margin:0;background:#F5F5F5;font-family:Arial,Helvetica,sans-serif;color:#4A4A4A\"><table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding:28px 12px;background:#F5F5F5\"><tr><td align=\"center\"><table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"max-width:660px;background:#fff;border:1px solid #D0D0D0\"><tr><td style=\"height:4px;background:#6CC24A\"></td></tr><tr><td style=\"padding:28px 34px 10px\"><img src=\"https://dbit.digitalcompass.agency/storage/v1/object/public/public-assets/GLM_completo.png\" width=\"190\" alt=\"GomezLee Marketing\" style=\"display:block;max-width:100%;height:auto\"></td></tr><tr><td style=\"padding:18px 34px 0\"><div style=\"font-size:11px;font-weight:700;letter-spacing:1.5px;color:#6CC24A\">COTIZADOR WMC · REPORTE DE USUARIO</div><h1 style=\"margin:8px 0 0;font-size:24px;line-height:30px;color:#4F758B\">Nuevo reporte recibido</h1></td></tr><tr><td style=\"padding:24px 34px 0\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;font-size:13px\"><tr><td style=\"width:125px;padding:9px 12px;background:#EEF6E8;border:1px solid #D0D0D0;font-weight:700;color:#4F758B\">Usuario</td><td style=\"padding:9px 12px;border:1px solid #D0D0D0\">${esc(x.fullName)}</td></tr><tr><td style=\"padding:9px 12px;background:#EEF6E8;border:1px solid #D0D0D0;font-weight:700;color:#4F758B\">Correo</td><td style=\"padding:9px 12px;border:1px solid #D0D0D0\">${esc(x.verifiedEmail)}</td></tr><tr><td style=\"padding:9px 12px;background:#EEF6E8;border:1px solid #D0D0D0;font-weight:700;color:#4F758B\">Fecha</td><td style=\"padding:9px 12px;border:1px solid #D0D0D0\">${esc(date)}</td></tr></table></td></tr><tr><td style=\"padding:24px 34px 0\"><div style=\"font-size:11px;font-weight:700;letter-spacing:1px;color:#4F758B;border-bottom:2px solid #6CC24A;padding-bottom:7px\">DESCRIPCIÓN DEL REPORTE</div><div style=\"margin-top:14px;padding:16px 18px;background:#F5F5F5;border:1px solid #D0D0D0;font-size:14px;line-height:22px\">${esc(x.message).replace(/\\n/g,'<br>')}</div></td></tr><tr><td style=\"padding:28px 34px 30px\"><div style=\"border-top:1px solid #D0D0D0;padding-top:12px;font-size:11px;font-style:italic;color:#6B8FA3\">CONFIDENCIAL — Uso interno GomezLee Marketing · Mensaje generado automáticamente desde Cotizador Walmart Connect.</div></td></tr></table></td></tr></table></body></html>`;\nreturn [{json:{...x,to:'iaracena@gomezleemarketing.com',subject:`[Cotizador WMC] Reporte de usuario - ${x.fullName}`,html}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
0,
0
],
"id": "2926807e-09e5-4e6a-950e-04935eea8692",
"name": "Preparar correo GLM"
},
{
"parameters": {
"sendTo": "={{ $json.to }}",
"subject": "={{ $json.subject }}",
"message": "={{ $json.html }}",
"options": {
"appendAttribution": false,
"senderName": "Cotizador Walmart Connect"
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
224,
0
],
"id": "31e372fb-0f07-411e-804a-76c37850aa6e",
"name": "Enviar a Isaac",
"webhookId": "26bd0d0a-d6b2-4c16-b3da-6b22456cc880",
"credentials": {
"gmailOAuth2": {
"id": "UDcO1FLJqA453V2D",
"name": "Gmail account 3"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/glm_track_app_event",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
},
{
"name": "Authorization",
"value": "={{ $node[\"Preparar correo GLM\"].json.auth }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/json",
"body": "={{ JSON.stringify({p_app_key:'cotizador_wmc',p_event_name:'report_submitted',p_session_id:$node[\"Preparar correo GLM\"].json.appSessionId,p_metadata:{length:$node[\"Preparar correo GLM\"].json.message.length},p_entity_type:'report',p_entity_id:null,p_display_name:$node[\"Preparar correo GLM\"].json.fullName}) }}",
"options": {
"timeout": 20000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
448,
0
],
"id": "c2bd31d4-3755-4434-9287-0931224f9b90",
"name": "Registrar métrica reporte",
"continueOnFail": true
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ {ok:true,message:'Reporte enviado correctamente.'} }}",
"options": {
"responseCode": 200
}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
672,
0
],
"id": "1d11fc02-2e04-44bb-a728-31d3d626e28f",
"name": "Responder OK"
},
{
"parameters": {
"jsCode": "// Configuración local del workflow: no usa variables de entorno.\nreturn [{json:{...$json,config:{supabaseUrl:\"https://dbit.digitalcompass.agency\",supabaseAnonKey:\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE\"}}}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1744,
128
],
"id": "9d1eb2b2-8fb9-4689-8b9b-3ddeefbf05b4",
"name": "Configuración - sin ENV"
}
],
"connections": {
"Webhook - Reportar": {
"main": [
[
{
"node": "Configuración - sin ENV",
"type": "main",
"index": 0
}
]
]
},
"Normalizar reporte": {
"main": [
[
{
"node": "Supabase - validar JWT",
"type": "main",
"index": 0
}
]
]
},
"Supabase - validar JWT": {
"main": [
[
{
"node": "Validar identidad",
"type": "main",
"index": 0
}
]
]
},
"Validar identidad": {
"main": [
[
{
"node": "JWT válido?",
"type": "main",
"index": 0
}
]
]
},
"JWT válido?": {
"main": [
[
{
"node": "Supabase - acceso",
"type": "main",
"index": 0
}
],
[
{
"node": "Responder 401",
"type": "main",
"index": 0
}
]
]
},
"Supabase - acceso": {
"main": [
[
{
"node": "Validar acceso",
"type": "main",
"index": 0
}
]
]
},
"Validar acceso": {
"main": [
[
{
"node": "Acceso permitido?",
"type": "main",
"index": 0
}
]
]
},
"Acceso permitido?": {
"main": [
[
{
"node": "Preparar correo GLM",
"type": "main",
"index": 0
}
],
[
{
"node": "Responder 403",
"type": "main",
"index": 0
}
]
]
},
"Preparar correo GLM": {
"main": [
[
{
"node": "Enviar a Isaac",
"type": "main",
"index": 0
}
]
]
},
"Registrar métrica reporte": {
"main": [
[
{
"node": "Responder OK",
"type": "main",
"index": 0
}
]
]
},
"Enviar a Isaac": {
"main": [
[
{
"node": "Registrar métrica reporte",
"type": "main",
"index": 0
}
]
]
},
"Configuración - sin ENV": {
"main": [
[
{
"node": "Normalizar reporte",
"type": "main",
"index": 0
}
]
]
}
},
"authors": "Isaac Aracena",
"name": "Version 595e83c9",
"description": "",
"autosaved": true,
"workflowPublishHistory": [
{
"createdAt": "2026-08-22T15:04:29.600Z",
"id": 5129,
"workflowId": "5JALWgQdOiSV2uSN",
"versionId": "595e83c9-ea18-4d33-855a-8666fbcb0304",
"event": "activated",
"userId": "0a88c0b1-928e-4412-896e-c5d1c99b2029"
}
]
}
}