Skip to content

Rules and Automation

Rules and automation turn repeated cleanup decisions into saved behavior. Herald exposes automation through the Cleanup tab rule editor, custom prompt editor, cleanup manager, schedule settings, MCP tools, and dry-run status.

Use W for future-mail automation rules, P for reusable AI prompts, and C for cleanup rules that target older mail by sender or domain. These are shipped user-facing features backed by Herald’s rule and cleanup-rule storage.

AreaWhat it shows
Automation rule editorAutomation Rule form with trigger group, action multiselect, action detail fields, and saved-rule summary.
Trigger fieldsTrigger type sender, domain, or AI category; trigger value such as address, domain, or category.
Action listDesktop notification, move, archive, delete, webhook POST, and shell command.
Action detail fieldsDestination folder, webhook URL/body, shell command, notification title/body.
Prompt editorName, output variable, system prompt, user template, and saved-prompt summary.
Cleanup manager listSaved cleanup rules with name, match type, match value, action, older-than days, enabled state, and last run.
Cleanup manager edit formRule name, match type, match value, action, older-than days, and enabled toggle.
Status barRun results, dry-run marker, deletion/archive progress, and error messages.
KeyContextPreconditionsResult
WCleanupRule editor closed.Opens automation rule editor, prefilled from focused sender/domain when available.
escRule editorForm not completed.Cancels and closes the rule editor.
PMain UIRule editor, prompt editor, and settings closed.Opens custom prompt editor.
escPrompt editorForm not completed.Cancels and closes the prompt editor.
CCleanupCleanup manager closed.Opens cleanup manager.
nCleanup manager listManager open.Creates a new cleanup rule.
enterCleanup manager listA rule exists.Edits selected cleanup rule.
d / DCleanup manager listA rule exists.Deletes selected cleanup rule.
rCleanup manager listManager open.Runs all cleanup rules immediately.
j / downCleanup manager listManager open.Moves down.
k / upCleanup manager listManager open.Moves up.
escCleanup managerManager open.Closes list or cancels edit form back to list.
  1. Open Cleanup with 3.
  2. Focus a sender/domain row when you want prefilled context.
  3. Press W.
  4. Choose trigger type.
  5. Enter trigger value.
  6. Select one or more actions.
  7. Fill details for move, webhook, command, or notification actions.
  8. Complete the form to save.
  1. Press P.
  2. Enter a name.
  3. Optionally enter an output variable.
  4. Write system instructions.
  5. Write a user template using placeholders such as {{.Sender}}, {{.Subject}}, and {{.Body}}.
  6. Complete the form to save.

Custom prompts are reusable instructions. A rule or MCP tool must invoke a saved prompt before it produces results.

  1. Open Cleanup with 3.
  2. Press C.
  3. Press n.
  4. Fill rule name, match type, match value, action, older-than days, and enabled state.
  5. Save the form.
  6. Press r in the manager list to run all rules immediately, or rely on configured scheduling.
  1. Press S to open settings.
  2. Set cleanup schedule hours in the sync/cleanup section.
  3. Save settings.
  4. Reopen Cleanup manager with C to review enabled rules.
StateWhat happens
No saved automation rulesRule editor summary says none yet.
Saved automation rulesRule editor summary shows a few saved rules and a count of additional rules.
Prompt validationPrompt name is required.
No cleanup rulesCleanup manager explains that n creates one.
Disabled cleanup ruleManager list marks the rule disabled and scheduled runs skip it.
Run allCleanup manager emits an immediate run request for all rules.
Dry-run modeStatus shows [DRY RUN] so rule effects can be inspected without live mutation when launched in that mode.
AI unavailableAI-category triggers and custom prompt execution cannot classify new content.
Dangerous actionsDelete, shell command, and webhook actions can affect mail or external systems.

Rules are stored in Herald’s backend and may include trigger values, destination folders, webhook URLs, webhook body templates, shell commands, notification text, and custom AI prompts. Cleanup rules can delete or archive matching mail. Webhooks send configured email-derived data to external URLs. Shell commands run locally with environment variables derived from matching mail.

If a rule does not match, compare trigger type and value with the exact sender/domain/category shown in Cleanup.

If a custom prompt saves but appears to do nothing, remember that saved prompts are invoked by rules or MCP tools; saving alone does not run a prompt.

If cleanup rules do not run on schedule, check cleanup.schedule_hours and confirm the app or daemon surface responsible for scheduled work is active.

If experimenting with delete rules, use dry-run mode when available and verify the status bar before enabling live cleanup.