Code - JavaScript

A component to run JavaScript

Although AgenticFlow AI is generally a zero or low-code platform, the functionality of adding JavaScript code snippets to your workflows is available and fully supported. Code snippets can be useful in tasks such as pre- or post-processing of data or analysis tasks where LLMs might not be the best fit.

How to Use a JavaScript Action

Adding the Component

To use JavaScript, you need to add a “Code-JavaScript” action to your workflow. Follow these steps to get started:

  1. Navigate to the Workflow page.

  2. Click on + Create Workflow or select an existing workflow.

  3. Click on + Add Action.

  4. Select Code - JavaScript from the list of action components.

Enter your code in the code section as you would in any other IDE (e.g., VS Code, WebStorm).

Access to Input Variables and Other Actions’ Output

Access Input Variables

Input variables can be accessed via params. params is a dictionary, and the names of variables are the dictionary keys. For example, if there is an input parameter named “title,” you can access its value using params.title.

Access Other Actions’ Output

Outputs from other actions can be accessed via steps. steps is a dictionary, and the names of actions are the dictionary keys. For example, if there is an action named “summary,” you can access its produced value using steps.summary.output.

Setting the Output of the JavaScript Action

You can set the output of this action to be a string generated by a Large Language Model (LLM) such as GPT. This can be done by clicking on the LLM icon on the top right.

Follow the links below for more information about:

Access the Step Output

If the name of a JavaScript action is javascript, you can access the action's output using javascript.transformed. Note that an action name is different from the action title. Action titles can be found on the top left of actions. An action name is shown on the bottom left, in a smaller font and highlighted green.

Common Errors

The most common errors seen in our logs are JavaScript coding-related errors, for which there are millions of resources available online. However, occasionally, users encounter the Code execution timed out error. Keep in mind that JavaScript snippet execution time cannot exceed 15 minutes.

Last updated