Create functions to reuse queries and logic in workflows
Learn how to create reusable blocks in a workflow.
Functions are reusable blocks that run in a headless state. They operate outside of the control flow and do not appear on the canvas. You call a function from JavaScript Code blocks which can pass data as parameters. This reduces the need for query duplication and enables you to perform certain tasks only when necessary.
Add a function
Click Functions in the left panel, then click + to create a function. You can configure optional parameters for each block that you can reference within the block itself. Each parameter must have a test value so it can perform a test run without being called.
Call a function
You call a function using await
and include parameters, if required. For example:
const email = getUsers.data[0].email;
const name = getUsers.data[0].name;
await function1(name, email);
The Function block returns its output back to the block from which it was called, allowing it to be used in the rest of the workflow.