Routines

View as Markdown

Schedules and triggers that start an agent or an automation: one routine's detail, and recurring tasks written as plain sentences with their last and next run.

Post the pipeline digest

Active
Schedule
Every weekday at 9Mon–Fri 09:00 (Europe/London)
Time zone
Europe/London
Next run
  • SucceededMon, Nov 30, 9:00 AM
  • FailedFri, Nov 27, 9:00 AM
  • SucceededThu, Nov 26, 9:00 AM

Sync the sales sheet

Paused
Schedule
Every 2 hoursevery 2 h
Time zone
America/New_York
Next run
Not while paused
Paused after 3 failures in a row.

When to use

Schedules and triggers that start an agent or an automation: one routine's detail, and recurring tasks written as plain sentences with their last and next run. Use Flow Diagram instead when you edit what the automation does, not when it runs.

Usage

import { RoutineCard } from "./ui/uicontext/components/Routine.ts"
const Message = UiSchema.TaggedEnum({	PausedRoutine: { id: Schema.String },	ResumedRoutine: { id: Schema.String },	RescheduledRoutine: { id: Schema.String, text: Schema.String, timeZone: Schema.String },})export const DigestRoutine = (h: Html.H<typeof Message.Type>, state: "active" | "paused", nextRun: string | null) =>	RoutineCard(h, {		props: {			id: "digest",			title: "Post the pipeline digest",			trigger: { kind: "schedule", text: "Every weekday at 9", parsed: "Mon–Fri 09:00" },			state,			nextRun,			timeZone: "Europe/London",			can: ["pause", "resume", "reschedule"],		},		onEmit: {			RequestedPause: ({ id }) => Message.PausedRoutine({ id }),			RequestedResume: ({ id }) => Message.ResumedRoutine({ id }),			RequestedReschedule: ({ id, text, timeZone }) => Message.RescheduledRoutine({ id, text, timeZone }),			RequestedTest: () => undefined,			RequestedApprove: () => undefined,			RequestedDecline: () => undefined,			RequestedPreview: () => undefined,			RequestedDelete: () => undefined,		},	})

Examples

Proposed by an agent

An agent suggests a routine; it does nothing until a person approves it.

Triage new support tickets

Waiting for you
Trigger
When a ticket arrives in the Support inbox
Next run
Nothing scheduled

Routine detail

Turn it on or off, edit what it does and when, then Save or press ⌘S. A schedule without a time is refused with the reason. Test run adds to the history.

When to run

Run history

Scheduled tasks

What each does and when, in plain words, with when it last ran and runs next. Pause one with its switch, or delete it.

  • Weekdays

    Morning inbox triage

    Every weekday morning, read new mail and DMs, answer what's simple, and list what needs me.

    Every weekday at 7:30 AMRan 36 minutes ago · Next in 21 hours
  • Weekly

    Weekly pipeline review

    Every Monday, refresh the pipeline sheet, say what moved and why, and flag deals at risk.

    Every Monday at 8:00 AMRan 3 days ago · Next in 4 days
  • Weekly

    Vendor price watch

    Every Friday, check our main vendors' pricing pages and tell me if anything changed.

    Every Friday at 4:00 PMHasn't run yet · Paused

Make a scheduled task

Name it, say what to do, pick how often. The schedule reads back as a sentence while you choose; empty fields say what they need on Schedule.

America/New York

Every Monday at 9:00 AM

API reference

RoutineCardComponent

Props

RoutineCard props
NameTypeDescription
idrequiredstringThe routine's id, sent back with every request
titlerequiredstringWhat the routine does: "Summarize new support tickets"
triggerrequiredRoutineTriggerWhat starts it: a schedule, an event or a webhook
staterequiredRoutineStateWhether it's active, paused, proposed or ended
stateLabelstringThe product's word for the state: "On", "Turned off"
pausedReasonstringWhy it's paused: "Paused after 3 failures in a row"
nextRunstring | nullISO 8601, or null when nothing is scheduled
timeZonerequiredstringThe person's time zone (IANA), for every time shown
localestringThe locale dates are formatted in; the browser's by default
showYearbooleanInclude the year in next-run, schedule preview, and history timestamps.
timeZonesstring[]The time zones the editor offers; defaults to every zone the runtime knows
lastResultsRoutineResult[]The most recent runs, newest first, shown as a row of results
webhook{ url, secret }A webhook trigger's address and key, shown once
canrequiredRoutineAction[]What this person may do here; anything absent is hidden
labels{ test, delete }Labels the product uses: { test: "Run now", delete: "End routine" }
readOnlystringWhy this person can't change it: "Only the owner changes this routine"
outcomeOutcome | nullThe app's answer to the last request; its request is the action ("pause", "reschedule")
previewSchedulePreviewThe app's reading of the schedule being typed: its next runs, or why it can't be saved
requirePreviewbooleanRequire a successful preview tied to the current request before Save.
agentIdstringThis card's id for agents; defaults to routine:<id>

