Automations — Rules, Jobs & Cron
Make DLRS proactive: auto-reminders, deadline monitors, follow-ups. Covers triggers, conditions, scheduling, and the Redis queue — beginner-friendly.
What is Automation?
Beginner: If This Then That
Located: /w/[workspace]/automations. Table: automation_rules — each row is a rule with trigger, condition, action, enabled. Runs create jobs → job_runs log.
Concepts — Rules, Jobs, Runs
automation_rules {
id, workspace_id,
name: "Deadline 2 days notify",
trigger: "task.due_approaching", // event
condition: { days_before: 2 }, // when to fire
action: { type: "notify", channel: "push", template: "GB reel due tomorrow..." },
enabled: true,
last_run_at
}
jobs {
id, rule_id, payload: { task_id }, status: "pending"|"running"|"done"|"failed", run_at
}
job_runs {
id, job_id, started_at, finished_at, output, error
}Keywords: trigger (event), condition (filter), action (what to do), job (queued work), run (execution log).
Built-in Automations
- Reminder Engine — Contextual: “GB reel due tomorrow, export pending” (not just “Task due”).
- Overdue monitor — Daily check:
due_date < today AND status NOT IN (Completed)→ notify + increase priority. - At-risk — If remaining > available → badge + notify.
Triggers & Conditions (Examples)
Trigger: task.created → Condition: client = GB → Action: create checklist
Trigger: task.due_approaching → Condition: days_before = 2 → Action: notify push
Trigger: task.overdue → Condition: priority = High → Action: notify daily
Trigger: task.waiting → Condition: waiting_days > 3 → Action: follow-up email draft
Trigger: transaction.created → Condition: merchant = "Netflix" → Action: detect subscription
Trigger: cron "0 8 * * 1-5" → Action: morning briefing (weekdays 8am)Beginner: Cron Syntax
0 8 * * 1-5 = minute hour day month weekday. * = any. 1-5 = Mon-Fri. So 0 8 * * 1-5 = weekdays 8:00am. Use crontab.guru to test.Cron & Scheduling
Per-Task Policy
Task → Reminders tab → Policy: Automatic (7d, 3d, 1d, morning-of, overdue) | Custom | None. Auto adapts to priority.
Global Rules
Automations → New → Trigger cron 0 9 * * * → Action: notify “Daily briefing”.
Recurrence
Task → Repeat: Never/Daily/Weekdays/Weekly/Monthly/Custom. Stored as recurrence_rule (iCal RRULE), not expanded rows.
Worker & Queue
Producer: API route → ioredis.lpush("queue:jobs", JSON.stringify(job))
Consumer: npm run worker (lib/jobs/worker.ts)
- BLPOP queue, run handler, update job_runs
- Retry 3x with backoff on failure
- Logs to activity_log
Deployment:
- Local: separate terminal npm run worker
- Prod: separate service (Docker, PM2, systemd)
- Health: check Redis + job_runs for failedTechnical: Tenancy in Jobs
workspace_id. Worker always scopes DB queries via tenant DAL — no cross-workspace leak.Creating Your First Rule
Open Automations
Go to /w/[workspace]/automations → New Rule.
Configure
Name: Follow up waiting tasks
Trigger: task.waiting
Condition: waiting_for != null AND days_waiting > 3
Action: Create notification "Follow up with {{waiting_for}} about {{task_title}}"
Enabled: trueTest
Create a task → set Waiting, follow_up_date = tomorrow → check job_runs after cron or manual trigger.