Share feedback, ideas and get community help

Updated 5 months ago

How to repeat steps multiple times and store the results in an array or in sub-variables?

At a glance

The community member is creating a flow that asks for information from a borrower and a co-borrower, and the questions are the same for both. The current approach of duplicating and updating each step is tedious, as each variable is different and needs to be updated for each step. The community members suggest two solutions:

1. A solution using a feature from https://github.com/baptisteArno/typebot.io/issues/249.

2. An alternative solution where the community member stores the current defined variables under a namespace variable, jumps back to the start of the flow, and uses a different namespace for the co-borrower.

There is no explicitly marked answer in the comments.

Useful resources
I'm creating a flow asking about information to a borrower and a co-borrower.
The questions are the same for both. The way around this today is duplicating and updating each step two or three times based on the number of borrowers, which is quite tedious since each variable is different and needs to be updated for each step.

Any ideas? Thanks!

The result would look something like this
Plain Text
{
  "borrower.name": "John Doe",
  "borrower.email": "borrower@example.com",
  "borrower.phone": "1234567890",
  "coBorrower.name": "Jane Doe",
  "coBorrower.email": "coborrower@example.com",
  "coBorrower.phone": "1234567890"
}
B
t
3 comments
Amazing, thanks!
An alternative but more creative solution if we had access to a list of defined variables mid-typebot in the script block:
  1. Once the flow is completed, store current defined variables under a namespace variable, for example: name -> borrower.name
  2. Jump back to the start of the flow
  3. Once you reach the end of the flow, you are back at step 1, use a different namespace, for example coBorrower.name
  4. Do this as many times as needed
Add a reply
Sign up and join the conversation on Discord