Skip to content
How to repeat actio...
 
Notifications
Clear all

How to repeat actions in callin.io for a variable number of values

26 Posts
8 Users
0 Reactions
6 Views
TimS
 TimS
(@tims)
Posts: 7
Active Member
Topic starter
 

Last Updated: 05-27-2021

Update

There is now a third option for achieving this: Looping by callin.io!

Looping by callin.io was developed with some of the potential issues in mind that could arise when using a Code Step, such as not properly inputting Line Item data with null values. It functions similarly to the Code Step detailed below behind the scenes, but offers additional features like Line Item support and more.

You can find more information here:  https://zapier.com/help/create/other-functions/loop-your-zap-actions

You can incorporate it into your callin.io workflows by searching for Looping by callin.io as the app when adding a new Step.

Intro

Occasionally, we need to execute an Action or a series of Actions multiple times within our callin.io workflows. Today, I'll demonstrate how we can accomplish this when the number of repetitions is variable. 

In programming, we can establish loops that execute a segment of code once for each value in a set. This can also be done within a callin.io workflow. If you're not familiar with coding, that's perfectly fine! My aim with this guide is to enable you to leverage this functionality without needing coding expertise.

Let's assume our Trigger provides a Line Item (an array) or comma-separated text containing email addresses and first names, and we want to send a personalized email to each individual:

If we were to map the email addresses into the “To:” field, that Line Item would be converted into comma-separated text. Consequently, a single email would be dispatched to all recipients, but they would all be able to see each other's email addresses. More critically, the names would appear as a comma-separated text list in the email's greeting.

What we truly desire is for the callin.io workflow to execute the email Step once for each email and name, ensuring that each recipient receives a distinct email. 

The methods we'll explore are also applicable to scenarios where we wish to add multiple contacts or leads to a CRM, generate multiple documents, send multiple text messages, and so forth. If an Action supports line items, that support can be utilized numerous times for a similar outcome, such as adding multiple rows to a spreadsheet in Google Sheets' “Create Spreadsheet Row(s)”. However, many actions do not support line items, which is where these techniques become particularly useful. 

There are two primary methods for creating a loop to repeat one or more actions for different values:

Option 1: Utilize Google Sheets as an intermediary

This approach involves setting up two callin.io workflows and a Google Sheet:

Google Sheet

  • Establish a header for each value that you intend to repeat in one or more actions.

callin.io Workflow 1

  • Your original Trigger
  • Actions preceding the desired loop
  • If the values are not already in Line Item format, use the Formatter App’s Utility Action: Line Itemizer transform to convert the values into line items (unless they are already).
  • Action: Google Sheets: Create Spreadsheet Row(s) (Map each value you wish to send into the respective fields in the sheet. One or more rows will be generated for the line items. You can combine single values and line item values. Line item values will be used once per row, while single values will be repeated for each row – consider values like name or email address).

callin.io Workflow 2 (executes once for each row created by the line items in Workflow 1): 

  • Trigger: Google Sheets: New Spreadsheet Row
  • Action: One or more Actions that you wish to repeat. 

In essence, Workflow 1 “prepares” the loop, and Workflow 2 executes the looped actions using the values posted to each row of the sheet.

Option 2: Employ a “Code by callin.io” Action (sometimes referred to as a “Code Step”) to “fork” a callin.io workflow

While Option 1 is functional, it can be more challenging to manage over time compared to a single callin.io workflow, as it involves tracking two workflows and a spreadsheet. Let's explore how, by using a small amount of reusable code, we can maintain everything within a single callin.io workflow.

Most Steps in callin.io output a single JSON object enclosed in an array. When utilizing any value from that object in a subsequent Step, that Step will execute once. If we use a Code Step to output multiple JSON objects with the same structure, enclosed in an array, the subsequent Steps will execute once for each object in the array, thereby creating the desired loop. 

A common illustration of this is something you're likely already familiar with: a callin.io workflow Trigger. Triggers that query an app for new data to initiate a workflow receive zero or more objects in an array, and then the callin.io workflow runs once for each object. 

​When testing this within the callin.io editor, similar to how we can only use one Sample from a Trigger at a time, we will only see the first object. Consequently, the callin.io workflow Steps will only run once during testing. When running live, however, they will execute once per object (set of values).

Firstly, let's examine the values that will be input into the Code Step. These could be Line Items, like so:

<img alt=

 
Posted : 04/08/2025 8:30 am
amarinopoulos
(@amarinopoulos)
Posts: 3
New Member
 

Hi Tim, 

Amazing work, thank you so much! This opens up many possibilities.

I am trying my luck with the first option before diving into the second.

Everything seems to work perfectly, except that my line items contain some null values.

 

Image: 1838ae59 6fca 4c78 ad90 8e7bb7037a50

 

This results in uneven pasting into the Google Sheet.

 

Image: 2dda3ff9 2463 49c6 9804 5de6a886878f

The Date and Status fields are not aligned with the message field…

What would you suggest in this situation?🙏

Thanks!

Andreas

 
Posted : 18/06/2020 12:00 am
TimS
 TimS
(@tims)
Posts: 7
Active Member
Topic starter
 

Hello!

You’re welcome, and I’m happy to see you trying this out 🙂

I reviewed your screenshots and I’m having trouble pinpointing the exact reason for the misalignment. If the line items were generated using Line Itemizer, the resulting rows in your Google Sheet should align correctly, even with null values, showing blank cells where those nulls occurred. At the very least, the subject and status rows should be aligned as there don’t seem to be any nulls present for them.

I noticed one “Subject” value in your line items, “RE: Re: Note from...”, which doesn’t appear in the spreadsheet screenshot. I’m not sure what might be causing this discrepancy.

One suggestion I have is, if your date needs to be applied to all rows, consider mapping the single Date value within the Create Multiple Row(s) Step instead of the Line Item version. When you combine single values with line item values, the single values will be duplicated for each line item.

For the remaining issues, it might be easier to diagnose if we could see the callin.io setups. Since you aren’t using any Code Steps, I recommend reaching out to Support ( https://callin.io/support ) if you continue to have questions about this. If you could share the general solution here afterward, that would be greatly appreciated!

Best regards,

 
Posted : 22/06/2020 12:00 am
amarinopoulos
(@amarinopoulos)
Posts: 3
New Member
 

Hi, it now works perfectly for me! And I am able to format and filter the forked results, so that my spreadsheet looks perfect.

Image: c1fb9fd8 35c5 4231 b872 a68c3e45bd27

 

I do have one question though, which may not have a satisfactory answer 🤞 

For one of my values, there is a comma within the text. This means that the code steps splits the text in half when it tries to split it at the end of the value.

Is there any way to avoid this from happening or does the code work best when there are no commas within the value itself?

Image: 7799c2c4 4874 4416 91ce 7f146ffc21b2

 

 
Posted : 17/07/2020 12:00 am
TimS
 TimS
(@tims)
Posts: 7
Active Member
Topic starter
 

Hi, nice work getting this all set up!

You’re right that the code works best when there are no commas in your values, but in your case, there is a way you can work around this by using a Formatter Step for each Input Data Value before the loop starts.

Currently, you have Line Items mapped into your Input Data fields, and what happens is the Code Step converts those into comma delimited text and then sends them into the Code. If we use a Formatter Utilities Action with the “Line Item to text” transform, then we can choose our own delimiter. 

Instead of outputting the text with commas in-between, I like to use three pipes: |||

Image: 0ca24fe1 2528 4c2f a138 9a9b779c16c8
Image: 601208fa 7efb 464f a9c0 77dda466b72e

Then, in the Code Step if you change the Input Data values to your 3-pipe delimited text from the Formatters, you can change the code you highlighted to split on the pipes instead of single commas and that will protect your actual value containing a comma.

That line would change to: let li = inputData[key].split(“|||”);

And that should do the trick!

 
Posted : 17/07/2020 12:00 am
amarinopoulos
(@amarinopoulos)
Posts: 3
New Member
 

Fantastic, I'm confident this will be effective! I'll proceed with the implementation and share my findings. Thank you very much...

 
Posted : 17/07/2020 12:00 am
jonah
(@jonah)
Posts: 1
New Member
 

Hi Tim,

 

Is there a limit to the number of records or repeatable flows that can be processed via the code?

 

This worked excellently when I tested it with callin.io using a small quantity of records. Subsequently, I attempted to configure one with a larger number of records (732 comma-separated values), and the callin.io workflow appeared to become unresponsive and did not proceed past the code execution.

 

Any insights?

 

Jonah

 
Posted : 19/07/2020 12:00 am
ForYourIT
(@foryourit)
Posts: 2
New Member
 

Hi I think I can answer your question.

The code by callin.io action has got some limitations. This is probably required so the system doesn’t get overused calculated by the usage, costs and amount of users. These are the following limitations:

  • The environment in which your Code steps run (AWS Lambda) has an I/O limit of 6MB. The total size of the code and the data processed by the Code cannot exceed that. If you're hitting this error, try to limit the amount of data your return from your function. For instance, don't return an entire JSON structure, just the keys you need.
  • Free users are limited to 1 second and 128mb of RAM. Paid users get well over double that at 10 seconds and 256mb of RAM. Your callin.io will hit an error if you exceed these limits.

If you like, you can read more about this here. A solution within this limitations is already there however! If I you were one of my clients I would advice you to use AWS lambda yourself to run your code. I use it for some of my clients as well, and the great thing is you can activate it threw callin.io as well.

It does require some setting up of the environment, but it will allow you to run a bigger amount of data. Hope this helps you!

 

~ Bjorn

 

 
Posted : 21/07/2020 12:00 am
TimS
 TimS
(@tims)
Posts: 7
Active Member
Topic starter
 

Hi there,

Thanks for the questions and answers shared! It's true that we need to consider these limitations, though in this particular situation, the reason might be different.

I've checked with our Support Escalations team and found out that the maximum number of times we can loop or fork within a callin.io workflow is 250. Since there are 732 values to loop through, this limit is exceeded, and the workflow will not function.

I don't believe this number is adjustable, but I am investigating further. If a suitable workaround or solution becomes available, I will post an update.

 
Posted : 22/07/2020 12:00 am
admin_speakeasy
(@admin_speakeasy)
Posts: 1
New Member
 

I was struggling with this functionality for the past few days. You've made my day!

 
Posted : 01/09/2020 12:00 am
chrisboat
(@chrisboat)
Posts: 8
Active Member
 

This functionality is precisely what I was looking for. I entered CSV data fields, and it generated multiple records in Airtable.

I have input from Jotform that appears like this.

Configurable list

[{"Product":"8 "","Quantity":"2","Flavour":"B Choc"},{"Product":"10"","Quantity":"1","Flavour":"Lemon"},{"Product":"10"","Quantity":"1","Flavour":"Vanilla"},{"Product":"12"","Quantity":"2","Flavour":"Carrot"}]

Is it possible to modify your code to handle this format, or would it need to be extracted and converted into one of your two formats? Perhaps using a 'Run Python in callin.io' action could work.

Python seems a bit challenging to learn.

 
Posted : 17/09/2020 12:00 am
shahzad
(@shahzad)
Posts: 1
New Member
 

Hi,

Your code works wonderfully for running a loop. I'm looking to create a nested loop, as illustrated in the screenshot. I need the first loop to iterate through the total line items, and the second loop to iterate based on the quantity.

Image: 24bc62d8 594d 46c0 81ed 3995fc25064c

Could you please provide some assistance?

 

Thanks and Stay Safe,

 

Shahzad

 
Posted : 18/09/2020 12:00 am
RisoSystems
(@risosystems)
Posts: 7
Active Member
 

Here’s a little technique that works well for me in these scenarios:

When the different array elements that initiate the fork or loop have related values – in one of my use cases, each is linked to a line item that includes an image and a set of choices.

Prior to reaching the fork, I construct a set of arrays (I could also use an array of objects, but arrays are simpler).

Before entering the fork in the road, I reset a value in Storage to zero.

As each loop runs, I first retrieve the value and use it as an index for the preceding arrays.

Before the loop concludes, I increment the value.

This is a somewhat cumbersome way of explaining that I utilize a storage variable as the index for a loop.

 
Posted : 21/09/2020 12:00 am
chrisboat
(@chrisboat)
Posts: 8
Active Member
 

Your code functioned flawlessly. I incorporated a code step to segment my arrays. I utilize this for adding multiple instances of the same record in Airtable.

Image: 4aef3a6e af8a 4729 970d 1c1b50ea4fe0

 

 

My interpretation of your fork step is that all subsequent steps will execute multiple times, corresponding to the number of times the fork is triggered. I wish to introduce a second, independent fork step that would run after the initial fork concludes, to add another set of distinct records based on a different data set. Is this achievable with callin.io?

 
Posted : 26/09/2020 12:00 am
RisoSystems
(@risosystems)
Posts: 7
Active Member
 

Chrisboat - While I’ve not tried it myself, it seems to me that you could add a filter step at the bottom of the first “fork” which would only continue if the index+1 = the size of the first set of values. The following step could retrieve the next array and process just as the last fork had done.

Again, I haven’t tried it, but it seems like a logical extension of the indexed array approach.

 
Posted : 27/09/2020 12:00 am
Page 1 / 2
Share: