JavaScript API for Flow Modules

The Flow API provides an interface for Flow JS Modules to control the execution of Flow designs. It includes functions for reading module input, writing module output, and making callbacks to connected modules. The API is available in the Flow JS Module context and can be accessed using the keyword flowAPI.

const flowAPI = {
    // Returns module settings declare by the user in Module Properties.
    getModuleSettings: () => {...},

    // Gets module input.
    getModuleInput: () =>  {...},

    // Gets all module inputs as an array.
    getModuleInputs: () =>  {...},

    // Returns if there is input for the module.
    isModuleInput: () =>  {...},

    // Returns if multiple inputs are received by the module.
    // Can be used for checking whether to call getModuleInput()
    // or getModuleInputs().
    isModuleMultipleInputs: () =>  {...},

    // Sets module output.
    setModuleOutput: (value) =>  {...},

    // Sets a value to the common session object that is available for all modules.
    setModuleSessionValue: (key, value) =>  {...},

    // Gets a value by key from the common session object.
    getModuleSessionValue: key =>  {...},

    // Gets all keys in the common session object as an array.
    getModuleSessionKeys: () =>  {...},

    // Performs a callback. The module needs to have call-out enabled.
    callback: value =>  {...},

    // Checks if this module has multiple call-outs connected.
    // Can be user for checking if the callback
    // return value will be an array containing multiple return values.
    isMultipleCallbacks: () =>  {...},

    // Gets callback input. The module needs to have call-in enabled.
    getCallbackInput: () =>  {...},

    // Sets callback output. The module needs to have call-in enabled.
    setCallbackOutput: value =>  {...}

    // Gets the input passed from the parent flow via a callback.
    // This is applicable when the current flow functions as a sub-flow.
    getRunInput(): () => {...},

    // Sets the output to be returned to the parent flow as
    // the result of the callback. Applicable when the current flow is a sub-flow.
    setRunOutput(): (value) => {...}
}

Limitations in Flow JS Modules

There are some limitations in Flow JavaScript Modules.

Export Keyword

Do not export anything from a Flow JS Module. The export keyword is not allowed.

Var Keyword

Do not use the var keyword in your code. Always use let or const instead.

Function Keyword

Do not use the function keyword in your code. Instead, use a function expression. For example:

const myFunction = () => {
  // code here
};

Imports from Other JavaScript Configurations

Only use the import keyword. Do not use the @include TIF Cloud macro.

Also, when importing, do not include the .js suffix — even if the other configuration file has one.

For example, if you want to import something from foo/bar.js, write:

import { something } from "foo/bar";