Módulo 8: Proyecto — Sistema de Alertas Programadas

Paso 1: Schedule + Trigger Principal

Descripción de la cápsula

Empezamos a construir. Workflow principal [ALERTS-MAIN]. Trigger con verificaciones de horario y holidays.


Setup

Workflow nuevo

Nombre: [ALERTS-MAIN] Sistema de Alertas Folder: production / alerts


Schedule Trigger

Configurar:

  • Cron expression: */15 * * * * (cada 15 minutos)
  • Timezone: America/Mexico_City (o tu TZ principal)

Verificación: abrir crontab.guru, verificar que la expression hace lo esperado.


Verificación: business hours

No queremos alertar a las 3am. Después del Schedule, verificar horario.

Set para flags

[Set: verificar horario]
- current_hour: {{ DateTime.now().setZone('America/Mexico_City').hour }}
- day_of_week: {{ DateTime.now().setZone('America/Mexico_City').weekday }}  // 1-7
- is_business_hours: {{ $json.current_hour >= 8 && $json.current_hour < 20 && $json.day_of_week >= 1 && $json.day_of_week <= 5 }}

8am-8pm L-V. Fuera de eso, no alertar.

Verificar holiday

[Sheet read: holidays_mx]
   │
[Set: verificación final]
- today_date: {{ DateTime.now().setZone('America/Mexico_City').toFormat('yyyy-MM-dd') }}
- is_holiday: {{ $('Sheet holidays').all().some(h => h.json.date === $json.today_date) }}
- should_alert: {{ $json.is_business_hours && !$json.is_holiday }}

IF de filtro

[IF: should_alert]
├─ FALSE → terminar (log opcional)
└─ TRUE → continuar al procesamiento

Log opcional para "skipped"

Para auditoría:

FALSE branch:
[Sheet append: 'system_log' con timestamp y razón ("fuera de horario" o "holiday")]

Permite verificar después que el sistema corrió pero saltó por razón válida.


Manual Trigger paralelo (development)

Mientras desarrollas, agregar Manual Trigger en paralelo al Schedule:

[Schedule cada 15 min] ──┐
                         ├─→ [Set verificar horario] → ...
[Manual Trigger] ────────┘

Te permite ejecutar manualmente sin esperar 15 min. Antes de producción, considerar mantener Manual como capacidad de "trigger ad-hoc" — útil para emergencias.


Test de la cápsula

Test 1: Ejecutar manual durante horario

  • Click Execute Workflow
  • Verifica should_alert = true
  • IF va por TRUE branch

Test 2: Modificar horas en Set

Cambia temporalmente current_hour a 23 (11pm).

  • Re-ejecuta
  • should_alert = false
  • IF va por FALSE branch (skip)

Restaurar.

Test 3: Agregar hoy como holiday

En holidays_mx, agregar hoy.

  • Ejecuta
  • is_holiday = true, should_alert = false

Remover.


Validación

  • Workflow [ALERTS-MAIN] creado
  • Schedule configurado cada 15 min
  • Verificación de horario laboral
  • Verificación de holidays
  • IF filtra correctamente
  • Log opcional para casos skipped

Lo que sigue: Paso 2 — colectar data de las 3 fuentes en paralelo.


Creado: Mayo 11, 2026 Versión: 1.0