# Workflow: blocks

Workflow: blocks

**What it is.** Blocks that run in order by hand or on a schedule: fetch from connected apps, have the agent work on it and return typed output, branch, and make or update items, made by an AI agent such as Claude Code or Codex in Artifacts (tryartifacts.com), the office for AI agents. **Ask for it** in plain words: “Add a Condition to our lead workflow that sends hot leads to an Agent that emails me.” It stays a live item at its own link in the space, and the space’s owner can [publish](/docs/publishing) it as a web page anyone can open. See real pages agents made on [Examples](/examples).

> Agents read this guide with the `guide` tool, topic `workflow-blocks`, before they first make a workflow. It is shown here word for word, so people and their agents work from the same method.

| | |
| --- | --- |
| Guide topic | `workflow-blocks` |

Each block a workflow is built from: what it does, its fields (the `inputs` of an `add` or `edit`
operation, by id) with an example, and its outputs (read later as `<blockname.field>`). How to build,
connect and run them: guide topic `workflows`.

Fields that hold JSON (an Agent's `responseFormat`, a Response's `data`, a Webhook's `responseBody`, a
Condition's `conditions`, a Router's `routes`) are stored as JSON: give them as JSON values, not as text of
JSON (text is read as JSON, and text that is not JSON is refused).

**Start** (`start_trigger`). The entry point of a run by hand. **Inputs** (`inputFormat`): fields with
`name`, `type` (string, number, boolean, object, array), `description` and a default `value`, which a
run's values override. A number or boolean field given something else fails the run at the start.
Outputs: each input by name, `<start.input>` (text the run was started with), and any other value the
run was given. The names `error`, `selectedOption`, `selectedRoute`, `_pauseMetadata` are reserved.

**Schedule**, on the Start block. `schedule: true` ("Run on a schedule") also starts the workflow on a
timer, from Start, with the inputs' default values: `scheduleType` every X minutes, hourly, daily, weekly,
monthly or a cron expression, with its time fields and `timezone` (ask the person's; a minute interval must
fit in an hour). There is no separate Schedule block, so a schedule always runs the whole workflow. A run by
hand still runs it at once and does not move the next scheduled run. `edit_workflow` with
`pause_schedule: true` pauses the timed runs (false resumes them). After 100 failed runs in a row the
schedule pauses itself.

**App** (`app`). An app of the person's Tool kit, through Composio: `app` (e.g. `gmail`,
`google-sheets`, `slack`, `hubspot`), or an integration (see below). It joins the workflow by ordinary edges,
one into each Agent that uses the app (one App block can serve several Agents, with the same picks):
- Connected to an Agent, it gives that Agent all the app's tools.
- `picks`: the app's own things the person wants used (a spreadsheet and its sheet, a channel, a base…),
  picked by name on the block: `{ "spreadsheet_id": { "title": "Spreadsheet", "items": [{ "id": "1AbC…",
  "label": "Q3 deals" }] } }`. Which settings an app takes: `app_events` (`picks`). Find the ids with the
  app's tools (e.g. its search tool) rather than asking the person for one. The Agents the block is
  connected to are told to work only with these, whether or not an event is set and also on Run; an event
  setting of the same name takes them too (so a Sheets event watches the picked spreadsheet). Nothing
  picked: the Agents may use anything in the account.
- With an `event` (a slug from `app_events`, e.g. `GMAIL_NEW_GMAIL_MESSAGE`, its other settings in
  `eventConfig`), that event also starts the workflow here, and the event's fields are the block's
  output, handed on along its edge (`<gmail.subject>`). Without an event it starts nothing, and its
  edges go only into Agents.
- The person the workflow runs as must have the app connected in Tool kit. The event is switched on in
  Composio when the workflow is saved, and again when they connect the app; `read_workflow`'s
  `triggers` says whether it is on, or why not.
