# Node Reference

> The output of any node that already ran in this execution, the previous node and the entry point of a chained workflow.

Source: https://docs.sommatic.ai/en/expressions/reference/node-reference/

Each example was run against the deployed expression engine over the [example context](#example-context) at the end of the page.

## `$('Node label')`

Function · `NodeAccessor` · Source: `Sommatic AI expression engine`

```javascript
$(label)
```

`$` is a function. It takes the label of a node (the name shown on the canvas) and returns an accessor to the output that node produced in this execution. A node without a label is found by its `node_id`. Only nodes that already ran have an output; for any other name, the accessor still exists and returns an empty item, so a read gives `undefined` instead of an error.

The lookup is by text: renaming a node breaks every expression that reads it, and when two nodes share a label the one placed later in the workflow wins. Give nodes short, stable, unique labels.

### Parameters

- `label` (string, required): The node's label, exactly as written (case and spaces count). Its `node_id` when it has no label.

### Returns

`NodeAccessor`: An object with the members below.

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$('X').item` | `{ json }` | The node's output as an item: `item.json` is what the node returned. `{ json: {} }` when the node did not run. |
| `$('X').first()` | `{ json }` | Same as `.item`. |
| `$('X').last()` | `{ json }` | Same as `.item` (a node produces one item). |
| `$('X').all()` | `list` | A list with the node's item, or an empty list when the node did not run. |
| `$('X').params` (Reserved) | `object` | Reserved: the configuration of that node is not exposed; always `{}`. |
| `$('X').context` (Reserved) | `object` | Reserved: always `{}`. |
| `$('X').isExecuted` | `boolean` | `true` when the node already ran in this execution. |

### Examples

```javascript
{{ $('Normalize input').item.json.correlation_id }}
```

Result (string):

```json
"c-7f3a"
```

The webhook body, from any node further down the graph.

```javascript
{{ $('Webhook Receiver').item.json.body.email }}
```

Result (string):

```json
"ana.perez@example.com"
```

```javascript
{{ $('Classify').item.json.confidence >= 0.8 }}
```

Result (boolean):

```json
true
```

A node on another branch, or not reached yet.

```javascript
{{ $('Approval').isExecuted }}
```

Result (boolean):

```json
false
```

Reading a node that did not run gives undefined, not an error.

```javascript
{{ $('Approval').item.json.decision }}
```

Result (undefined):

```json
undefined
```

```javascript
{{ $('Classify').all().length }}
```

Result (number):

```json
1
```

### Notes

- The node's output is exactly what it returned through its port (`data` of the envelope), not the envelope itself: `$('X').item.json.ok` does not exist.
- A node on a branch that did not run is not an error. Check `.isExecuted` when the difference matters, for example after a `flow.if`.

In JSONata: Not available: $ and $$ mean the context in JSONata. Read the node in a JavaScript expression instead.

## `$prevNode`

Object · `object` · Reserved · Source: `Sommatic AI expression engine`

> **Reserved.** The engine does not pass the previous node: today it is always `{ name: 'Start', runIndex: 0, outputIndex: 0 }`.

```javascript
$prevNode
```

Meant to describe the node that routed to the current one. The engine does not pass it, so it always holds the same fixed values. To know which node produced the input, read its output with `$('label')` and check `.isExecuted`.

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$prevNode.name` (Reserved) | `string` | Meant to be the previous node's name. Today always `'Start'`. |
| `$prevNode.runIndex` (Reserved) | `number` | Meant to be the attempt of the previous node. Today always `0`. |
| `$prevNode.outputIndex` (Reserved) | `number` | Meant to be the output port it used. Today always `0`. |

### Examples

```javascript
{{ $prevNode }}
```

Result (object):

```json
{
  "name": "Start",
  "runIndex": 0,
  "outputIndex": 0
}
```

In JSONata: `$$prevNode.name`

## `Chain entry point`

Node output · `{ …data, chain_context }` · Source: `Sommatic AI expression engine`

```javascript
$('Chain Entry Point').item.json
```

A workflow called by another one through [`workflow.chain`](https://docs.sommatic.ai/en/nodes/workflow.chain/) starts at a [`workflow.trigger`](https://docs.sommatic.ai/en/nodes/workflow.trigger/) node (named here `Chain Entry Point`; use your node's label). Its output is the `data` the caller sent, spread at the top level, plus `chain_context`, which identifies the caller. The node right after the trigger reads it as `$json`; any later node reads it with `$('Chain Entry Point')`.

Inside a chained workflow, `$execution.id` is the id of the **root** run of the chain, so messages and tasks show the same reference across every workflow; `$execution.run_flow_instance_result_id` is the id of this hop.

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$('Chain Entry Point').item.json.<field>` | `any` | Each field of the `data` object the caller sent, at the top level. |
| `…chain_context.caller_flow_definition_id` | `string \| null` | Definition id of the calling workflow. `accepted_caller_ids` of the trigger is checked against it. |
| `…chain_context.caller_flow_instance_id` | `string \| null` | Flow instance id of the calling run. |
| `…chain_context.caller_flow_slug` | `string \| null` | Slug of the calling workflow. |
| `…chain_context.caller_node_id` | `string \| null` | `node_id` of the `workflow.chain` node that made the call. |
| `…chain_context.correlation_id` | `string` | Id of this call (`chain-` + 20 characters), new on every call. |
| `…chain_context.root_flow_instance_result_id` | `string \| null` | Result id of the root run of the chain, the same in every hop (it is also `$execution.id`). |

### Examples

Right after the trigger: the data the caller sent, at the top level.

```javascript
{{ $json.order_id }}
```

Result (string):

```json
"ord_1042"
```

```javascript
{{ $('Chain Entry Point').item.json.chain_context.caller_flow_slug }}
```

Result (string):

```json
"order-intake"
```

The editor suggests `data`, but the trigger spreads the caller's fields at the top level: `.data` reads as undefined.

```javascript
{{ $('Chain Entry Point').item.json.data }}
```

Result (undefined):

```json
undefined
```

```javascript
{{ $('Chain Entry Point').item.json.chain_context.correlation_id }}
```

Result (string):

```json
"chain-7Hq2Lw9sKd3pXa1mZr4t"
```

The root run of the chain.

```javascript
{{ $execution.id }}
```

Result (string):

```json
"fir-root-xxxx"
```

This hop of the chain.

```javascript
{{ $execution.run_flow_instance_result_id }}
```

Result (string):

```json
"fir-hop-xxxx"
```

### Notes

- The label `Chain Entry Point` is an example: `$('…')` takes the label you gave the `workflow.trigger` node.
- `chain_context` keeps travelling only if you pass it on: a `workflow.chain` node builds a new one for the next hop and carries the root id forward on its own.

In JSONata: `$$json.chain_context.caller_flow_slug`

## Example context

The examples run over this data: the input of the current node (`$json`), the nodes that already ran (`$(…)`), the ids of the run and the current node. The clock is fixed at `2026-11-26T14:30:00.000Z` and the server zone is UTC, so `$now` and `$today` give the same values on every page.

```json
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "ana.perez@example.com",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  },
  "nodes": {
    "Webhook Receiver": "= $json",
    "Normalize input": {
      "correlation_id": "c-7f3a",
      "channel": "web"
    },
    "Classify": {
      "label": "billing",
      "confidence": 0.92
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-xxxx",
    "$flow_instance_id": "fi-xxxx",
    "$flow_definition_id": "fd-xxxx",
    "$flow_version_id": "fv-xxxx",
    "$flow_slug": "order-intake"
  },
  "node": {
    "node_id": "node-notify",
    "label": "Notify customer"
  }
}
```

The examples of a chained workflow run over a second context: a workflow started by `workflow.chain`, whose `workflow.trigger` node is labelled `Chain Entry Point`.

```json
{
  "$json": {
    "order_id": "ord_1042",
    "customer_email": "ana.perez@example.com",
    "amount": 46,
    "chain_context": {
      "caller_flow_definition_id": "fd-caller-xxxx",
      "caller_flow_instance_id": "fi-caller-xxxx",
      "caller_flow_slug": "order-intake",
      "caller_node_id": "node-chain-billing",
      "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
      "root_flow_instance_result_id": "fir-root-xxxx"
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-hop-xxxx",
    "$flow_instance_id": "fi-hop-xxxx",
    "$flow_definition_id": "fd-billing-xxxx",
    "$flow_version_id": "fv-billing-xxxx",
    "$flow_slug": "billing-review",
    "$input": {
      "data": {
        "order_id": "ord_1042",
        "customer_email": "ana.perez@example.com",
        "amount": 46
      },
      "chain_context": {
        "caller_flow_definition_id": "fd-caller-xxxx",
        "caller_flow_instance_id": "fi-caller-xxxx",
        "caller_flow_slug": "order-intake",
        "caller_node_id": "node-chain-billing",
        "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
        "root_flow_instance_result_id": "fir-root-xxxx"
      }
    }
  },
  "node": {
    "node_id": "node-create-task",
    "label": "Create review task"
  }
}
```

Examples run against the orchestrator at commit 31e874b.
