Subflows
The ability to use flows within eachother is one of the most powerful features of Gumloop. It allows you to treat any flow like a node in another flow.
Using subflows is useful for two main reasons…
1. Cleanliness
Breaking up complicated logic into seperate functions is a common practice in programming and equally as useful on Gumloop. If you are automating a very large task, splitting each sub component into it’s own succinct flow will help with future maintenance.
2. Looping
Creating a subflow that performs one task very well and looping it is the best way to automate repetitive work. It makes it very easy to test the flow since you can run it one instance at a time.
Ex: You want to scrape a company’s website for contact info. You should build a flow that is perfected for the task and then use it as a subflow elsewhere, looping it on thousands of websites one by one.
3. N-th order nesting
This is similar to nested for-loops in programming. Let’s say you are processing an email inbox containing orders. One inbox has many orders, each order has many order items. If we wanted to run analysis on each order item we could have three flows and nest them!
We would start with one to process the entire email inbox and extract orders. We’d pass in this list of orders into a nested flow (in list mode) that processes a single order. Within that single order processing we’d pass each order item into the final nested automation that processes a single order item (using list mode). This is equivalent to having a triple nested for loop, allowing you to perform operations for each item regardless of nesting layers.
Using Subflows
Your flows can be used as nodes. Drag them onto the canvas just like you would a standard node to leverage the complexity of your existing flows within larger even larger creations.
In the flow builder, you should see the option ‘Subflow Library’ under the classic node library menu option. Click this to see all of your flow nodes. See image below.
Inputs and Outputs for Subflows
For a subflow to be useful, you need to be able to pass in inputs and get some output! Let’s walk through a quick example that breaks down how you specify both the inputs and outputs for a subflow.
Here’s an example of a flow that I want to reuse across other builds. It takes scrapes a website, extracts the company name, summarizes it and categorizes it.
For this example let’s say I want to reuse this flow by looping it over a google sheet full of websites. I’ll add a google sheet reader and try adding my subflow as a node (from flow menu on the left).
If you notice, this subflow node has no inputs or outputs! No way to connect a previous node to it. We can easily fix this, just a small tweak needed.
We need to go that subflow and add input and outputs nodes that specify the input and outputs we expect. In this case, we expect to be able to pass in a URL, so we add 1 input node and name it “URL”. (naming is optional)
If you save this subflow and return to your previous ‘parent’ flow, you’ll see that the subflow node now has an input called url. Success ✅
Now, we can do the same thing with outputs. I want to output the summary, the extracted name and the category outputted seperately. I’ll add 3 output nodes and save.
All done! Now your subflow can take inputs, spit back out outputs and mimics a node.