Skip to main content

Functions

Execute JavaScript functions.

Function nodes are JavaScript snippets that allow for quick and easy parsing, re-mapping or otherwise modifying the data using JavaScript.

Inputs of the node are provided as function's arguments. Functions are executed on top of Google's V8 Engine Isolates that are built into the ZEN Engine.

The second argument provides some extra helpers for the function:

  • dayjs - for Date Manipulation
  • big.js - for arbitrary-precision decimal arithmetic.
info

Maximum execution time of a single function is limited to 50ms.

Getting started

To start off create a simple decision with input, function node and an output through graph edit mode. Switch back to content edit mode and click on the function node (Open).

By default, function will return anything that is provided as an input.

Writing a sample function

Let's create a function that will calculate the sum of all numbers provided in the request. Our expected JSON for the request will be:

{
"numbers": [1, 2, 3, 4]
}

And our function will look something like this:

function sample code

Debugging via Simulator

To debug a function you may use console.log statements. It supports all primitive data types which can be represented in JSON format.

As an example:

debug a function