In this tutorial, we will learn how to create loops with Action(s).

Loops allow you to repeat a part or all of your work flow multiple times. There are two different actions that you can use to create loops:
The first action call the Loop, allows you to loop back a pre-set number of times. The second action allows you to Dispense Items incrementally so that you can work with each item in a list one by one.

Our example will demonstrate how to use the "loop back” action. Let’s say that you are having a party at home tonight. A lot of friends are coming and you can be sure that tomorrow, they will all want the pictures of the evening. But of course, it will be difficult to remember who was there, and you are not even sure that you have all their email addresses.

The little workflow that we will create in this example will solve all of your problems. It will display a window that will prompt your friends to input their email addresses. Once the addresses are inputted, the workflow will send them an email telling them that the pictures will be available on Facebook tomorrow.

  1. So, the first step in our workflow is to ask the users for their email addresses. To do so, go into the Text category, choose the Ask for Text action and drag it into your workflow. The question will be “Hi, please let me have your email address:
  2. We will store this answer in a variable. To do so, let’s go into the Variable category, choose New Text and drag it into our workflow. A new variable named New Text 1 is created and an action is added to the workflow. Do not forget to check the Select the result of the previous action as the value of the variable box so the input is stored within the variable.
  3. Then, we want to Send an email message to our friends. This action is available in the Email category. We will use the variable New text 1 as the recipient and input a nice message.
  4. And we can finish by displaying a message saying that an email has been sent. Use the Show Message action in the Other category.
  5. So our workflow is that easy. However, if we run it now, it will run once and then stop. What we want is for the workflow to repeat itself again and again so each one of our friends gets a chance to enter their email address. That’s where the loop comes into play. In the Other category, choose Loop and add it at the end of your workflow. We want the workflow to run all evening, so we will define that it should Loop automatically for 180 minutes. We will loop back to the beginning of the workflow, but as you can see it is possible to loop back to any previous task in the workflow. Leave the other options as defaults.

Our workflow is ready. When we run it, it first asks for the email address and then automatically sends an email message. Once the execution is finished and the email is sent, the workflow restarts from the beginning and re-asks for a new email address, again and again, until the end of the party!

Visit http://app.jbbres.com/actions for more information about Action(s).