Need help building a loop in RapidPro (iterate over a list and stop at the end)

16 views
Skip to first unread message

Justin Ndiaye

unread,
Jul 1, 2025, 5:35:43 PMJul 1
to rapidpro-dev

Hi everyone,

I'm working on a RapidPro flow (integrated with CHT) where I retrieve a list of children from a household using a webhook. My goal is to loop through this list (webhook.rows) and, for each child, send specific data (like child_name, child_id, etc.) via another webhook.

Here’s what I’ve already implemented:

  • I initialize an index at 0 (results.index).

  • I access child data using webhook.rows[results.index].

  • After processing one child, I increment the index with @results.index + 1 and loop back to continue.

  • I use @((webhook.rows)[results.index]).value to extract values from each row.

The problem:
I’m struggling to detect the end of the list properly. I can’t find a reliable way to stop the loop once all rows have been processed.

My question:

How can I write a condition in a split by expression that checks if results.index is beyond the size of webhook.rows? Is there a way to determine the list length or to safely detect that the current index is out of bounds?

Thanks in advance for any help, or if you have a working loop example to share!

Best regards,
Justin

Reply all
Reply to author
Forward
0 new messages