Skip to content

Workflow Implementation Patterns

Use explicit nodes for data access, transformations, decisions, and approvals. Give each reusable component a stable input/output contract. See Node Configuration Reference for field definitions.

Chain, branch, and refine

Chain dependent operations so each receives validated upstream output. Use parallel branches for independent retrievals or analysis, then combine their results before a decision. Serialize conflicting updates to the same business record.

For iterative refinement, validate an extracted result, collect missing information or feedback, and return to a defined step. Supply an exit path for successful validation and a bounded failure path. Deterministic orchestration does not make model-generated content inherently correct.

Paginated retrieval

For an API exposing a reliable total count and offset pagination:

  1. Retrieve count metadata using a small initial request.
  2. Set a positive page size and generate the required offsets.
  3. Use For Loop to call the Business Object Function for each offset.
  4. Combine the returned records and validate completeness before presentation.

For 63 records and a page size of 10, the offsets are 0, 10, 20, 30, 40, 50, and 60. Map the current offset with:

{{$context.$nodes.PAGE_LOOP.$currentItem.offset}}

The loop's $output contains iteration results. Parse serialized responses when necessary before combining their items arrays. The precise result wrapper depends on the inner node.

Use While Loop when pagination instead depends on a continuation flag or token. Match the endpoint's pagination contract; a precomputed count is unsuitable when totals are unavailable or change during retrieval. Bound accumulated output to the next node's limits.

Code node transformations

Use inline JavaScript for compact, deterministic mapping, calculations, and validation. Return a value rather than modifying $context; assign shared state through Set Variables.

Limit Inline Code node
Runtime 5 seconds
Iterations 10,000
Source length 2,000 characters
Serialized output 50 KB

Inline code cannot perform file I/O, external API calls, console output, imports, or function definitions. Keep integration calls in data nodes. Reusable Functions is a separate source option; its template contract must be configured independently.

Read a returned value as {{$context.$nodes.TRANSFORM.$output.result}}. Error context includes $context.$error.$errorMessage and $context.$error.$nodeCode; a timeout reports TIMEOUT as its error message. Exceeding a runtime limit stops execution.

Reuse agents and workflows

Component Use
Agent Reuse one published specialist agent.
Workflow Invoke a published workflow.
Reference Block / Reference Reuse logic within the current workflow.

Expose workflow inputs through webhook variables; expose reusable agent inputs through Input Variables. Pass typed values where the contract requires them. A message is interpreted as a conversational request.

The result can be nested inside an envelope. For a Workflow node, the business response commonly resides at {{$context.$nodes.SUBFLOW.$output.output}}. Validate the selected component's schema before mapping it.

Call child workflows containing Human Approval or Wait outside the parent's loops. If the parent needs to call the child for each item, use a child without suspension nodes and handle approval or waiting in the parent after the loop. See child workflow restrictions. Private agents created inside a workflow remain local to that workflow.

Deterministic policy decisions

Policy generation and policy execution are separate stages. An LLM converts business rules into JavaScript during authoring; the published function applies those rules at runtime. Use an upstream LLM to extract facts and a downstream LLM to explain the decision when needed.

Use a Generic standalone policy for a single ruleset. Use a Policy Template for related policies that share function signatures, input and output schemas, and generation guidance. See Policy Templates and Policies for setup and examples.

Prepare explicit formulas, effective dates, precedence, caps, and rounding rules. Specify required function names and schemas in generation instructions. Validate generated code with policy-owner test cases covering thresholds, date transitions, missing fields, and conflicting conditions. Publish only after review; regenerate and retest after material rule or schema changes.

Approval and feedback routing

Without feedback, route on the reviewer's approval or rejection. With feedback, send the user's changes to Loop Back Node and cap repetitions with Maximum Iterations. Email review also needs an Approver account and a timeout path.

Output attribute Meaning
$actionPerformed Decision, including APPROVED or REJECTED.
$feedbackRecieved Feedback text; retain this spelling in the context path.
$iterationsPerformed Completed feedback/regeneration cycles.

Reference these under $context.$nodes.APPROVAL.$output. Timeout and iteration-exhaustion values require separate handling; their complete result contract remains TBD. Provide reviewers with the proposed change, relevant evidence, and expected effect.