Transform
A node that builds one object out of values of the execution and fixed values, for the nodes after it and for the answer.
3 min read
Transform builds an object. Each field of it is taken from a path of the execution or is a fixed value, and the nodes after it read the object as the output of the node.
- Node
- Transform
- Type
transform- Category
- Decision
- Ports
- Default
defaultmust be connected
- Default
- Ends the path
- No
What it does
The node goes through its fields in order. A field with a path takes the value at that path; a field with a fixed value takes that value. The object the fields make up is the output of the node, and the execution leaves through Default.
{
"fields": [
{ "to": "tier", "from": "context.plan", "default": "free" },
{ "to": "channel", "value": "web" }
]
}A path that finds nothing gives the field its default, or null when the field has none. A path that finds null gives null: the value is there.
When to use it
Answer the caller with an object of your own: Return Response with the source Output of a node answers with the whole output of this node.
Gather values under short names for a Condition or a Trace Note after it.
The node does not build the prompt of a model: AI Model takes its messages from input.messages of the request.
Settings
| Setting | What it is for |
|---|---|
fields | The fields of the object the node builds, 1 to 32 of them, in order. Each has a name (to) and either a path (from) with an optional default (default), or a fixed value (value). |
In the builder Add field adds a field. A field has a Name, a Source — From a path or A fixed value — and, for a path, a default that is used when the path finds nothing.
A name is 1 to 64 Latin letters, digits and underscores, and does not start with a digit. Two fields may not have the same name.
A node has 1 to 32 fields.
A field has a path or a fixed value, never both.
In the builder a fixed value keeps its type when it reads as a number,
true,false,nullor JSON; anything else is text.
Ports
The node has one port, Default, and it is required. A flow in which it leads nowhere is not published.
Output
{ "tier": "pro", "channel": "web" }A later node reads a field as nodes.<key>.output.<name> — here nodes.build.output.tier, when the key of the node is build.
Errors
The node raises no error. The paths that found nothing are named in one warning event of the trace.
{ "type": "warning", "node_key": "build", "payload": { "reason": "unknown_path", "paths": ["context.plan"] } }The settings are checked when the flow is validated and when it is published: a path starts with input, context or nodes, and a path into nodes names a node that runs before this one.
In the API an entry of issues names such a check in params.detail; its code is invalid_node_config.
| Check | Message in the builder |
|---|---|
transform_needs_field | “{node}” needs at least one field to build. |
transform_too_many_fields | “{node}” builds more than {max} fields. |
transform_field_not_object | “{node}” has a field that is not an object. |
transform_field_without_name | “{node}” has a field without a usable name: a Latin letter or an underscore first, then letters, digits and underscores, 64 characters at most. |
transform_field_both_sources | The field “{field}” of “{node}” has both a path and a fixed value. |
transform_field_without_source | The field “{field}” of “{node}” needs either a path or a fixed value. |
transform_field_bad_path | The field “{field}” of “{node}” reads “{path}”, which is not a path into input, context or nodes. |
transform_field_repeated | “{node}” builds the field “{field}” more than once. |
transform_field_unknown_node | The field “{field}” of “{node}” reads “{path}”, but the flow has no node “{ref}”. |
transform_field_later_node | The field “{field}” of “{node}” reads “{path}”, but “{ref}” does not run before it. |
Example
- Request — Default → Transform
- Transform — Default → Return Response
The flow calls no model. Transform builds the object above, and Return Response answers with it. The execution ends completed, and its output is that object.
Related
Execution context and paths — what a path may read.
How a flow is built — every node of the builder.
Send a request — the
outputthe caller gets.
Built from openapi b070e1f, sdk contract 5cc7055, php ae4a53b, node 84bc62d