Building integration flow
This document provides a step-by-step instruction on building an advanced Integration Flow. It is intended for platform users who have at least some experience in building basic Flows.
For basic information on integration flows and how to create them, please read the Creating a Basic Integration Flow article. The integration flow in this document was created using many platform features such as: Transforming data, Content-Based Routing and Passthrough Feature.
In this example, we will create a flow that will send an email informing about the availability of sufficient renewable energy in the city in the next 3 days:
We used a Google Spreadsheet as a database containing information about name, city, postal code, API-key and email:
We could have used other components for this task, such as JDBC component, but in our case there is not much data, so the Google Spreadsheet is more convenient.
Configuring trigger
As a trigger, we use a Google Spreadsheet component that allows us to read information from a spreadsheet above. To do this, we need to select the spreadsheet - Database
in our case - we need and configure the rest of the input:
After successful configuration, request a sample:
REST API Configuration
In the next step, we will use the REST API component to get green energy information for the next 3 days for a specific city. We will take the necessary data such as postal code
from the previous step. If necessary, we can also add a header and use the API-key from the database for this:
https://api.corrently.io/v2.0/gsi/prediction?zip=POSTAL_CODE
As a sample, you will receive a large amount of data that needs to be processed in the next step:
Transformation Configuration
After we have received a large amount of data from the REST API component, we need to process it. We are interested in the average amount of available renewable energy in the city for the next 3 days. To get this figure, we create a variable Mean
that equals the arithmetic mean of the renewable energy over 3 days. To accomplish this task, we use the JSONata aka Transformation component:
We used the JSONata expression to get the value we needed. You can learn more about this in the Transforming data article. As a result of mapping you can see the Mean
variable. The same you can see in the Sample:
Routing
Our ultimate goal is to send 3 different emails: if the energy is less than 50
, then it is not enough, more than 50
but less than 54
, then it is enough and more than 54
, then it is in excess. In other words, we have a criteria for creating 3 different branches. To create them we use a Router component:
Now we need to configure the 3 remaining steps:
To learn more about Routing please read Content-Based Routing article.
E-mail Configuration
Now we just have to send emails to people from the database, which says how much renewable energy is in the next 3 days in their city. To do this, we will use a Email component:
As you can see, we took data such as email
, name
and city name
from the first step of our integration flow. We can do this with Passthrough Feature. Below you can see how to take information from the previous steps in the JSONata mode.
We configure the two remaining branches accordingly, depending on the amount of renewable energy available. As a result, the email will look like this:
As you can see, the text says that there is enough energy because the Mean
variable is equal 50.36
.