{
"updatedAt": "2026-07-31T14:19:35.665Z",
"createdAt": "2026-07-24T19:13:05.914Z",
"id": "cFu3Xx23KQBKfr0M",
"name": "Seguimiento de Impuestos GLM - Recordatorios Gmail y Google Chat",
"description": null,
"active": true,
"isArchived": false,
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "0 8 * * *"
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-32,
1456
],
"id": "d9890ecf-a9ba-4604-9a68-03568e80bbe5",
"name": "Diario 8:00 AM"
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-32,
1616
],
"id": "58d5e31d-10bb-4dec-af43-d3ea3225a4ad",
"name": "Ejecutar manualmente"
},
{
"parameters": {
"httpMethod": "POST",
"path": "seguimiento-impuestos",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-32,
1808
],
"id": "b1a94a40-005a-419c-9d3d-697b95d16749",
"name": "Webhook seguimiento-impuestos",
"webhookId": "seguimiento-impuestos-glm"
},
{
"parameters": {
"jsCode": "function dateInTimeZone(timeZone) {\n const parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n }).formatToParts(new Date());\n const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));\n return `${values.year}-${values.month}-${values.day}`;\n}\n\nconst input = $json ?? {};\nconst runDate = input.run_date || dateInTimeZone('America/Santo_Domingo');\n\nreturn [{\n json: {\n run_date: runDate,\n source: input.source || 'schedule',\n },\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
224,
1536
],
"id": "da51143c-6cbd-4ea1-a49e-d0c4b097b952",
"name": "Preparar ejecución"
},
{
"parameters": {
"jsCode": "const body = $json.body ?? $json;\nconst action = String(body.action ?? '').trim().toLowerCase();\n\nif (!['run_now', 'run_reminders', 'ejecutar_recordatorios'].includes(action)) {\n return [];\n}\n\nreturn [{\n json: {\n run_date: body.run_date || body.date || '',\n source: 'webhook',\n },\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
224,
1808
],
"id": "0863e7a7-bc95-42f6-982f-f09f859ec6d6",
"name": "Validar ejecución por Webhook"
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/tax_due_reminders",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { p_run_date: $json.run_date } }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
480,
1616
],
"id": "00dfa1be-5e07-4860-8322-d9f490ac4e4a",
"name": "Supabase - Recordatorios pendientes"
},
{
"parameters": {
"jsCode": "const htmlEscape = (value) => String(value ?? '')\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n\nconst rows = [];\nfor (const item of $input.all()) {\n const value = item.json;\n if (Array.isArray(value)) rows.push(...value);\n else if (Array.isArray(value?.data)) rows.push(...value.data);\n else if (Array.isArray(value?.body)) rows.push(...value.body);\n else if (value?.obligation_id) rows.push(value);\n}\n\nconst logoUrl = 'https://home.digitalcompass.agency/glm-logo-completo.png';\nconst appUrl = 'https://digitalcompass.agency/calendario-impuestos/';\n\nconst formatDate = (iso) => {\n const [year, month, day] = String(iso).split('-').map(Number);\n return new Intl.DateTimeFormat('es-DO', {\n timeZone: 'UTC',\n day: '2-digit',\n month: 'long',\n year: 'numeric',\n }).format(new Date(Date.UTC(year, month - 1, day)));\n};\n\nreturn rows.map((row) => {\n const dueDate = formatDate(row.due_date);\n const isSameDay = row.alert_type === 'same_day';\n const reminderLabel = isSameDay ? 'Vence hoy' : 'Recordatorio previo';\n const categoryLabel = row.category === 'nomina' ? 'Nómina' : 'Administración';\n const firstName = String(row.contact_name ?? '').trim().split(/\\s+/)[0] || 'equipo';\n const subject = `${isSameDay ? 'Vence hoy' : 'Recordatorio'} · ${row.country_name} · ${row.description}`;\n\n const emailHtml = `\n\n\n
\n \n \n \n }\") | \n | | \n | \n ${htmlEscape(reminderLabel)} \n Seguimiento de Impuestos GLM\n Hola ${htmlEscape(firstName)}, este es el recordatorio correspondiente a la siguiente obligación tributaria: \n \n | País | ${htmlEscape(row.country_name)} | \n | Categoría | ${htmlEscape(categoryLabel)} | \n | Fecha límite | ${htmlEscape(dueDate)} | \n | Obligación | ${htmlEscape(row.description)} | \n \n Este aviso forma parte del seguimiento automático: miércoles anterior y fecha límite, incluidos sábados y domingos. \n \n | \n | GOMEZLEE MARKETING | Seguimiento de Impuestos GLM | Uso interno | \n \n |
\n
\n \n`.trim();\n\n const googleChatText = [\n `*${reminderLabel.toUpperCase()} · SEGUIMIENTO DE IMPUESTOS GLM*`,\n '',\n `Hola ${firstName},`,\n '',\n `*País:* ${row.country_name}`,\n `*Categoría:* ${categoryLabel}`,\n `*Fecha límite:* ${dueDate}`,\n `*Obligación:* ${row.description}`,\n '',\n 'Seguimiento automático: miércoles anterior y fecha límite, incluidos sábados y domingos.',\n '',\n `Abrir calendario: ${appUrl}`,\n ].join('\\n');\n\n return {\n json: {\n ...row,\n email_subject: subject,\n email_html: emailHtml,\n google_chat_text: googleChatText,\n },\n };\n});"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
736,
1616
],
"id": "780bc937-c373-43cc-9343-e3c73d076934",
"name": "Construir mensajes GLM"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.email_enabled === true && String(item.json.contact_email ?? '').trim());"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1008,
1472
],
"id": "343dc1d3-cb5b-452c-b5d4-f69583b15280",
"name": "Preparar correos"
},
{
"parameters": {
"sendTo": "={{ $json.contact_email }}",
"subject": "={{ $json.email_subject }}",
"message": "={{ $json.email_html }}",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
1264,
1472
],
"id": "7f16857a-3674-4255-9674-cc040682f518",
"name": "Gmail - Enviar recordatorio",
"webhookId": "16bfebbd-f4e3-4b1e-aba2-028fecf98da1",
"credentials": {
"gmailOAuth2": {
"id": "UDcO1FLJqA453V2D",
"name": "Gmail account 3"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/tax_record_notification",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { p_obligation_id: $('Preparar correos').item.json.obligation_id, p_contact_id: $('Preparar correos').item.json.contact_id, p_alert_date: $('Preparar correos').item.json.alert_date, p_channel: 'email', p_status: 'sent', p_provider_response: $json } }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
1520,
1472
],
"id": "bea9fc06-b8de-4091-bde0-d7be8c18e4cd",
"name": "Supabase - Registrar correo"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.google_chat_enabled === true && String(item.json.contact_email ?? '').trim());"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1008,
1744
],
"id": "3addf2bd-60c2-493c-8919-56b603aad7e8",
"name": "Preparar Google Chat"
},
{
"parameters": {
"method": "POST",
"url": "https://chat.googleapis.com/v1/spaces:setup",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleChatOAuth2Api",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { space: { spaceType: 'DIRECT_MESSAGE', singleUserBotDm: false }, memberships: [ { member: { name: 'users/' + $json.contact_email, type: 'HUMAN' } } ] } }}",
"options": {
"timeout": 30000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
1264,
1744
],
"id": "630cdc84-f7aa-4db8-8356-942056f3ac22",
"name": "Google Chat - Abrir DM",
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1500,
"credentials": {
"googleChatOAuth2Api": {
"id": "V4eVQvEoy5QcBvUu",
"name": "Chat account"
}
},
"onError": "continueRegularOutput"
},
{
"parameters": {
"jsCode": "const source = $('Preparar Google Chat').item.json;\nconst spaceName = String($json.name ?? '').trim();\nreturn [{ json: { ...source, chat_space_name: spaceName, chat_setup_ok: Boolean(spaceName), google_chat_status: spaceName ? 'pending' : 'failed', google_chat_provider_response: $json } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1520,
1744
],
"id": "1002151d-cb96-46c1-9868-3e9aca7846c0",
"name": "Evaluar DM Google Chat"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.chat_setup_ok === true);"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1776,
1632
],
"id": "5978dd34-7cb2-46be-9536-65c22b7f06a4",
"name": "Preparar envío Google Chat"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.chat_setup_ok !== true);"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1776,
1888
],
"id": "cbc9f8d3-35f8-48a2-9251-c85c96d15be0",
"name": "Preparar fallo DM Google Chat"
},
{
"parameters": {
"method": "POST",
"url": "={{ 'https://chat.googleapis.com/v1/' + $json.chat_space_name + '/messages' }}",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleChatOAuth2Api",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { text: $json.google_chat_text, createMessageNotificationOptions: { notificationType: 'NOTIFICATION_TYPE_FORCE_NOTIFY' } } }}",
"options": {
"timeout": 30000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
2032,
1632
],
"id": "d4d67181-4079-4a46-9fd7-a10afe57db71",
"name": "Google Chat - Enviar recordatorio",
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1500,
"credentials": {
"googleChatOAuth2Api": {
"id": "V4eVQvEoy5QcBvUu",
"name": "Chat account"
}
},
"onError": "continueRegularOutput"
},
{
"parameters": {
"jsCode": "const source = $('Preparar envío Google Chat').item.json;\nconst sent = Boolean($json.name) && !$json.error;\nreturn [{ json: { ...source, google_chat_status: sent ? 'sent' : 'failed', google_chat_provider_response: $json } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2288,
1632
],
"id": "6398165b-9e0a-483f-9db6-71f0d85a69d0",
"name": "Evaluar envío Google Chat"
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/tax_record_notification",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { p_obligation_id: $json.obligation_id, p_contact_id: $json.contact_id, p_alert_date: $json.alert_date, p_channel: 'google_chat', p_status: $json.google_chat_status, p_provider_response: $json.google_chat_provider_response } }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
2544,
1744
],
"id": "29a93cc5-c157-4199-81c1-1fed7664edc6",
"name": "Supabase - Registrar Google Chat"
}
],
"connections": {
"Diario 8:00 AM": {
"main": [
[
{
"node": "Preparar ejecución",
"type": "main",
"index": 0
}
]
]
},
"Ejecutar manualmente": {
"main": [
[
{
"node": "Preparar ejecución",
"type": "main",
"index": 0
}
]
]
},
"Webhook seguimiento-impuestos": {
"main": [
[
{
"node": "Validar ejecución por Webhook",
"type": "main",
"index": 0
}
]
]
},
"Preparar ejecución": {
"main": [
[
{
"node": "Supabase - Recordatorios pendientes",
"type": "main",
"index": 0
}
]
]
},
"Validar ejecución por Webhook": {
"main": [
[
{
"node": "Preparar ejecución",
"type": "main",
"index": 0
}
]
]
},
"Supabase - Recordatorios pendientes": {
"main": [
[
{
"node": "Construir mensajes GLM",
"type": "main",
"index": 0
}
]
]
},
"Construir mensajes GLM": {
"main": [
[
{
"node": "Preparar correos",
"type": "main",
"index": 0
},
{
"node": "Preparar Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Preparar correos": {
"main": [
[
{
"node": "Gmail - Enviar recordatorio",
"type": "main",
"index": 0
}
]
]
},
"Gmail - Enviar recordatorio": {
"main": [
[
{
"node": "Supabase - Registrar correo",
"type": "main",
"index": 0
}
]
]
},
"Preparar Google Chat": {
"main": [
[
{
"node": "Google Chat - Abrir DM",
"type": "main",
"index": 0
}
]
]
},
"Google Chat - Abrir DM": {
"main": [
[
{
"node": "Evaluar DM Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Evaluar DM Google Chat": {
"main": [
[
{
"node": "Preparar envío Google Chat",
"type": "main",
"index": 0
},
{
"node": "Preparar fallo DM Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Preparar envío Google Chat": {
"main": [
[
{
"node": "Google Chat - Enviar recordatorio",
"type": "main",
"index": 0
}
]
]
},
"Google Chat - Enviar recordatorio": {
"main": [
[
{
"node": "Evaluar envío Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Evaluar envío Google Chat": {
"main": [
[
{
"node": "Supabase - Registrar Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Preparar fallo DM Google Chat": {
"main": [
[
{
"node": "Supabase - Registrar Google Chat",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1",
"binaryMode": "separate",
"availableInMCP": true,
"timeSavedMode": "fixed",
"errorWorkflow": "puF4LUczoSz3hcek",
"timezone": "America/Santo_Domingo",
"callerPolicy": "workflowsFromSameOwner"
},
"staticData": {
"node:Diario 8:00 AM": {
"recurrenceRules": []
}
},
"meta": {
"templateCredsSetupCompleted": true
},
"versionId": "29d1a109-07ab-4b9c-a381-790a18c89e58",
"activeVersionId": "29d1a109-07ab-4b9c-a381-790a18c89e58",
"versionCounter": 86,
"triggerCount": 2,
"shared": [
{
"updatedAt": "2026-07-24T19:13:05.942Z",
"createdAt": "2026-07-24T19:13:05.942Z",
"role": "workflow:owner",
"workflowId": "cFu3Xx23KQBKfr0M",
"projectId": "PJpTANzTXIFibWsW",
"project": {
"updatedAt": "2026-04-22T14:25:09.686Z",
"createdAt": "2026-04-22T14:22:54.790Z",
"id": "PJpTANzTXIFibWsW",
"name": "Isaac Aracena ",
"type": "personal",
"icon": null,
"description": null,
"creatorId": "0a88c0b1-928e-4412-896e-c5d1c99b2029"
}
}
],
"tags": [],
"activeVersion": {
"updatedAt": "2026-07-31T14:19:36.000Z",
"createdAt": "2026-07-31T14:19:35.667Z",
"versionId": "29d1a109-07ab-4b9c-a381-790a18c89e58",
"workflowId": "cFu3Xx23KQBKfr0M",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "0 8 * * *"
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-32,
1456
],
"id": "d9890ecf-a9ba-4604-9a68-03568e80bbe5",
"name": "Diario 8:00 AM"
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-32,
1616
],
"id": "58d5e31d-10bb-4dec-af43-d3ea3225a4ad",
"name": "Ejecutar manualmente"
},
{
"parameters": {
"httpMethod": "POST",
"path": "seguimiento-impuestos",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-32,
1808
],
"id": "b1a94a40-005a-419c-9d3d-697b95d16749",
"name": "Webhook seguimiento-impuestos",
"webhookId": "seguimiento-impuestos-glm"
},
{
"parameters": {
"jsCode": "function dateInTimeZone(timeZone) {\n const parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n }).formatToParts(new Date());\n const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));\n return `${values.year}-${values.month}-${values.day}`;\n}\n\nconst input = $json ?? {};\nconst runDate = input.run_date || dateInTimeZone('America/Santo_Domingo');\n\nreturn [{\n json: {\n run_date: runDate,\n source: input.source || 'schedule',\n },\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
224,
1536
],
"id": "da51143c-6cbd-4ea1-a49e-d0c4b097b952",
"name": "Preparar ejecución"
},
{
"parameters": {
"jsCode": "const body = $json.body ?? $json;\nconst action = String(body.action ?? '').trim().toLowerCase();\n\nif (!['run_now', 'run_reminders', 'ejecutar_recordatorios'].includes(action)) {\n return [];\n}\n\nreturn [{\n json: {\n run_date: body.run_date || body.date || '',\n source: 'webhook',\n },\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
224,
1808
],
"id": "0863e7a7-bc95-42f6-982f-f09f859ec6d6",
"name": "Validar ejecución por Webhook"
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/tax_due_reminders",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { p_run_date: $json.run_date } }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
480,
1616
],
"id": "00dfa1be-5e07-4860-8322-d9f490ac4e4a",
"name": "Supabase - Recordatorios pendientes"
},
{
"parameters": {
"jsCode": "const htmlEscape = (value) => String(value ?? '')\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n\nconst rows = [];\nfor (const item of $input.all()) {\n const value = item.json;\n if (Array.isArray(value)) rows.push(...value);\n else if (Array.isArray(value?.data)) rows.push(...value.data);\n else if (Array.isArray(value?.body)) rows.push(...value.body);\n else if (value?.obligation_id) rows.push(value);\n}\n\nconst logoUrl = 'https://home.digitalcompass.agency/glm-logo-completo.png';\nconst appUrl = 'https://digitalcompass.agency/calendario-impuestos/';\n\nconst formatDate = (iso) => {\n const [year, month, day] = String(iso).split('-').map(Number);\n return new Intl.DateTimeFormat('es-DO', {\n timeZone: 'UTC',\n day: '2-digit',\n month: 'long',\n year: 'numeric',\n }).format(new Date(Date.UTC(year, month - 1, day)));\n};\n\nreturn rows.map((row) => {\n const dueDate = formatDate(row.due_date);\n const isSameDay = row.alert_type === 'same_day';\n const reminderLabel = isSameDay ? 'Vence hoy' : 'Recordatorio previo';\n const categoryLabel = row.category === 'nomina' ? 'Nómina' : 'Administración';\n const firstName = String(row.contact_name ?? '').trim().split(/\\s+/)[0] || 'equipo';\n const subject = `${isSameDay ? 'Vence hoy' : 'Recordatorio'} · ${row.country_name} · ${row.description}`;\n\n const emailHtml = `\n\n\n \n \n \n \n }\") | \n | | \n | \n ${htmlEscape(reminderLabel)} \n Seguimiento de Impuestos GLM\n Hola ${htmlEscape(firstName)}, este es el recordatorio correspondiente a la siguiente obligación tributaria: \n \n | País | ${htmlEscape(row.country_name)} | \n | Categoría | ${htmlEscape(categoryLabel)} | \n | Fecha límite | ${htmlEscape(dueDate)} | \n | Obligación | ${htmlEscape(row.description)} | \n \n Este aviso forma parte del seguimiento automático: miércoles anterior y fecha límite, incluidos sábados y domingos. \n \n | \n | GOMEZLEE MARKETING | Seguimiento de Impuestos GLM | Uso interno | \n \n |
\n
\n \n`.trim();\n\n const googleChatText = [\n `*${reminderLabel.toUpperCase()} · SEGUIMIENTO DE IMPUESTOS GLM*`,\n '',\n `Hola ${firstName},`,\n '',\n `*País:* ${row.country_name}`,\n `*Categoría:* ${categoryLabel}`,\n `*Fecha límite:* ${dueDate}`,\n `*Obligación:* ${row.description}`,\n '',\n 'Seguimiento automático: miércoles anterior y fecha límite, incluidos sábados y domingos.',\n '',\n `Abrir calendario: ${appUrl}`,\n ].join('\\n');\n\n return {\n json: {\n ...row,\n email_subject: subject,\n email_html: emailHtml,\n google_chat_text: googleChatText,\n },\n };\n});"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
736,
1616
],
"id": "780bc937-c373-43cc-9343-e3c73d076934",
"name": "Construir mensajes GLM"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.email_enabled === true && String(item.json.contact_email ?? '').trim());"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1008,
1472
],
"id": "343dc1d3-cb5b-452c-b5d4-f69583b15280",
"name": "Preparar correos"
},
{
"parameters": {
"sendTo": "={{ $json.contact_email }}",
"subject": "={{ $json.email_subject }}",
"message": "={{ $json.email_html }}",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
1264,
1472
],
"id": "7f16857a-3674-4255-9674-cc040682f518",
"name": "Gmail - Enviar recordatorio",
"webhookId": "16bfebbd-f4e3-4b1e-aba2-028fecf98da1",
"credentials": {
"gmailOAuth2": {
"id": "UDcO1FLJqA453V2D",
"name": "Gmail account 3"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/tax_record_notification",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { p_obligation_id: $('Preparar correos').item.json.obligation_id, p_contact_id: $('Preparar correos').item.json.contact_id, p_alert_date: $('Preparar correos').item.json.alert_date, p_channel: 'email', p_status: 'sent', p_provider_response: $json } }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
1520,
1472
],
"id": "bea9fc06-b8de-4091-bde0-d7be8c18e4cd",
"name": "Supabase - Registrar correo"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.google_chat_enabled === true && String(item.json.contact_email ?? '').trim());"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1008,
1744
],
"id": "3addf2bd-60c2-493c-8919-56b603aad7e8",
"name": "Preparar Google Chat"
},
{
"parameters": {
"method": "POST",
"url": "https://chat.googleapis.com/v1/spaces:setup",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleChatOAuth2Api",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { space: { spaceType: 'DIRECT_MESSAGE', singleUserBotDm: false }, memberships: [ { member: { name: 'users/' + $json.contact_email, type: 'HUMAN' } } ] } }}",
"options": {
"timeout": 30000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
1264,
1744
],
"id": "630cdc84-f7aa-4db8-8356-942056f3ac22",
"name": "Google Chat - Abrir DM",
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1500,
"credentials": {
"googleChatOAuth2Api": {
"id": "V4eVQvEoy5QcBvUu",
"name": "Chat account"
}
},
"onError": "continueRegularOutput"
},
{
"parameters": {
"jsCode": "const source = $('Preparar Google Chat').item.json;\nconst spaceName = String($json.name ?? '').trim();\nreturn [{ json: { ...source, chat_space_name: spaceName, chat_setup_ok: Boolean(spaceName), google_chat_status: spaceName ? 'pending' : 'failed', google_chat_provider_response: $json } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1520,
1744
],
"id": "1002151d-cb96-46c1-9868-3e9aca7846c0",
"name": "Evaluar DM Google Chat"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.chat_setup_ok === true);"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1776,
1632
],
"id": "5978dd34-7cb2-46be-9536-65c22b7f06a4",
"name": "Preparar envío Google Chat"
},
{
"parameters": {
"jsCode": "return $input.all().filter((item) => item.json.chat_setup_ok !== true);"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1776,
1888
],
"id": "cbc9f8d3-35f8-48a2-9251-c85c96d15be0",
"name": "Preparar fallo DM Google Chat"
},
{
"parameters": {
"method": "POST",
"url": "={{ 'https://chat.googleapis.com/v1/' + $json.chat_space_name + '/messages' }}",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleChatOAuth2Api",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { text: $json.google_chat_text, createMessageNotificationOptions: { notificationType: 'NOTIFICATION_TYPE_FORCE_NOTIFY' } } }}",
"options": {
"timeout": 30000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
2032,
1632
],
"id": "d4d67181-4079-4a46-9fd7-a10afe57db71",
"name": "Google Chat - Enviar recordatorio",
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1500,
"credentials": {
"googleChatOAuth2Api": {
"id": "V4eVQvEoy5QcBvUu",
"name": "Chat account"
}
},
"onError": "continueRegularOutput"
},
{
"parameters": {
"jsCode": "const source = $('Preparar envío Google Chat').item.json;\nconst sent = Boolean($json.name) && !$json.error;\nreturn [{ json: { ...source, google_chat_status: sent ? 'sent' : 'failed', google_chat_provider_response: $json } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2288,
1632
],
"id": "6398165b-9e0a-483f-9db6-71f0d85a69d0",
"name": "Evaluar envío Google Chat"
},
{
"parameters": {
"method": "POST",
"url": "https://dbit.digitalcompass.agency/rest/v1/rpc/tax_record_notification",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ { p_obligation_id: $json.obligation_id, p_contact_id: $json.contact_id, p_alert_date: $json.alert_date, p_channel: 'google_chat', p_status: $json.google_chat_status, p_provider_response: $json.google_chat_provider_response } }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
2544,
1744
],
"id": "29a93cc5-c157-4199-81c1-1fed7664edc6",
"name": "Supabase - Registrar Google Chat"
}
],
"connections": {
"Diario 8:00 AM": {
"main": [
[
{
"node": "Preparar ejecución",
"type": "main",
"index": 0
}
]
]
},
"Ejecutar manualmente": {
"main": [
[
{
"node": "Preparar ejecución",
"type": "main",
"index": 0
}
]
]
},
"Webhook seguimiento-impuestos": {
"main": [
[
{
"node": "Validar ejecución por Webhook",
"type": "main",
"index": 0
}
]
]
},
"Preparar ejecución": {
"main": [
[
{
"node": "Supabase - Recordatorios pendientes",
"type": "main",
"index": 0
}
]
]
},
"Validar ejecución por Webhook": {
"main": [
[
{
"node": "Preparar ejecución",
"type": "main",
"index": 0
}
]
]
},
"Supabase - Recordatorios pendientes": {
"main": [
[
{
"node": "Construir mensajes GLM",
"type": "main",
"index": 0
}
]
]
},
"Construir mensajes GLM": {
"main": [
[
{
"node": "Preparar correos",
"type": "main",
"index": 0
},
{
"node": "Preparar Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Preparar correos": {
"main": [
[
{
"node": "Gmail - Enviar recordatorio",
"type": "main",
"index": 0
}
]
]
},
"Gmail - Enviar recordatorio": {
"main": [
[
{
"node": "Supabase - Registrar correo",
"type": "main",
"index": 0
}
]
]
},
"Preparar Google Chat": {
"main": [
[
{
"node": "Google Chat - Abrir DM",
"type": "main",
"index": 0
}
]
]
},
"Google Chat - Abrir DM": {
"main": [
[
{
"node": "Evaluar DM Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Evaluar DM Google Chat": {
"main": [
[
{
"node": "Preparar envío Google Chat",
"type": "main",
"index": 0
},
{
"node": "Preparar fallo DM Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Preparar envío Google Chat": {
"main": [
[
{
"node": "Google Chat - Enviar recordatorio",
"type": "main",
"index": 0
}
]
]
},
"Google Chat - Enviar recordatorio": {
"main": [
[
{
"node": "Evaluar envío Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Evaluar envío Google Chat": {
"main": [
[
{
"node": "Supabase - Registrar Google Chat",
"type": "main",
"index": 0
}
]
]
},
"Preparar fallo DM Google Chat": {
"main": [
[
{
"node": "Supabase - Registrar Google Chat",
"type": "main",
"index": 0
}
]
]
}
},
"authors": "Isaac Aracena",
"name": "Version 29d1a109",
"description": "",
"autosaved": false,
"workflowPublishHistory": [
{
"createdAt": "2026-07-31T14:19:36.417Z",
"id": 3742,
"workflowId": "cFu3Xx23KQBKfr0M",
"versionId": "29d1a109-07ab-4b9c-a381-790a18c89e58",
"event": "activated",
"userId": "0a88c0b1-928e-4412-896e-c5d1c99b2029"
}
]
}
}