- An **integration** in `app`: a service Artifacts runs itself with the details the person saved in Tool
  kit: a database (`postgresql`, `mysql`, `mssql`, `oracledb`, `mongodb`, `redis`, `clickhouse`,
  `supabase`, `elasticsearch`), a data warehouse (`snowflake`, `databricks`, `google_bigquery`), AWS
  (`s3`, `dynamodb`, `rds`, `athena`, `sqs`, `ses`, `lambda`, `cloudwatch`, `textract`), `pinecone`,
  `http` (Call any API), or a public source needing no connection (`wikipedia`, `arxiv`, `duckduckgo`).
  Connected to an Agent, it gives that Agent the integration_ tools over it (`integration_list`,
  `integration_tool_schemas`, `integration_run`) and its guide topic. It has no `event` and no `picks`:
  name the table, bucket or query in the Agent's task. `app_events` says whether it is connected and
  lists its tools.

**Webhook Trigger** (`generic_webhook`). Starts a run each time its URL is called (POST; other methods
with `acceptOtherMethods`). The URL is made when the workflow is saved: `read_workflow`'s `triggers`
gives it. With `requireAuth` (on by default) the caller sends the block's `token` as `Authorization:
Bearer <token>`, or in `secretHeaderName` when one is set. The output is the request's body, with
`query` (the URL's parameters), `headers` (with `exposeRequestHeaders`) and `method` (with
`acceptOtherMethods`) added; read its fields as `<webhooktrigger.order.id>`. `idempotencyField` (a path
in the body, e.g. `event.id`) skips a repeat within 7 days. The caller is answered at once
(`{"message": "Webhook processed"}`, or `responseMode: custom` with `responseStatusCode` and
`responseBody`), not when the run ends. Use it only for a service that has no App event.

**RSS Feed** (`rss`). `feedUrl`: an RSS or Atom feed, checked every minute; each new item starts a run
(items already in the feed when it is saved do not). Outputs: `title`, `link`, `pubDate`, `item` (all
the item's fields: `guid`, `summary`, `content`, `contentSnippet`, `author`, `categories`, `enclosure`,
`isoDate`), `feed` (`title`, `link`, `description`), `timestamp`. A feed that fails to load is tried
again later, less often; after 100 failed checks it is switched off until the workflow is saved again.

**Agent** (`agent`). One step done by Artifacts' workflow agent. Its base prompt is fixed: it works on
its own and never asks anyone, it is connected to Artifacts' tools and their guide, and it has
Artifacts' own built-in skills (internal: not picked, not shown to people). You write only its task.
- `task`: the instruction, in plain words: what to do, and what to answer. No tags in it: what it works
  on reaches it through `inputs`, or by itself, and the task names it.
- `inputs`: what the step is given from the run, chosen from what its task works on:
  - Certain values (a lead's number, a draft's subject and body, a date): one row each,
    `{ "name": "lead_number", "type": "number", "value": "<start.lead_number>" }` (types `string`,
    `number`, `boolean`, `object`, `array`, `file[]`), and the task names them ("the lead whose number
    is lead_number"). The step then gets only these rows, as JSON, so list every value its task needs.
  - Whole earlier answers (all the rows a step read, what every step before it found): no rows. The
    step gets the event that started the run and every earlier block's answer on its path, under each
    block's name, and the task names the block ("the deals Read Deals listed").
  In an `add` or `edit` it is one of the block's fields: `"inputs": { "task": "…", "inputs": [ … ] }`.
- `artifacts`: what the step creates or updates in the space: `[{ "action": "create", "kind": "report" },
  { "action": "update", "itemId": "dt_…" }]`, kinds as `workflow_blocks` lists them (`artifact_kinds`).
  It reads any item of the space and writes only these: a call that would change another item is
  refused. Without artifacts it reads and answers.
- Apps: connect App blocks to it, one edge each. It gets their tools as `composio_list_apps`,
  `composio_search_tools`, `composio_get_tool_schemas` and `composio_execute_tool`, over those apps
  only, and is told to work only with each block's `picks` when it has some. An App block with an
  integration gives it `integration_list`, `integration_tool_schemas` and `integration_run` over those
  integrations only. Without an App block it has no apps and no integrations.
- Always on: web search, `guide`, the read tools of the space's items, and the built-in skills, which
  it loads when it needs them.
- The run's VM (when this server has a VM service: `read_workflow`'s `vm.service`): `read`, `write`,
  `edit` and `bash` in a Linux machine shared by every Agent of the run, its working directory the
  run's folder, the workflow's Data files in `files/`. It is set on the workflow, not the block
  (`computer`: size, internet, files; guide topic `workflows`, "The run's VM"). Name the files the
  task works on by their path: "Read files/orders.csv, total the amount column by region…".
- `skills`: this space's own skills, `[{ "skillId": "…" }]` from `list_skills`. The agent sees each
  skill's name and description and loads one in full when it is relevant. A skill is reusable
  instructions (a rubric, a procedure, a style), made with `save_skill`; a skill that mentions a tool
  does not give it one.
- **Memory is always on and its own**, and people do not see or set it. Each run keeps the Agent's final
  result once it has answered; the next run of the same Agent reads back the results of its last 5
  runs, with when, under "Your earlier runs". No two Agents share a memory: what an Agent gets from
  the other steps of a run is their final answers, under "This run so far". An Agent that fails keeps
  nothing; a retried block is never kept twice. Its past_runs tool reads what an earlier run of it
  did (its tool calls and results). `agent_memory` lists, reads or clears a memory.
- `files`: pictures and PDFs (text files are inlined) the agent reads with its task: file
  ids or objects of this space, or an earlier block's files (`<start.files>`). With a VM, they are
  also put in its `files/`. Data files for the whole run go in the workflow's `computer.files`.
- `fallbackModels` (advanced): `["deepseek/deepseek-v4.1-flash"]`, tried once each, in order, when the
  block's model fails. Also on Router and Evaluator.
- `responseFormat`: a JSON Schema (or `{ "name", "schema", "strict" }`) when later blocks need named
  fields. A schema given as it is is strict: list every field in `required` and set
  `"additionalProperties": false`, as here:

  ```json
  { "type": "object",
    "properties": {
      "category": { "type": "string", "enum": ["Sales", "Support", "Other"] },
      "score": { "type": "number", "description": "1 to 5: how urgent" },
      "summary": { "type": "string", "description": "One line" } },
    "required": ["category", "score", "summary"], "additionalProperties": false }
  ```

  Describe each field (what goes in it, and what to give when there is nothing) so the agent does not
  fill it with something else. Its fields are then read at the top level (`<agent.sentiment>`), and a
  field that is an object by the path to its own fields, any depth (`<agent.address.city>`); a name
  down the path that the schema does not declare is refused when the workflow is saved. The agent
  delivers its answer by one `submit` tool call, checked against the schema: an answer that does not fit
  goes back to the agent with what is wrong (up to 6 attempts, a reminder counted as one when it stops
  without submitting), so the fields that reach later blocks always fit the schema; an agent that never
  delivers one fails the block, which is not retried. The schema's top level must be an object. Do not
  name fields `artifacts`, `model`, `tokens`, `toolCalls`, `providerTiming` or `cost`: the agent's own
  overwrite them.
- `temperature`, `maxTokens` (advanced). `model` is the one Artifacts runs.
- The Agent is one agent loop: it calls its tools until the whole task is done (artifacts created, sheets
  and documents filled, app actions taken), then gives its final answer, in the Response Format when there
  is one. That answer is the block's output.
- Outputs: `content` (text, without a Response Format), `artifacts` (the items it created or changed:
  `[{ id, type, title, url, created }]`), `model`, `tokens` (`{ input, output, total }`), `toolCalls`
  (`{ list, count }`; each call's name, arguments, result and timing), `providerTiming`; with a Response
  Format, its fields plus all of those but `content`.

**Condition** (`condition`). Takes the first branch whose expression is true, checked in order; makes
no model call. `conditions`: `if`, any `else if`, and `else`. Each expression is JavaScript:
comparisons, `&&` `||` `!` `??`, `?.`, ternaries, arithmetic, text and list methods (`includes`,
`startsWith`, `toLowerCase`, `split`, `length`…), `Math.*`, `JSON.parse`, `Number()`, `Date.now()`
and `Date.parse()`: `<agent.score> > 75`, `<ticket.subject>.toLowerCase().includes('urgent')`,
`Date.parse(<start.due>) < Date.now()`. `context` is the output of the block connected into it. An
empty expression is false. An expression that throws fails the block ("Evaluation error in condition
…"): guard missing values with `?.`. An unconnected `else` ends that path without an error. Outputs:
`conditionResult` (true for a matched expression, false for else or none), `selectedOption` (the
branch id), `selectedTitle`, `selectedPath` (`{ blockId, blockType, blockTitle }`, or null when
nothing is connected), and the fields of the block connected into it.

**Router** (`router_v2`). A model picks one route by its description. `context`: the text to decide
on (`<start.input>`, `<agent.content>`). `routes`: `[{ "title": "Billing", "value": "Payments,
invoices and refunds" }, …]`, each its own handle (`route-0`…). Make the descriptions specific and
distinct. When nothing fits, the model says NO_MATCH and the block fails: set `errorEnabled` and
connect `error`. Outputs: `selectedRoute`, `reasoning`, `context`, `model`, `tokens`, `selectedPath`.

**Evaluator** (`evaluator`). A model scores `content` against `metrics`: `[{ "name": "Accuracy",
"description": "Are the claims supported by the source?", "range": { "min": 1, "max": 5 } }]`.
Outputs: each score under its metric's name in lowercase (`<evaluator.accuracy>`), `content`,
`model`, `tokens`. A missing score is 0 and scores are not clamped to the range: check them before an
action depends on them (a Condition after it).

**Workflow** (`workflow_input`). Runs another workflow of this space from its Start block and waits
for it. `workflowId`: its item_id. `inputMapping`: values for the child's Start inputs by name, with
tags: `{ "lead": "<start.lead>" }`. Outputs: `result` (the child's result), `success`,
`childWorkflowName`, `childWorkflowId`. A child that fails fails this block (connect `error` to
recover). Its run shows on the child's page. Workflows may call workflows up to 25 deep. Keep a child
focused, with a clear description and Start inputs.

**Human** (`human_in_the_loop`). Pauses the run until a person answers on the workflow's page (or
`resume_workflow_run` when they asked you to answer for them); it waits with no time limit. `builderData`
(Display Data): what they are shown, as fields `[{ "name": "draft", "type": "string", "value":
"<writer.content>" }]`. `inputFormat` (Resume Form): what they fill in, e.g. `approved` (boolean) and
`comments` (string), as fields like the Start block's:

```json
{ "builderData": [{ "name": "draft", "type": "string", "value": "<writer.content>" }],
  "inputFormat": [
    { "name": "approved", "type": "boolean", "description": "Send it as it is" },
    { "name": "comments", "type": "string", "description": "What to change" } ] }
```

A boolean field shows as a box that starts unticked: an answer without it ticked is `false`. Outputs after they answer: each form field by name (`<approval.approved>`),
`submission`, `resumeInput`, `submittedAt`, `response` (the display data), `url`. Resuming is not
approving: put a Condition after it (`<approval.approved> === true`) before the step it gates.

**Variables** (`variables`). Sets workflow variables for the rest of the run. `variables`:
`[{ "variableName": "total", "type": "number", "value": "<counter.total>" }]`; each value is converted to the variable's
type (a number field given "abc" fails). It does no arithmetic. Outputs: each variable it set, by
name. The variable must exist in the workflow's variables.

**Wait** (`wait`). Waits `timeValue` `timeUnit` (seconds or minutes), up to 5 minutes. Outputs:
`waitDuration` (milliseconds), `status` (`completed`, or `cancelled` when the run is stopped).

**Response** (`response`). Ends the run with its data, the run's result. `dataMode` `structured` with
`builderData` fields (each a name, a type: string, number, boolean, object or array, and a value with
tags), or `json` with `data` (JSON; a string that is one tag, `"<agent.score>"`, becomes that value with its
type, and a tag inside longer text is filled in as text). Output: `data`.

```json
{ "dataMode": "structured", "builderData": [
  { "name": "status", "type": "string", "value": "review" },
  { "name": "customer", "type": "string", "value": "<webhook.customer>" },
  { "name": "amount", "type": "number", "value": "<variable.last_amount>" } ] }
```
The first Response to run ends the run: avoid one on a branch that runs beside important work.

**Note** (`note`). Text on the canvas for the people reading the workflow. It never runs.

## See it in use

- **Examples:** [24 pages agents made for a sample company](/examples)
