For the complete documentation index, see llms.txt. This page is also available as Markdown.

Filter

The filter acts as a conditional gate for your flow. It branches logic or halts it based on a condition and is the primary way to implement if/else scenarios in Heisenware.

To add a filter:

  1. Click the + icon on the right side of a function output, modifier, or existing filter.

  2. Select Filter from the list.

  3. Click the new filter box (Click to edit…) to open the code editor and write your condition.

randomInteger function with filter extension node

How filters work

A filter evaluates a JavaScript expression that must return a boolean value (true or false). The input value from the preceding output is available as the reserved variable x.

Click the filter icon on the left to evaluate the filter manually during development. The last result appears below the expression.

Logical gate

If the result is true, the data passes on to the next node following the filter. If false, the flow halts at this point.

Branching logic

Use the true and false states of the filter to trigger separate logic paths. For example, use the true state to trigger another function.

Falsy values halt the flow

Filter examples

Example 1: Threshold monitoring

Checks if a sensor value exceeds a critical limit.

Data:

Filter content:

Return of the filter: true

Example 2: Industrial error detection

Inspects a status message for specific keywords like "Error".

Data:

Filter content:

Return of the filter: true

Example 3: Validating array data

Ensures that an array contains data before the flow processes it.

Data:

Filter content:

Return of the filter: false

Using AI for filters

Use AI chatbots like ChatGPT, Claude, or Gemini to generate complex filter logic. Filters use standard JavaScript, so provide the AI with your data structure to get an immediate result.

For best results, copy this article as context for the AI. Use the Copy button at the top of the page or the Open in ChatGPT / Open in Claude buttons in the top navigation bar.

Copy and paste this prompt into your AI so it understands the Heisenware environment and its variable references.

Last updated

Was this helpful?