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 }
| Param | Type | Notes |
|---|---|---|
trigger_name! | String | The flow/trigger to run |
params | Object | delay, datetime, or cron |
user_id | Number | User 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)
| Param | Type |
|---|---|
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)
| Statement | Inputs | Outputs |
|---|---|---|
jobs.run | — | handle, error_text |
jobs.broadcast | — | handle, error_text |
jobs.status | handle! | status, progress, error_text |
jobs.cancel | handle! | error_text |
For sending the same message or media to your whole audience, the telegram.broadcastMessage / broadcastMedia / broadcastFlow recipes wrap this with a friendly signature.