# How to loop over actions

**URL:** <https://forum.rasa.com/t/how-to-loop-over-actions/33808>\
**Category:** Rasa Open Source\
**Created:** [September 16, 2020, 8:13am UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808 "2020-09-16T08:13:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thobson](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/thobson/32/10967_2.png) [@thobson](https://forum.rasa.com/u/thobson)\
**Post date:** [September 16, 2020, 8:13am UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/1 "2020-09-16T08:13:32Z")

</div>

I want to repeatedly perform an action until a condition is met. How can this be done in Rasa? I want something like:

```
* greet
 - utter_greet
  [    
 - action_ask_question
 - action_do_stuff
  ] ( repeat until condition is met )
 - utter_done

```

To give some background our bot makes a suggestion and asks the user “do you like this?”. The user can reply yes or no. We keep making suggestions until the user has said yes to N suggestions. We’ve built an action that does this based on slots but we can’t work out how to use stories to drive this flow (repeatedly invoke an action until the condition is met)

Thanks

---

<div class="post-metadata">

**Author:** ![j.mosig](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/j.mosig/32/3588_2.png) [@j.mosig](https://forum.rasa.com/u/j.mosig)\
**Post date:** [September 18, 2020, 1:48pm UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/2 "2020-09-18T13:48:16Z")

</div>

Hi @thobson

This is something you can do with a form and its validation function. The form will keep asking until its slots are filled, so you just have the validation function be the `action_do_stuff` and let it set the form’s slot to `none` if the condition is not met. See [Forms](https://legacy-docs-v1.rasa.com/core/forms/) (or [Handling Business Logic | Rasa Open Source Documentation](https://rasa.com/docs/rasa/business-logic) if you work with Rasa 2.0 rc1)

---

<div class="post-metadata">

**Author:** ![mattvan83](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mattvan83/32/12835_2.png) [@mattvan83](https://forum.rasa.com/u/mattvan83)\
**Post date:** [April 8, 2021, 9:46pm UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/3 "2021-04-08T21:46:27Z")

</div>

Hi @j.mosig I am really interested in repeating parts of a story/rule using Forms ([How to practically design chatbot with repeated parts of a story - #4 by mattvan83](http://forum.rasa.com/t/how-to-practically-design-chatbot-with-repeated-parts-of-a-story/42001/4)).

Could you help me get through?

Thanks!

---

<div class="post-metadata">

**Author:** ![j.mosig](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/j.mosig/32/3588_2.png) [@j.mosig](https://forum.rasa.com/u/j.mosig)\
**Post date:** [April 12, 2021, 12:48pm UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/4 "2021-04-12T12:48:28Z")

</div>

Melinda just replied on your thread. 🙂

---

<div class="post-metadata">

**Author:** ![mattvan83](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mattvan83/32/12835_2.png) [@mattvan83](https://forum.rasa.com/u/mattvan83)\
**Post date:** [April 13, 2021, 11:44am UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/5 "2021-04-13T11:44:08Z")

</div>

Thanks @j.mosig 🙂

---

<div class="post-metadata">

**Author:** ![athulvingt](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/athulvingt/32/16181_2.png) [@athulvingt](https://forum.rasa.com/u/athulvingt)\
**Post date:** [August 3, 2021, 2:06pm UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/6 "2021-08-03T14:06:17Z")

</div>

I know that forms keep on asking questions until the slots are filled, is it possible to perform actions in between this process. eg: suppose i am using forms to fill in details for for hotel booking, then the form ask questions to get the hotel name, room type, etc. After that only i can check if the room is available and if that hotel is not available i have to ask the question again. Instead of this process i want to run an action to fetch the available hotels and utter it before asking the question, “Which hotel do you prefer?”

---

<div class="post-metadata">

**Author:** ![athulvingt](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/athulvingt/32/16181_2.png) [@athulvingt](https://forum.rasa.com/u/athulvingt)\
**Post date:** [August 4, 2021, 10:36am UTC](https://forum.rasa.com/t/how-to-loop-over-actions/33808/7 "2021-08-04T10:36:19Z")

</div>

I found solution to this problem, Use action (utter ) to ask for next slot value , refer [Forms](https://rasa.com/docs/rasa/forms#validating-form-input)
