Buildable
Search…
Add Nodes to a Flow
Everything you need to know about Nodes (i.e., the building blocks of your Flows)!

Overview

Nodes are the building blocks of your Flow and are incredibly simple to add using the canvas. As you're building, it's important to keep in mind that each Node should ideally represent one logic step in your Flow.

Adding your first node

All flows start with an initial Trigger Node that handles the entry point and response of your flow. To add your first Node below the Trigger, simply click the + button that appears when you hover over the trigger node card.
Adding a Node to a Flow

What makes up a node?

Every node is comprised of an input and run function. Double click a Node to view and edit either function.
Double click a node to view/edit its Input and Run functions
Input
Run
The input function’s sole purpose is to select the data that will be passed into the run function of that node.
It has access to:
  • $trigger - The flow's request object
  • $nodes - The outputs of all nodes above itself
You can read more about these global variables in the Understanding Global Variables section below
It’s important to make sure your input function is only used for selection and not for processing. Following best practices, you shouldn’t write any logic within the Input function. To enforce this, Buildable purposefully allocates lower resources for input functions.
Below is an example of the input function.
1
/**
2
* Lets you select the input for your node
3
*
4
* @param {Params} params
5
* @param {Object} $trigger - This flow's request object
6
* @param {Object} $nodes - Data from above nodes
7
*/
8
const nodeInput = ({ $trigger, $nodes }) => {
9
return {
10
name: $trigger.body.name
11
}
12
}
Copied!
The run function is where you write the processing and logic of your node. Whatever is returned in the run function will be the response of the node.
It has access to:
  • input - The values passed in from the input function
Below is an example of the run function, accessing the values we passed in from the input function.
1
/**
2
* @param {Run} input
3
*/
4
const run = (input) => {
5
return {
6
message: `Hey, ${input.name}!` // Passed from the input function
7
};
8
}
Copied!

Understanding Global Variables

The input function of your nodes will have access to 2 global variables, which are $trigger and $nodes. The below section highlights both types.
1. $trigger
  • method- The request method (GET, POST, PUT, PATCH, or DELETE).
  • headers - The request headers.
  • params
    • env - The environment that you’re testing in.
    • flowPointer - Your flow’s unique slug.
    • p0pN - Params passed in via the URL. Each param will have the property name pN, where N = the param’s position in the URL.
  • query
    • Query data passed via the URL.
  • body - Data passed to the body. This will not be parsed if the request method is GET.
2. $nodes
An object of objects, containing the output of each node above the current node. The image below outlines the available context for each node using arrow pointers. As visible, only the Trigger Node has access to the output of all nodes. Every node only has access to the outputs of the nodes above it.
How to think about node access

Available nodes

There are 4 types of Nodes, which are all very similar in behaviour aside from a few key nuances. Learn about each type below:

Best Practices 🙌

  1. 1.
    Be Descriptive
    When creating Nodes, be sure to include a title and description to ensure maximum flow readability.
  2. 2.
    Single Purpose Development
    Every Node should ideally perform one task, towards a single purpose. This allows for developers to simplify their code and reduce the possibility of technical debt down the road. Following this practice will also provide you with an accurate visual representation of your backend system.
  3. 3.
    Node Naming
    Avoid naming your Nodes like a function/method, the Node’s name represent the output of the Node not the Node itself. Therefore, the Node should be named based on the data it outputs.
    For example if you have a Node getting the user data, then don’t name the Node getUserData instead name it user. In another word, treat the Node like a variable.
    For example, in code we would not do this:
    const getUser = await service.call("user.get")
    But would do this:
    const user = await service.call("user.get")
    This will make the code much more real when you want to reference the Node again. For example, if you set the input to the user it is better to do $nodes.user than $nodes.getUserData since the name with the get feel like a method and might be misunderstood.
Last modified 3d ago