# Function

The **Function connector** allows you to execute custom **JavaScript code** within a workflow. It is useful when advanced data processing or custom logic is required that cannot be handled using standard connectors.

The Function connector runs using **Node.js**, enabling you to manipulate workflow data, perform calculations, filter information, or transform JSON structures before passing the results to the next connector in the workflow.

This connector is typically used for tasks such as:

* transforming input data
* performing calculations
* restructuring JSON objects
* preparing data for external API requests
* applying custom logic to workflow data

After the code is executed, the processed output is passed to the next connector in the workflow.

### JavaScript <a href="#javascript" id="javascript"></a>

The Code node supports Node.js.

### Supported JavaScript features <a href="#supported-javascript-features" id="supported-javascript-features"></a>

The Code node supports common JavaScript functionality, including asynchronous operations.

* Promises: Instead of returning the items directly, you can return a promise which resolves accordingly.
* Console Logging: You can print debug information using `console.log`. This allows you to inspect data during execution and helps with troubleshooting workflow behavior.

### Built-in methods and variables <a href="#built-in-methods-and-variables" id="built-in-methods-and-variables"></a>

iMBrace's workflow provides built-in methods and variables for working with data and accessing n8n data. The syntax to use the built-in methods and variables is `$variableName` or `$methodName()`. Type `$` in the Code node or expressions editor to see a list of suggested methods and variables.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://imbrace.gitbook.io/imbrace-documentation/workflows/function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
