Function Element

The Function Element allows you to define a reusable workflow as a function. The function can be invoked using the Expression Language, enabling dynamic and flexible usage within your application.

When to use?

Use this element when you need to define a block of logic that can be reused multiple times in your workflow. It is particularly useful for encapsulating frequently used processes or computations.

How to configure:

  1. Function name:

    Enter a valid name for the function. This name will be used to invoke the function within expressions. For example, if the name is myFunction, you can call it like this: ${myFunction(arg1, arg2)}.

  2. Function arguments:

    Specify the arguments that the function will accept. Each argument can have a name and an optional default value. For example:

    • name: The name of the argument.
    • default value: The value to use if no value is provided during the function call.
  3. Result variable name:

    Specify a variable name where the function's result will be stored. This ensures that the component knows where to retrieve the result value.

  4. OK flow:

    Define the steps to execute when the function is called. These steps will form the body of the function and can include other conversation elements or logic. Within this flow, you must set the result variable's value using the Set Parameter Element.

How to use in expressions:

Once the function element is executed in your workflow, you can call it in subsequent workflow components using the specified name in any expression. For example:

${myFunction("value1", "value2")}

The arguments provided in the call will replace the placeholders defined in the Function arguments section. The function will execute its workflow and return the result, which you can use further in your workflow.