Routines
A Routine is an automated unit of work in Onnie. You give it a trigger — a cron schedule, a workspace event, or a manual run — and it executes without you being in the chat. There are three kinds, each suited to a different kind of job.
Routines belong to a workspace or to a specific project. They appear in the Routines panel of any project, and workspace-level Routines are managed under Settings → Routines. A project-scoped Routine uses that project as its default context; a workspace-level Routine spans all projects unless your instruction or function code narrows the scope.
Each Routine tracks a Run History: every execution records its type, trigger source (schedule or manual), start time, duration, status (running, completed, failed), and the full output or error. You can view Run History from the Routine detail panel.
Three kinds of Routines
Agent Routines
An Agent Routine runs Onnie AI on a prompt you provide — exactly like sending a chat message, but automated. The agent has full access to your workspace tools: it can read records and pages, create and update Tasks, consult Onniebots, generate images, search the web, and write back to any table. Agent Routines are free to execute; the AI reasoning inside consumes credits just as a regular chat turn does.
You pair an Agent Routine with a schedule and optionally associate it with a specific Onniebot. When the schedule fires, the run executes under that bot's identity and instructions. Each run starts fresh — there is no persistent thread across executions. If the agent needs to carry state between runs (a rolling count, a last-known value), it writes to workspace memory with the remember tool and reads it back on the next run.
Agent Routines are the right choice when the job requires judgment: summarizing, triaging, writing narrative content, making routing decisions, or doing research that would take a human several minutes.
See Agent Routines for configuration details and examples.
Functions
A Function Routine — called Functions in the UI — runs a JavaScript function you define. Functions are deterministic: no AI reasoning, no model calls, no credit consumption. They read from Supabase directly (the same database your workspace uses), write Tasks, call external APIs, and send emails — all via the Platform SDK. Functions are free and unlimited on every plan.
The key distinction: Functions go straight to the database. They do not go through the AI engine. That makes them fast, cheap, and predictable. Transforming records in bulk, syncing data to an external system, sending a notification when a condition is met — these are all Function jobs.
Functions also serve as the deterministic layer in Chains, doing the data work that feeds or follows an Agent step.
See Function Routines for the SDK surface, the code editor, and examples.
Chain Routines
A Chain Routine — called Chains in the UI — is a multi-step pipeline that sequences Functions, Agent steps, and conditional branches. A Chain can route on the output of a previous step and pass data between steps via variables. Chains are the most expressive Routine type and the only one with an execution cost: 2 credits per run, available on paid plans only.
Chains handle multi-step flows where steps depend on each other: fetch data with a Function, score it with an Agent, branch based on the score, assign via another Function, and send a notification as the last step. That whole pipeline runs as a single Routine, triggered once, with outputs flowing between steps automatically.
See Chain Routines for step types, variable wiring, and a worked example.
Triggers
Every Routine has exactly one trigger configuration. Three trigger types are available:
Cron schedule — runs on a fixed time pattern. You pick a schedule type and the value that fills it in. Onnie's database scheduler fires the Routine at the next matching time. The scheduling layer runs inside the database — there is no separate cron service or external scheduler. The next scheduled time is stored on the Routine row (next_scheduled_at) and updated after each run.
Available schedule types: once (a single specific date and time), daily, every_x_days, weekly, every_15_days, and monthly_day. The schedule value (time of day, day of week, etc.) is stored per-Routine.
Workspace event (coming soon) — fires when something happens in the workspace: a record is created or changed, a Task moves to a specific status, a new row appears in a table. Event-driven Routines react to data rather than the clock. This trigger type is on the roadmap and is not yet available.
Manual run — you click Run now from the Routine detail panel. Manual runs behave identically to scheduled runs — the same input, the same function or instruction, and the same Run History entry. Use manual runs for testing before enabling a schedule, or for one-off jobs you want to trigger by hand.
Variables
Routines can read from workspace variables: named key–value pairs that hold secrets (encrypted at rest) and configuration values. Variables let you separate configuration from code — an API key or project ID goes in a variable, and your function or instruction references it by name. When the value changes, you update the variable once; all Routines pick up the new value on their next run.
In Chain Routines, step outputs also become variables. A Function step's return value or an Agent step's response is available to subsequent steps using the {{stepId.field}} syntax.
Variables are defined at the workspace level and are available to any Routine in the workspace. See Variables for types, syntax, and secret rotation.
When to use which
Use this as a decision guide when choosing a Routine type:
| Situation | Routine type |
|---|---|
| Send a weekly project status summary | Agent Routine |
| Triage incoming records and create Tasks | Agent Routine |
| Write an end-of-sprint retrospective | Agent Routine |
| Call an external API and write the result to a table | Function |
| Send an email when a record field changes | Function |
| Transform and sync records in bulk on a schedule | Function |
| Route a new lead through enrichment → scoring → assignment | Chain |
| Run a nightly multi-step job with branching between steps | Chain |
| Enrich with code, summarize with AI, then route based on the result | Chain |
Rule of thumb: if your job needs no AI reasoning, write a Function — it's free and predictable. If it needs AI but is a single-step prompt, use an Agent Routine. If it's multi-step with branching or needs to compose both code and AI in sequence, use a Chain.
Chains are paid-plan-only and cost 2 credits per execution. Functions and Agent Routines are always free at the execution layer — you only pay AI credits when Onnie AI is reasoning inside an Agent Routine or an Agent step in a Chain.