How do we create a recursion or a loop in a flow? Because I have tried with giving next to same step id and it uttered the same response for 5 times. Then I have added ask_before_filling: true to make it utter one time and ask again. But the problem is what if a user already gives the required information and bot asks again no matter what the slot is filled with due to ask_before_filling: true line under collect.
Thanks for the fine tuning document link, I will look into it.
The use case where I want to use recursion could be in this way:
- collect: preferred_city
description: Collects the specific city that the caller is interested in.
id: city_preference
ask_before_filling: true
next:
- if: slots.preferred_city = "bangalore"
then:
- action: utter_bangalore_colleges
next: name
- if: slots.preferred_city = "hyderabad"
then:
- action: utter_hyderabad_colleges
next: name
- if: slots.preferred_city = "mumbai" or slots.preferred_city = "bombay"
then:
- action: utter_mumbai_colleges
next: name
- else:
- action: utter_sorry
next: city_preference
But as a custom action I am also collecting is the user gives the city name before the specified step, and this step is asking no matter what user gives due ask_before_filling: true which I am actually using to avoid recurring same utterance such as:
utter_sorry:
- text: "Sorry! currently we are not available in that city. But you can choose a nearest city from these: Bangalore or Hyderabad or Mumbai."
If not the utter_sorry will be uttered 5 times.
Also if the LLMs, that are already fine tuned for the purpose of compatibility with Rasa, are provided, it would be a great help towards community.
One option is to change preferred_city to a categorical slot and then it will only accept a list of cities that you choose. Another option is that the else can erase the slot.
It’s not directly related to your question but I would remove all of the if tests and use Conditional Response Variations instead.
I have used the set_slots in the else step to erase the slot, removed the ask_before_filling: true and now it is working good as expected without uttering the response 5 times.
I would like to provide a suggestion regarding Conditional Response Variations. Currently, it appears that conditions in response variances work only when the slot type is set to bool. While this is useful, it would greatly enhance flexibility and functionality if conditions could also work with categorical slot types, allowing any text value to be used as the condition instead of being limited to true or false.
This addition would enable more nuanced and varied responses based on the values of categorical slots, providing a richer user experience.
Thank you for considering this suggestion. I look forward to any updates on this feature.
Hey @stephens , I wanted to let you know that I had actually tried the solution you suggested before, but it didn’t seem to work at the time. However, I gave it another shot after your recommendation, and now it’s working perfectly! I really appreciate your help and persistence—thanks again!