Over the past few months, multiple customers have been asking us how to automatically run one or multiple actions for each item within a list. For example, to automatically add individual meeting invitees that attended to a CRM after an event ended.
To help you automate use cases that require you to iterate over items in a list, we launched a new flow control feature: the Iterator.
Iterators let you perform a single or multiple actions for each item in a list. To understand how iterators might help you automate your workflows, let’s look at some examples.
Example 1: Automatically add event attendees to a spreadsheet
Goal: add a row to a Google Spreadsheet for each guest in a newly scheduled Calendly event.
Here’s how to create a playbook in Relay.app does just that:
- First, add a Trigger for the event type that you’re interested in
- Next, add an Iterator. You’ll want to set up the iterator to iterate over the list of Guests for the Calendly event that triggered the playbook run.
- And finally, add a step inside the Iterator that adds a row to the Google Spreadsheet you’re using to track attendees for this event type. This step will be run once for each Guest in the Calendly event.
Of course you’ll also be able to automate multiple actions within each iteration as well. See the next example.
Example 2: Daily bug escalations
Goal: every morning at 8am, ping the #bug-escalations Slack channel for each issue in Jira that’s overdue. Plus, add a comment to each of these respective issues to nudge its assignee.
Here’s how to create a playbook in Relay.app does just that:
- First, add a “Recurring schedule” trigger that triggers new playbook runs at the desired frequency, e.g. every morning at 8am
- Then, add a “Jira - Get Issue(s)” step. Configure it so that it finds issues that are overdue, and that it will return the entire list of all these issues (instead of just the most recent one, which is the defaut)
- Next, add an Iterator and set it up to iterate over the Issues output from the previously added Get step
Finally, add steps inside your Iterator for all the actions that need to happen for each issue. Specifically sending a Slack message to a channel and adding a comment to the issue to nudge the assignee. These steps will run once for each issue that came out of the Get step above.
Example 3: Automatically send an email to select contacts for a closed HubSpot Deal
Goal: send a “Excited to work together” email to your champion- and sponsor-labeled contacts that work at the company you just signed a new deal with.
Here’s how to create a playbook in Relay.app does just that:
- First, set up a HubSpot trigger for the “Deal reaches stage” event. In this case, we’ll want to trigger playbook runs for Deals that reach the ‘Closed Won’ stage
- Next, we’ll set up an Iterator. The HubSpot Deal that came out of the Trigger has a number of list fields, one of them being “Associated contacts”. Select this as your list variable to iterate through.
- However, in this case we’ll not just want to send an email to *all* contacts, only those with the specific “Buyer Role’ of “Champion” or “Executive Sponsor”. So in this case we’ll add a filter to the Iterator that filters contacts that don’t match either of these conditions
- Finally, we’ll add a “Send email” action from Gmail or Outlook inside the iterator, with a templated message.
How to get "lists of items"
You can add iterators in your playbook via the ‘Flow control’ menu in the Step list. Iterators iterate over “lists of items”. There are two primary mechanisms how you get “lists of items” in your playbook:
1. Explicitly, via "Get" steps
For example via a Linear - Get issue(s) step or a Google Sheets - Get row(s) step.
Previously, Get steps always returned at most one item. Starting today, you will be able to configure Get steps to return a list of items.
2. Lists as embedded fields within a Step or Trigger output
Some Step and Trigger outputs contain fields that are lists themselves. For example, the "Guests" property of a Calendar event is a list, or “Attachments” field of an email. To help you identify lists, these fields have a small badge (with three horizontal lines) on top of the regular type icons.
What’s next
In the future, we will launch more features that let you do things with lists, as well as support other “iterative” use cases.
I hope the use cases above gave some inspiration on how to use Iterators in Relay.app. Let us know about the use case you’d like to be able to automate!