Execute and test your unique logic.


The Custom Code action is among the most powerful tools in fastgen, as it allows you to write, test and implement custom logic into your routes and workflows. While fastgen is intentionally designed for simplicity, there are instances where a touch of customized code is exactly what’s needed to accomplish your desired behavior.

Supported Versions:

  • Node.js: v16 and v18
  • Python: v3.8, v3.9, v3.10, and v3.11

Deprecation Warning for Node.js v16 New projects created after Mar 11, 2024 won’t be able to use Node v16 anymore. All Custom Code actions in projects created up until then will still work but need to update to a newer version in the following months.

Getting Started

Context Data View (Left Panel)

This section helps you with testing your code without the need to run the whole route or workflow. It is filled with input data of your route or workflow and data that other actions produce as output. You can always go in here and modify it to simulate a specific edge case or just let the last run of your flow prefill it for you.

Be aware that not all the data shown as context data are already accessible when the code is run. The context data is a snapshot of the data at the end of the whole flow execution. Meaning if the Custom Code action is at the very top of the flow, before any other action has run, it won’t have access to its output despite it being shown in the context data panel.

Code Editor (Right Panel)

The right side is your canvas, the Code Editor. Here, you can pen down your logic, integrate functions, and weave the context data into your script as needed. This panel is meticulously crafted to offer an optimal scripting experience, ensuring that every line of code seamlessly integrates with the provided context data.

During the coding process, the role of the fastgen function is crucial to understand. This function is called during the execution of the custom code and acts as a bridge to retrieve data from previous actions via the context parameter.

For a practical example, suppose you want to extract the myData variable housed within $body (notated as {{$body.myData}}). In that case, you would utilize context.$body.myData.

The fastgen function is a crucial part of data extraction and manipulation, enabling seamless integration of past action data into the current workflow.

Package Manager

Fastgen’s package manager facilitates the easy integration of external libraries or packages into your code, expanding your scripting potential.

Node.js (npm packages): If you’re writing in Node.js, the left corner houses the button to access the package manager. Clicking it opens a console where you can specify the npm packages and versions you require.

Python (pip packages): For Python scripts, the same left-corner button provides access to the pip package manager. Specify your desired Python packages and their versions.

Once the desired packages are installed, you can easily integrate them into your scripts, enhancing your code’s capabilities.


The output of your custom script will depend on what you have designed it to return. For smooth integration into your workflows, always ensure that your script’s output is in a format that is congruent with the Fastgen ecosystem.


The output of the action consists of two data points: Error and Data. Error will contain any runtime errors encountered while execution that didn’t early abort the whole execution of the flow. Data will return the content that the function fastgen, within the custom code, returned.


async function fastgen(context) {
  return {
    data: context,