Skip to main content

Scheduling & Jobs

Run work later or in the background: schedule.* creates timed jobs, and jobs.* runs and broadcasts subflows at a controlled pace.

Scheduled flows (on schedule)

The simplest scheduling is a cron-triggered flow:

flow daily_digest on schedule "0 9 * * *" {
send.text("☀️ Good morning!", chat_id: shared.group_chat_id)
}

See Triggers for the cron format. Scheduled flows have no chat in scope — always pass chat_id.

schedule.create

Create a one-off or recurring job programmatically (by delay, datetime, or cron). When it fires, it runs the named trigger.

let { task_id } = schedule.create(
trigger_name: "reminder",
params: { delay: "1h" },
user_id: user.id
)
set { user.reminder_task = task_id }
ParamTypeNotes
trigger_name!StringThe flow/trigger to run
paramsObjectdelay, datetime, or cron
user_idNumberUser context to run as

Outputs: task_id, scheduled_for, error_text.

schedule.cancel

Cancel a scheduled job by its id:

let { cancelled } = schedule.cancel(task_id: user.reminder_task)
ParamType
task_id!String

Outputs: cancelled, error_text.

Background jobs

For work that fans out across many users, use the jobs.* family. These run a subflow on the worker pool at a controlled pace.

jobs.run

Enqueue a one-off subflow execution:

let { handle } = jobs.run()

jobs.broadcast

Run a subflow for each user in the audience, paced to respect rate limits:

let { handle } = jobs.broadcast()
set { shared.last_broadcast = handle }

jobs.status

Check progress by handle:

let { status, progress } = jobs.status(handle: shared.last_broadcast)
send.text(`Broadcast status: ${status}`)

jobs.cancel

jobs.cancel(handle: shared.last_broadcast)
StatementInputsOutputs
jobs.runhandle, error_text
jobs.broadcasthandle, error_text
jobs.statushandle!status, progress, error_text
jobs.cancelhandle!error_text
tip

For sending the same message or media to your whole audience, the telegram.broadcastMessage / broadcastMedia / broadcastFlow recipes wrap this with a friendly signature.

See also