Events

RoutineCard events
EventPayloadDescription
RequestedPause{ id: string }Stop the routine from starting until it's resumed
RequestedResume{ id: string }Start the paused routine again
RequestedTest{ id: string }Run the routine once now
RequestedApprove{ id: string }Turn on a routine an agent proposed
RequestedDecline{ id: string }Turn down a routine an agent proposed
RequestedPreview{ id: string; text: string; timeZone: string; request?: string }The person is typing a schedule: answer with preview
RequestedReschedule{ id: string; text: string; timeZone: string }Save the schedule the person typed, in the time zone they chose
RequestedDelete{ id: string }End the routine for good, after the person confirmed

Agent actions

What agents can do with RoutineCard
ActionDescription
ClickedPausePause the routine
ClickedResumeResume the paused routine
ClickedTestRun the routine once now, as a test
ClickedApproveApprove the routine an agent proposed
ClickedDeclineDecline the routine an agent proposed
ClickedEditScheduleOpen the schedule editor
UpdatedScheduleType the schedule in plain words, as a person would: 'every weekday at 9am'
ChoseTimeZoneChoose the schedule's IANA time zone
SubmittedScheduleSave the schedule being edited
ClickedDeleteAsk to delete the routine (opens the confirmation)
ConfirmedDeleteasks firstDelete the routine. Name it as your target.

RoutineListView function

Options

RoutineList options
NameTypeDefaultDescription
statusrequired"loading" | "ready"—loading shows a placeholder while the routines load
labelstringRoutinesWhat the list is of, for screen readers; Routines by default
emptyrequired{ readonly title: string; readonly hint?: string }—"No routines yet", "Ask the agent to do something on a schedule"
childrenrequiredView.Children—The routine cards

RoutineEditorComponent

Props

RoutineEditor props
NameTypeDescription
idrequiredstring—
namerequiredstring—
instructionrequiredstringWhat the agent does when it runs, in its own words
schedulesrequiredstring[]When it runs, each in plain words: "Every day at 8:00 AM", "Weekdays at 6:00 PM"
activerequiredboolean—
runsrequiredRoutineResult[]Its runs, newest first
nowrequiredstringThe clock its runs are read in
timeZonerequiredstring—
localestring—
canrequired("edit" | "toggle" | "test" | "delete")[]What this person may do; anything absent is hidden
outcomeOutcome | nullThe app's answer to the last request: "save", "active", "test" or "delete"
agentIdstring—

Events

RoutineEditor events
EventPayloadDescription
RequestedSave{ id: string; name: string; instruction: string; schedules: string[] }—
RequestedActive{ id: string; active: boolean }—
RequestedTestRun{ id: string }—
RequestedDelete{ id: string }—

Agent actions

What agents can do with RoutineEditor
ActionDescription
RequestedChangeasks firstChange the routine's name, instruction or schedules (plain words, such as 'Every weekday at 9:00 AM') and save
ToggledActiveasks firstTurn the routine on or off
ClickedTestRunRun the routine once now

ScheduleFormComponent

Props

ScheduleForm props
NameTypeDefaultDescription
initial{ title, instruction, schedule }—What the form starts with: a task's title and instruction when it's made recurring. Read once, as it mounts.
submitLabelstring"Schedule"The submit button's text; "Schedule" by default
savingboolean—The app is saving it: the form waits
errorstring | null—Why the last save failed, from the app
timeZonestring—The reader's time zone, said under the time
todaystring—"YYYY-MM-DD": today, the default for Once

Events

ScheduleForm events
EventPayloadDescription
RequestedSubmit{ draft: ScheduleDraft }—
RequestedCancel{}—

ScheduledTaskCardView function

Options

ScheduledTaskCard options
NameTypeDescription
taskrequiredScheduledTask—
nowrequiredstringISO 8601: the app's clock, for "Ran 36m ago" and the next run
timeZonestring—
localestring—
onPauserequired(paused: boolean) => MessageThe switch: true asks to pause it
onRunNowMessage—
onDeleteMessage—
runningbooleanA Run now is on its way
styleStyle—

Keyboard and accessibility

  • Each routine is a labelled card; its schedule, time zone and next run are a description list, and every time is a <time>.
  • Editing a schedule is a form: the app's reading of it and its next runs are announced as you type.
  • Deleting asks first, and agents must name the routine they end.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/routines

Source