Hello everyone!
I’m working with Rasa version 3.2.1. I’m wondering how can I break the story loop, when user has listed all the sentences of a topic (a string array). Hopefully the following code will clarify my issue.
Stories:
stories:
- story: user wants to know bio of a named person
steps:
- intent: tell_me_about_person
entities:
- PERSON
- action: action_fetch_person_bio
- action: utter_select_topic
- intent: topic_number
entities:
- NUMBER
- action: action_show_topic
- active_loop: null
- action: utter_more_bio
- intent: affirm_more
- action: action_show_topic
- active_loop: list_bio_form
- story: user wants to stop listing bio of a named person
steps:
- active_loop: null
- action: utter_more_bio
- intent: deny_more
- active_loop: null
Actions.py:
class ActionShowTopic(Action):
def name(self) -> Text:
return "action_show_topic"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain) -> List[Dict[Text, Any]]:
try:
topic_nr_slot = int(tracker.get_slot("topic_nr_slot"))
except:
dispatcher.utter_message(text="Please make sure the number is in numerical form.")
return []
topic = tracker.get_slot("topic")
try:
count = int(tracker.get_slot("count"))
except:
return []
dispatcher.utter_message(text=str(topic[topic_nr_slot][count]))
count = count + 1
if count == len(topic[topic_nr_slot]):
#
pass
else:
return [SlotSet("count",count)]
What I’m trying to do is to break the story loop when “count == len(topic[topic_nr_slot])”.
Thanks in advance!