Skip to main content

Auto Reminders

The platform includes an automated reminder system that sends urgency-graded email notifications for MOCs with approaching or overdue target timelines.

Configuration

The auto-reminder runs as a Vercel cron job configured in vercel.json:

{
"crons": [
{
"path": "/api/auto_reminder",
"schedule": "0 8 * * *"
}
]
}

Schedule: Every day at 08:00 UTC.

Endpoint

Route: GET /api/auto_reminder

File: src/app/api/auto_reminder/route.ts

Authentication: None (public endpoint intended for cron access only).

How It Works

  1. Scan — Fetches all implementer form documents that have a target-timeline field
  2. Filter — Skips MOCs where completed === true
  3. Evaluate — For each remaining MOC, calculates how the target date relates to today
  4. Grade — Assigns an urgency level based on the timeline
  5. Send — Dispatches urgency-formatted emails to all users in the MOC's all_users array

Urgency Levels

ConditionLevelDescription
Overdue by ≤14 daysCRITICALTarget date has passed within the last 2 weeks
Due tomorrowURGENTTarget date is tomorrow
Due within 1 weekHIGHTarget date is within the next 7 days
Due within 1 month (created >30 days ago)MEDIUMTarget date is within 30 days
Due within 1 month (created ≤30 days ago)LOWRecently created, due within 30 days

MOCs overdue by more than 14 days are not included in reminders.

Email Content

Reminder emails include:

  • The MOC serial number
  • The target timeline date
  • The urgency level badge
  • A direct link to the MOC in the platform
  • Description of what action is needed

Response

{
"message": "Reminders processed",
"totalReminders": 5,
"results": [
{
"moc_id": "...",
"serial_num": "15-2026",
"urgency": "HIGH",
"target_date": "2026-02-20",
"emailsSent": 3
}
]
}

Customizing the Schedule

To change the reminder schedule, update the schedule field in vercel.json. The cron expression follows standard cron syntax:

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sunday=0)
│ │ │ │ │
* * * * *

Examples:

  • 0 8 * * * — Daily at 08:00 UTC
  • 0 8 * * 1-5 — Weekdays at 08:00 UTC
  • 0 8,14 * * * — Twice daily at 08:00 and 14:00 UTC