Articles on: Automation docs

Orchestrate Workflow Steps



Hi there! In this tutorial we are going to talk about orchestrating your workflow steps.

In this demonstration, we will showcase the multiple steps, conditional, and iteration capabilities of Easyflow. We will also take a brief look at variables, mappers, and function expressions.

In this example, we are going to collect website traffic data from Google Analytics and then insert these data into Google Sheets.

We will also create an input variable to instruct the flow in which spreadsheets the data should be inserted. This will help to demonstrate the conditional steps.

In addition, we will insert information about these operations into the logs spreadsheet. We will also use the For Loop connector to insert iterative data into an additional spreadsheet to showcase its capabilities.

Accordingly, we created four spreadsheets in Google Sheets, Sheet1, Sheet2, Logs, and Loop. The Logs spreadsheet has three columns to log the workflow operations.

Let’s connect to Google Analytics and read the Traffic Metrics. We will configure the “Start Date” as yesterday and the “End Date” as Today.

Also, don’t forget to set Google Analytics as a starting point, so the workflow will start at this step.

Now, we are going to link Google Analytics to 2 different Google Sheets connectors in order to insert Traffic Metrics records. Each connector will have a condition based on the “Sheet Name” input variable.

To set up a condition, simply choose a link and determine the condition criteria using the function expressions.

Now, it’s time to configure the Google Sheets Steps in order to read the information from Google Analytics.

As shown, each connector's traffic data is clearly and graphically represented, making it easy to map Traffic Metrics to Google Sheet.

Simply, by clicking on the corresponding data key.

The next step is to configure the Logs step to insert information about the insertion activities into the “Logs Spreadsheet”.

This step requires more advanced logic to calculate and shape the received traffic data. This is why we are going to use the “Built-in” Mapper connector.

With the mapper connectors, we are going to prepare the request payload that will be sent to the Google Logs Spreadsheet. This payload consists of 3 keys: Sheet Name, Number of Inserted Records and the Date.

As you can see,

We picked up the Sheet Name from input variables

We calculate the number of Traffic Metrics by calculating the length of Google Sheet received records using the Length array function expression

We determined the date using the “Now Date” from date function expressions.

Next we are going to link all the steps together. Sheet1, Sheet2 to the Logs Payload, then to the Google Sheet Logs.

Also, we need to map the Logs Payload to Google Sheet Logs connectors.

It is time to test our workflow and see how it will perform. Let us run the workflow from the Run button, set sheet1 as value for sheet name key and press run.

This is great news - the traffic data has been inserted into the spreadsheet as expected, and logs have been added to the spreadsheet logs.

Let’s move to the next step and quickly talk about the For Loop connector.

We will be using a simple logic to incrementally add numbers in a separate row in a Google Loop Spreadsheet. The number will start from 0 and keep increasing by 1 until it reaches the number of received metrics traffic records.

To implement this logic we need to do the following:

In the For Loop connector, we have to define a function expression to calculate the length of “Metric traffic records”. The loop will start iterating from 0 till reach this length, incrementing by 1

We need a mapper to prepare the payload for Google Sheet. It’s simply the value of the current loop index

We need a Variable to be incremented by one in each loop.

Finally don’t forget to connect the last step of the loop logic back to the for loop itself.

Let’s Run the workflow and see if we got something into Loop Spreadsheet.

The data is kept updated in the spreadsheet as the workflow runs, which is very cool to look at.

Thank you for watching this tutorial.
Please feel free to contact us if you have any questions.

Updated on: 04/08/2022

Was this article helpful?

Share your feedback

Cancel

Thank you!