Trying to Loop based on user input

Hi! I am trying to build a bot that will prompt a user to input a number (2,3,4,5, etc.) then the process will repeat that many corresponding times. The problem is, currently when it loops, even if you put in “2” as the input, it continuously loops.

Any advice on this?

1 Like

Hi @LeoHeff

Use kill process in the loop based on input dialog


There are two ways-

  1. If you are using self recovery flow decision then kill the process based on the value you pass to the bot.
  2. Use while loop and run it <=UserInput

Cheers @LeoHeff

have you incremented the value inside the loop every time it successfully completes one full cycle?

HI @LeoHeff

In your loop, have a condition that limits the iteration to the point where you need. So if you are using a while loop for example, have a counter variable that increments each time the loop is iterated and have a check to make sure the counter variable always stay less than or equal to the number that user provides. This condition will make sure the loop will not execute infinitely…

I think u missed out the Iterating the counter variable

1 Like

Hope these steps would help you resolve this issue buddy
—use a input dialog box activity and get the output from this activity with a variable of type string named out_value
—use a assign activity with a variable of type int32 counter with a default value of 0
— use a while loop with condition like this
Then inside the loop use any activity you want so that it will iterate till counter value buddy

Hope this would help
Kindly try this and let know for any queries or clarification
Cheers @LeoHeff

1 Like

—while still being in while loop at last use assign activity within this while loop that increments the counter

Cheers @LeoHeff

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.