Workflows
The logic layer: how a workflow turns your data into a page, a response, or an automation, step by step.
A workflow is the logic layer, the recipe that turns your data into a finished thing: a web page, an API response, an image, or an automation. It's the piece your agent spends the most time on, and the one most worth understanding when you want to follow what it built or adjust it by hand in Workflow Studio.
You rarely author a workflow yourself. But being able to read one, to see the shape of what your agent assembled, is what makes the whole system legible instead of a black box.
#The shape of a workflow
A workflow is an ordered list of steps. It starts at the first step and runs each one, once, top to bottom. There are no jumps and no loops back: a step can repeat itself, but the workflow never returns to an earlier one. That straight-line shape is deliberate: you can read a workflow top to bottom and know exactly what runs, and when.
Each step has a name and does a bit of work. Wherever a value has to be worked out on the fly (a price, a filename, a filter), it's a small expression (more on those below).
#What carries between steps
This is the one rule worth holding onto. Inside a step, the results of its actions are available (the reply from an API call, the rows from a content lookup), but only for the rest of that step. To use a value in a later step, you save it into a variable.
Variables are the workflow's memory; everything else is scratch. It's why your agent adds "variables" here and there: it's stashing the pieces it will need further down.
#Steps and blocks
A step is built from blocks: you tick the ones it needs. A step holds at most one of each, and when it runs, its blocks fire in a fixed order regardless of how they were added:
- Assert: a precondition. If it's false, the whole run fails. ("The customer must exist.")
- Conditional: a skip gate. If it's false, the rest of this step is skipped. ("Only if they opted in.")
- Loop: repeat the rest of this step, either while a condition holds or for each item in a list. Iterations can run in parallel.
- API call: call one of your integrations and read the response.
- Sub-workflow: run another workflow and use its output. This is how a page fans out: header, body, and footer built by separate workflows, then stitched into one document.
- Data: read, write, or list your content records.
- LLM: call a language model (the key comes from a secret, never the workflow itself). Give it tools and it becomes an agent; see Agents below.
- Asset: read, upload, or generate a media file, including turning an SVG into an image, handy for social-share cards.
- Email: send an email to people in your workspace, such as a contact form message. See Email below.
- Variables: set the named values that carry to later steps.
A step with no blocks is a valid do-nothing. Most steps are one or two blocks: fetch something, then stash it in a variable.
#Each action leaves a result
When a block does something, it leaves its result under a name you can read for the rest of that step:
| Block | Leaves behind | Which is… |
|---|---|---|
| API call | $response | { status, headers, body } (the reply, already parsed) |
| Sub-workflow | $sub_output | whatever that workflow returned |
| Data | $data_result | the record(s) read, or the outcome of a write |
| LLM | $llm | the model's reply ($llm.text is the message) |
| Asset | $asset | the file's details ($asset.url is its public address) |
$email | { sent, test }, whether it went out and whether it was a test |
Because these vanish when the step ends, anything a later step needs gets carried forward into a variable first.
#Agents: the LLM block with tools
With no tools, the LLM block is one exchange: a prompt in, a reply out as $llm.text. Give
it tools and it becomes an agent. The model can ask for a tool to be run, read the
result, and go again, up to a max turns you set (counted in model calls, not tool calls).
A tool is one of:
- an integration, with its arguments inferred from the template's own variables;
- another workflow, whose arguments are that workflow's input;
- a set of Tessryx operations, so the agent can create, edit, publish, run and preview workflows, endpoints, schemas and the rest of your workspace. You tick the operations it may use, and each becomes a tool. It acts with editor permission, only inside a scope it must be given, and can never change members or billing. A run or preview an agent starts counts toward the same recursion limit as the run it is already inside, so an agent cannot loop through the front door. Firing a schedule is not on the list.
Which models. Set the provider to Anthropic or OpenAI, put your key from that
provider in a secret, and name the model the way the provider does (claude-sonnet-5-5, say,
or an OpenAI model id). Tessryx adds nothing to what the provider charges. Server address
points the block at a server that speaks the same API instead, such as a model you run
yourself: for OpenAI, give the base address the server's own docs give for OpenAI's client
libraries (the part ending in /v1). Tools, agents, chains and compaction work the same on
both. A run trace shows the model's reasoning only on Anthropic, or on a server that sends
its reasoning along with the answer.
Two settings shape the work. Effort is how hard the model thinks per turn: lower is faster and cheaper, higher is better for long, many-step builds. Thinking display decides whether the run trace shows a summary of that reasoning (Anthropic only). Both are display and budget choices; the model reasons either way.
Max tokens is per turn, not per block, and covers the model's thinking as well as its reply. Set it generously. A turn cut off at the limit is treated as a failure, not a short answer, so an agent never continues from half a tool call.
An agent stops when it answers without asking for a tool. If it runs out of turns while still asking, the run fails, and that last turn's tool calls are not made. An agent that ran out of turns did not finish and must not look as if it had.
#Scope and secrets
A workflow can declare a scope: the folders it may touch and what it may do in each. The
three permissions are read (get, list, and call an integration or another workflow),
write (save and delete) and publish (serve at a public path). A folder covers
everything under it, so shop covers shop/orders/42, but never shop-old.
Leave the scope off and the workflow reaches the whole workspace, with the same authority as whoever wrote it. For most workflows that's allowed. It's worth setting a scope whenever a slug comes from something you don't control (a path parameter, a form field, text an agent read), so a surprising value can only reach that app's own files.
The one place a scope is required is an agent that can build: an LLM block given Tessryx operations as tools needs a scope, on the block or on the workflow. Without one the workflow is refused when it's saved and again when it runs, so every agent that can change your workspace works inside a limit someone declared.
In a scoped workflow:
- Data, asset, API call and sub-workflow blocks can only name slugs inside its folders. Anything else fails the step. A sub-workflow runs only if its own scope fits inside the caller's, so an unscoped workflow can't be called from a scoped one.
- An LLM block with tools can narrow things further with its own tool scope, worked out while the run happens, such as the one app the agent is building. It can't be wider than the workflow's scope. A tool scope that comes out empty or malformed fails the step before the model is called, rather than falling back to no limit.
#An agent can't widen its scope
An agent inherits the scope of whatever called it and can never widen it. Every workflow it creates, edits, publishes, runs or connects to an endpoint or schedule has to fit inside its own scope. If it saves a workflow without writing a scope, its own scope is written in for it, so an agent can't produce a workspace-wide workflow by leaving the field out. If it writes a wider scope, the save is refused.
#Secrets are handed over, never shared
A scoped workflow also lists the secrets it may use: the key of an LLM block and the credentials of any integration it calls. Using a secret that isn't on the list fails the step.
The list belongs to the workflow that's running and is never passed down from whoever called it. That's what makes delegation safe. An agent can call a workflow that holds a key (one that generates images, say) and the key does its job, but the agent can't read it or reuse it. A scoped agent can't save or edit a workflow that lists a secret, and can't build an integration that uses one. Unscoped workflows can use every secret in the workspace, as before.
#Email: contact forms and alerts
The Email block sends mail from a workflow, with no mail service or secret to set up. It can tell your team something happened (a contact form was submitted, a scheduled check found a problem), or send one of your site's visitors a confirmation or a receipt.
It only sends to people in your workspace, and its Audience says which:
- Team (the default): members of your workspace.
- Visitor: people you invited to your private pages. See Email to your visitors.
The fields:
- To gives one recipient or a list of up to 10. For team mail that's members' email
addresses or viewer ids; for visitor mail it's visitors' viewer ids. Take it from your own
definition or data, or use the signed-in visitor's own
$input.auth.viewer_id, rather than from what a form submits. Each value is checked against your workspace's own people, so mail can't reach anyone else. One that names nobody fails the step and nobody gets anything. Each person gets their own copy. - From name is who the mail is from, shown as "Acme Club via Tessryx". Team mail uses the workspace's name when it's blank.
- Contact is an address where someone can reach you about the mail. Replies go there unless you set a Reply-To.
- Reply-To can come from the input. On a contact form it's the visitor's address, so you can answer them by pressing Reply.
- Subject is required. Set Body (plain text), Body (HTML), or both. With only the HTML, the plain-text version is made from it.
HTML is cleaned before it's sent. Scripts, forms, embedded frames, <style> blocks,
links and images that aren't https, and styles that hide or overlay content are removed.
Inline styles, layout tables, and https links and images stay.
Escape what visitors typed. The cleaner can't tell your link from one a visitor typed
into the form, and the email arrives from your workspace. Wrap every value that came from a
visitor in $escapeHTML(...), so <a href=…> arrives as plain text. It works in JSONata and
JavaScript.
A contact form is an endpoint that accepts
POST, and a workflow whose typed input requires a name, an email address and a message, so
a bad submission fails before anything is sent:
{
"input_schema": "contact-form@latest",
"steps": [
{
"name": "notify",
"blocks": ["email"],
"email": {
"to": ["you@example.com"],
"reply_to": { "language": "jsonata", "source": "$input.email" },
"subject": { "language": "jsonata", "source": "'Contact form: ' & $input.name" },
"body_html": { "language": "jsonata", "source": "'<p><b>' & $escapeHTML($input.name) & '</b> (' & $escapeHTML($input.email) & ')</p><p style=\"white-space: pre-wrap\">' & $escapeHTML($input.message) & '</p>'" }
}
}
],
"final_transform": { "language": "jsonata", "source": "{ 'ok': true }" }
}
To keep each submission even when the email fails, save it with a Data step first and set the email step to continue on error.
A few things to know:
- Test runs send real mail. A preview, an editor run, a run your AI agent starts, or Run
now all deliver, with
[Test]in front of the subject and a note at the bottom. Only published pages and scheduled jobs send unmarked mail. - Visitors see one message. On a published page, every email failure reads "the email could not be sent". The reason (a recipient who isn't one of your people, a limit, a bad reply address) is in the step's trace.
- Sending is capped per workspace, by the hour, the day and the month, shared by all your workflows. Past a cap, the step fails until that window resets. Emails don't use credits. The numbers are in Plans & limits.
- The result is
$emailfor the rest of that step: how many weresent, who wasskippedand why, and whether it was atest.
#Email to your visitors
Set Audience to Visitor to email the people you invited to your private pages: a booking confirmation, a receipt, a note that their access changed, an update about something they signed up for. Visitor mail has to be that kind of message, never advertising (see the Acceptable Use Policy).
- Address them by viewer id. On a page gated to visitors,
$input.auth.viewer_idis the person signed in. To email them later, from a schedule say, store that id when they visit. - From name and Contact are required. Use your site's name as your visitors know it.
- Tessryx adds a footer naming you and your contact address, with a link to stop emails from you. Mail apps' own unsubscribe button works too.
- Some visitors are skipped. Someone who unsubscribed, whose address bounced or who marked
your mail as spam, or who has already had 5 emails from you today, is skipped and the rest
still go.
$email.skippedlists each one as{ to, reason }, with the reasonopted_out,suppressedordaily_limit, and it's empty when everyone was mailed. A published page's run may not keep its trace, so if a skip matters, handle it in the workflow. Your Visitors tab marks who unsubscribed or has email blocked. - It shares the monthly allowance with team mail, and each visitor gets at most 5 a day.
- Spam reports pause it. If enough visitors mark your mail as spam, visitor email stops for the workspace and the step fails saying so. Contact support to turn it back on.
{
"name": "confirm",
"blocks": ["email"],
"email": {
"audience": "visitor",
"to": { "language": "jsonata", "source": "$input.auth.viewer_id" },
"from_name": { "language": "jsonata", "source": "'Acme Club'" },
"contact": { "language": "jsonata", "source": "'hello@acme.example'" },
"subject": { "language": "jsonata", "source": "'Booked: ' & $input.class" },
"body": { "language": "jsonata", "source": "'See you at ' & $input.class & '.'" }
}
}
#Chains: a job longer than one run
Every run has an execution budget (see Guardrails and cost). Some jobs are bigger than that: an agent building a whole app, a crawl of ten thousand pages. A workflow can run those as a chain. It finishes one run, saves a bookmark, and another run of the same workflow picks up from it.
Two settings on the workflow turn this on:
- Continuation, with a max links: the most runs one chain may use, counting the first. A chain that reaches this number and still asks to continue fails rather than stopping quietly, so set it comfortably above what the job should need.
- Continue with: an expression evaluated after the final transform. Return nothing and the chain ends, which is the normal way for one to end. Return a value and another run starts with that value as its entire input. Keep it a bookmark: a page token, the id you reached, what is left to do. Anything bigger belongs in a content record the next run reads. If the workflow declares an input schema, the bookmark must carry everything that schema requires, or the next run fails validation.
Inside a run, $link says where it is: $link.index (0 on the first run), $link.chain_id
and $link.max. A chain keeps the workflow version it started on, so publishing mid-chain
never changes the code under a saved bookmark.
Any run can start a chain, including one serving a page or an API request, not only a schedule. Only the first run answers the caller; the rest happen in the background and get your plan's full run length. A form's route can save the submission and answer at once, then leave a slow API call to the next link. That link has no request or signed-in viewer, just the bookmark, so the viewer id and anything else it needs go in the bookmark. Don't continue from a cached GET page, since every cache miss would start another background job. Background links count toward your plan's limit on background runs at once.
Agents are the main reason chains exist. A chained agent that runs out of time stops at a
turn boundary, sets $llm.stop_reason to out_of_time, and hands back its conversation as
$llm.transcript. Return that from continue with, and give the LLM block a resume
expression (usually $input.transcript) so the next run continues the same conversation
instead of starting over. Resume evaluates to nothing on the first run, so one block serves
every link in the chain.
#Producing the output
After the last step, a few optional expressions shape what the run returns:
- Final transform: the expression whose value is the run's output (the HTML of a page, the JSON of an API route). Leave it off and the run returns nothing (fine for an automation that just writes data).
- Output status & headers: an optional HTTP status and headers, for a page that needs to
answer
404for a missing record or301for a redirect. The endpoint serving the workflow applies them. - Output handling: for a workflow run from an editor, whether its result simply displays, replaces the record, or patches part of it.
- Final message: a short confirmation shown in the editor after it runs.
#Expressions: JSONata and JavaScript
Anywhere a value is computed, it's a small expression in one of two languages:
- JSONata: a compact language for querying and reshaping data, ideal for pulling fields
out and restructuring them. One quirk worth recognizing: values are referenced with a
leading
$($input,$response, and your own variables); a bare word means "a field of the input" and usually comes back empty. - JavaScript: for logic that reads more clearly as code; it
returns the value.
Both have $escapeHTML(value), which makes text safe to put inside HTML. Use it on anything a
visitor typed before it goes into a page or an email.
A variable can also hold a literal: text returned exactly as written, with no evaluation. That's the right home for a big blob of embedded CSS, HTML, or JavaScript a page needs; the dynamic bits get assembled separately and slotted in.
You mostly won't write these (your agent does), but recognizing the shapes is most of what it takes to read a workflow.
#Guardrails and cost
Every run has an execution budget: a wall-clock cap (up to 15 minutes, set by your plan) so a workflow that hangs or loops forever is stopped rather than running up cost. A run that exceeds it is ended. A job that legitimately needs more than that runs as a chain, which is bounded by its own max links.
Where to watch runs and read a failure is covered in Runs and monitoring; what a run costs is in Credits and caching.
Put simply: a workflow is a straight line of steps, each assembled from a few blocks that run in a fixed order, passing values forward through variables, and ending in an output your endpoint serves or your schedule runs on a clock.