Composing a Dataflow

To create and compose a new dataflow, perform the following:

  1. Navigate to the Neo extension portal [{host url}/extensions/neo/ui]() and select the organization in which you want to create the dataflow.
  2. Click Create new dataflow and enter a name for the dataflow in the Name field.
  3. (Optional) Create or assign a tag for the dataflow.
  4. Click Done.
    The dataflow is created on the Dataflows page under the My Dataflows tab.
  5. On the Dataflows page, click the dataflow.
    The dataflow version page opens, showing the dataflow as version v1 in Draft status.
  6. Click on version v1 of the dataflow.
    The Neo UI canvas opens with the Trigger and Schema block.
  7. Add blocks to the dataflow as required by clicking a node. To reuse common logic, use the Helper Function block and invoke using the dao.executeBlock() function.
    Note: Blocks do not follow a fixed sequence; arrange them logically based on requirements.
  8. Click Save.
  9. Test the dataflow using an API testing tool.
  10. Click Send for Approval to submit the dataflow for approval.
    The dataflow status changes to Awaiting approval.
Composing a dataflow

Composing a dataflow

Executing script block with reusable logic

You can run a script block with reusable logic ( helper function block ) using the dao.executeBlock() function. This function calls a Script block from the block library and passes input arguments to it. The called block processes the input and returns a response.

Steps to execute a helper function block

  1. Create and publish the helper function block in the block library.

  2. In your main Script or Schema block, import dao from "neo/dao".

  3. Use dao.executeBlock() to run the helper block:

    • Pass the helper block name as the first argument.
    • Pass input arguments as additional parameters.
    • Use the await keyword to wait for the block's response.

    Example:

    const validationResult = await dao.executeBlock("validateMobileNumber", mobile);
    • validateMobileNumber is the name of the helper block.
    • mobile is the input value.
    • validationResult stores the response returned by the helper block.

Example scenario

Requirement
During a dataflow execution, you need to:

  • Validate a mobile number.
  • Calculate the total amount, including tax.

Script block using executeBlock

import dao from "neo/dao";
import logger from "neo/logger";

const script = {
  execute: async () => {
    const mobile = "+1234567890";
    const amount = 100;
    const tax = 18;

    // Call the mobile number validation helper block
    const validationResult = await dao.executeBlock("validateMobileNumber", mobile);

    if (!validationResult.isValid) {
      return { error: "Invalid mobile number" };
    }

    // Call the tax calculation helper block
    const totalAmountResult = await dao.executeBlock("calculateTotalAmount", amount, tax);

    return {
      validatedMobile: validationResult.cleanedNumber,
      totalAmount: totalAmountResult.amountWithTax
    };
  }
};

export {
  script as default
};

What this script does

  1. Create and publish helper blocks
    The blocks validateMobileNumber and calculateTotalAmount are saved to the block library.

  2. Importdao
    The main Script block imports dao to access DAO functions like executeBlock().

  3. CallexecuteBlock() with block name and arguments

    • Pass "validateMobileNumber" and mobile to validate the number.
    • Pass "calculateTotalAmount" along with amount and tax to compute the total.
  4. Useawait to get the result
    The await keyword pauses execution until the helper block returns a response. This ensures that you work with the actual result.

Best Practices

  • Include only the required blocks in your dataflow to improve performance.
  • Use clear, descriptive block names that reflect the block’s purpose.
  • Document the expected arguments and their order for each block.
  • Validate all input arguments inside the block using getFunctionArguments().
  • Always use the JavaScript keyword await with executeBlock to ensure proper execution flow.

Limitations

  • Only blocks included in the current dataflow's block library can be executed.
  • Execution is asynchronous and must be awaited.
  • Each block defines its response format; there is no standard structure.
  • Arguments must be accessed by index, not by name.
  • Blocks must be explicitly added to the dataflow to be executable.