12.07 Using Operators in a Node
As an example of setting up a node with operators, let's create a scenario that generates some values and then transforms these values using operators.
To set up this scenario, you need to add four nodes:

- (1) Trigger on Run once: This node initiates the scenario when you click the Run Once button;
- (2) JavaScript: This node generates the parameter ValueJS with the value
May
;

export default async function run({execution_id, input, data, store}) {
return {
ValueJS: "May"
};
}
- (3) SetVariables: This node adds the variable ValueSV with the value
October
to the scenario;

- (4) Webhook Response: This node returns the value transformed using operators. In the Body field, add the expression
{{if(contains(3.ValueSV, "ay") = false and matchesPattern($2.ValueJS, "\\d"), $2.ValueJS, 3.ValueSV)}}
.

The result of the scenario is the value October
, based on the conditions of the given expression:
If "ay" is not in ValueSV and ValueJS matches any digit from 0 to 9, the response is ValueJS; otherwise, the response is ValueSV.