For the complete documentation index, see llms.txt. This page is also available as Markdown.

2.5 🧠 Let’s Make Our Workflow Repeat and Think

Let’s build smarter workflows with logic.

Scenario: From a given array of emails, print individually if an email ends with gmail.com or yahoo.com or not.

1

Initialize Variable

Create a New Batch Workflow. Assume you have an array of emails. Let’s initialize a variable with the following details:

emails

JSON

["abc@gmail.com", "def@gmail.com", "xyz@company.com", "ijk@yahoo.com"]


2

Loop through the JSON Array

Add a loop tool to iterate through the JSON Array. By default, loop through values is selected as loop type which is for loop iterating through all values. In iterable, choose from Data Hub, variables -> emails.

3

Configure Decision Step

Add a decision step inside the loop. The Decision step works like a conditional ladder — if a condition is met, that pathway runs; otherwise it checks the next condition, and so on until the else pathway. We have the ability to configure a title for each pathway. Let us have Option A for filtering emails ending with gmail.com, option B for filtering emails ending with Ending with yahoo.com and an else pathway. For each pathway to be executed, configure the condition to satisfy as shown below.

If your use case demands a complex/nested condition, you can use the plus icon.

4

Add a Console for Option A

Click on Option A of Decision Step and add a Console. The current item being considered in the iteration is accessible in the Data Hub’s item when clicking plus icon before loop.

Configure the message as {{1.item}} ends with gmail.com

5

Add a Console for Option B

For Option B, add a console with message, {{1.item}} ends with yahoo.com and for else pathway, add a console with message - {{1.item}} does not end with gmail.com and yahoo.com

6

Save and Run

Enable console logs and save the workflow and run. Check logs.

🎉 You have successfully used Loop and Decision together in a workflow!

Last updated

Was this helpful?