On this page
Sommatic Docs
Open portal

Time Window

Aggregates events into time-based or count-based windows.

View as Markdown
Open in
Flow control Available flow.window Version 1.0.0 Execution: async

Buffers the items that reach it during one run and emits them as one batch through out when the buffer reaches max_items or interval_seconds have passed since the first item.

This operator allows processing of streams of data by grouping them into "windows". It buffers incoming payloads and emits them as a batch when the window conditions are met.

Window Types:

  • Tumbling: Fixed non-overlapping windows (e.g., every 5 minutes).
  • Sliding: Overlapping windows (e.g., last 5 minutes, updated every minute).
  • Count: Window of N items.

Use Cases:

  • Aggregating sensor readings every minute.
  • Batching analytics events before sending to a data warehouse.
  • Detecting patterns A -> B within a specific timeframe.

How it works

  1. The worker wraps the payload as { window_items: [payload], window_meta: { start_time, end_time } } (ISO strings) and sets meta.window { type, interval, batch_size } from type (default tumbling), interval_seconds (60) and max_items (100).
  2. The engine intercepts it and appends that wrapper to an in-memory buffer for this node.
  3. When the buffer holds max_items entries, or interval_seconds have passed since the first entry (checked only when an item arrives), the engine sends { window_items, window_meta: { start_time, end_time, count } } through out (times in epoch milliseconds) and empties the buffer.
  4. Otherwise nothing continues from the window for that item.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-batch-events",
  "label": "Batch events",
  "operator_slug": "flow.window",
  "operator_version": "1.0.0",
  "config": {
    "type": "tumbling",
    "interval_seconds": 60,
    "max_items": 2
  }
}

Configuration

type string Optional

Default: tumbling

Allowed values: tumblingsliding

interval_seconds integer Optional

Default: 60

max_items integer Optional

Force close window if buffer size reaches this limit.

Default: 100

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

type
Ignored: sliding behaves like tumbling.
interval_seconds
A value of 0 closes the window on every item.

Output ports

out default

The window closed by count or time. Each entry of window_items is the worker wrapper, so the original payload is at window_items[i].window_items[0].

Data
{
  "window_items": [
    {
      "window_items": [
        {
          "id": 1
        }
      ],
      "window_meta": {
        "start_time": "2026-11-26T15:00:00.000Z",
        "end_time": "2026-11-26T15:00:00.000Z"
      }
    },
    {
      "window_items": [
        {
          "id": 2
        }
      ],
      "window_meta": {
        "start_time": "2026-11-26T15:00:00.150Z",
        "end_time": "2026-11-26T15:00:00.150Z"
      }
    }
  ],
  "window_meta": {
    "start_time": 1795705200000,
    "end_time": 1795705200150,
    "count": 2
  }
}
error

Only when the worker throws unexpectedly.

Data
{
  "error": "<message>"
}

In expressions

What a later node can read from this node's output with $("Time Window").item.json.<path> (write your node's label instead of Time Window). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Time Window").item.json.window_itemsarray= […] (2)
$("Time Window").item.json.window_metaobject= {…}
$("Time Window").item.json.window_meta.start_timestring= 1795705200000
$("Time Window").item.json.window_meta.end_timestring= 1795705200150
$("Time Window").item.json.window_meta.countnumberNot suggested by the editor= 2—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Input contract

payload object Optional

Output contract

window_items array<object> Optional
window_meta object Optional
start_time string Optional
end_time string Optional

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "flow.window",
  "name": "Time Window",
  "category": "flow",
  "version": "1.0.0",
  "description": "Aggregates events into time-based or count-based windows.\n\n  This operator allows processing of streams of data by grouping them into \"windows\". It buffers incoming payloads and emits them as a batch when the window conditions are met.\n\n  **Window Types:**\n  - **Tumbling:** Fixed non-overlapping windows (e.g., every 5 minutes).\n  - **Sliding:** Overlapping windows (e.g., last 5 minutes, updated every minute).\n  - **Count:** Window of N items.\n\n  **Use Cases:**\n  - Aggregating sensor readings every minute.\n  - Batching analytics events before sending to a data warehouse.\n  - Detecting patterns A -> B within a specific timeframe.",
  "capabilities": [
    "windowing",
    "aggregation",
    "stream",
    "buffer"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "type": {
        "type": "string",
        "enum": [
          "tumbling",
          "sliding"
        ],
        "default": "tumbling",
        "title": "Window Type"
      },
      "interval_seconds": {
        "type": "integer",
        "default": 60,
        "title": "Interval (Seconds)"
      },
      "max_items": {
        "type": "integer",
        "default": 100,
        "title": "Max Items",
        "description": "Force close window if buffer size reaches this limit."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "description": "Individual event payload.",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "description": "Array of buffered payloads.",
    "properties": {
      "window_items": {
        "type": "array",
        "items": {
          "type": "object"
        }
      },
      "window_meta": {
        "type": "object",
        "properties": {
          "start_time": {
            "type": "string"
          },
          "end_time": {
            "type": "string"
          }
        }
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Window",
      "is_default": true,
      "description": "Emits the batch when window closes."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Internal failure."
    }
  ],
  "execution_mode": "async",
  "tags": [
    "stream",
    "window",
    "batch"
  ],
  "is_stateful": true,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
Yes
Retries (retryOnFail)
No
Capabilities
windowingaggregationstreambuffer
Tags
streamwindowbatch

Notes and limits

  • The buffer lives in memory during one run only. Entries left when the run ends are discarded and never emitted.
  • The example envelope is what the worker returns for one item; the engine intercepts it, and only the batch shown on out reaches the next node.
  • Without a flow.split upstream the node sees one item per run, so with the defaults nothing is ever emitted; set max_items to the expected number of items, or interval_seconds to 0.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs