Iterating through a Sheets row

(Jerry Lawson) #1

Hey there,
Hope your brains are well rested and available!

My bot got a lot of content to output and its nature (ie, text, img, question…) depends on the user choices.
So, to streamline the process, I decided to put the content in Sheets and use a mapping system to decide what to post.

Basically: one of the sheets contains the sequence the user should receive,
for example: [a text, then a picture, another picture, a question, etc…]
I have other sheets for actual content, ie text, questions, image links, etc…
I want my bot to iterate through the sequence row and output content accordingly.
The process would thus be:

[1 - Get the rows]
Get the sequence row
Get the text content row
Get the [bla bla] content row
etc…
[2 - Start the loop]
Label: Loop start
Post text from column1 of text sheet if (using filters) sequence1 says “text”
post pic from column1 of pic sheet if sequence1 says “pic”
etc…
Go to label Loop if sequence[x] don’t say “exit”.

And here is the tricky part: How do I got the bot to do this and then move right in the row. How do I get them to move to “sequence2” after the loop? He already checked all the condition for the 1st column and put out the correct content. Now, I want it to move right in the sheet and do it for this other column.

It’s pretty complex so many thanks to anyone trying to help me with this one!

Creating a cycle using Google Sheets data
(Daniel Beckett) #2

Hi @Jerry_Lawson

If your Google Sheet was setup so that each ‘sequence’ was per row rather than per column then you could use a loop with a counter to progress through a maximum of 20 times.

For example you’d have a column for ‘sequence’ that’s numbered 1 to 20, progressing each row. Your other columns would then contain the content that you want to send to the user.

You can create a counter for the loop by using an Attribute that is incremented on each pass through the loop. Here’s an example flow showing this:

Hope that helps!

Thanks,
Dan

1 Like