Creating Subflows

Written By Chetan Iterate ()

Updated at April 19th, 2022

We sometimes think about the flows being created, need to be optimized and could create some complex flow as a module and use it in a later scenario? or making clean, moduler code blocks that are re-usable, efficient and change them without breaking the whole program.

Well, we got you covered, we can create a subflow and deploy a single node to perform operations as we desired and we can design subflows on very own choice! Here we are taking example of creating a simple REST API and giving responses of GET request.

Steps

1) First look at the editor tab and remember the name of the tab, you can change the name by double-clicking as you like

So first we search and dragged to the editor nodes named 'HTTP','Function','msg','HTTP response' and connected like this:

Now double click on HTTP and edit the properties that is :

For the 'Function' Node:


In This API, it just receives the text which msg.payload had parsed in.

And for HTTP out:

Deploy and give a HTTP request:

http://<Instance_Name>.interplay.iterate.ai/demoapi

2) To create a subflow, Click on 

Now  the new tab of  'Subflow' will be open as 'Subflow1' and a new Node should appear in the nodes tab under the same tab name

3) Now Click on input '1' and output '+' sign, we can see some new elements on screen:

4) Introduce a Node.js function and join its input and output node, editing the properties like this:

5) Now head to The original tab where the Main flow is created, search for the subflow you just created by its name (Here we named 'subflow1') and introduced in editor

6) Next we can use the subflow by routing the flow through it.7) Deploy and see the result!

In this way, we used the subflow which incorporates another function with parses different payload 'Yes,sure' in the same msg.payload.

By subflows, you can create subflows from complex function, API calls, Cryptocurrency Transaction up to making an API with a machine learning model.

Was this article helpful?