Rasa story condition

Hello, I’am using rasa 3.5.3 (latest version released in 2023) and I’m very new with it. I have defined this story below

  • story: interview_po_1 steps:

    • intent: greet
    • action: utter_greet
    • action: utter_ready_check
    • intent: candidate_ready
    • action: utter_company_pres_po
    • action: utter_any_questions
    • intent: affirm
    • action: utter_hr_follow_up
    • intent: candidate_question
    • action: utter_noted
    • intent: deny
    • action: utter_pres_question1
    • intent: pres_answer1
    • action: utter_feedback

    This story is not working as intended, what I want this story to achieve is: When the bots gets to “utter_any_questions” he basically asks the user if he has any questions , the user will deny or affirm wether he has questions or not. If he affirms the bot goes through

  • action: utter_hr_follow_up

  • intent: candidate_question

  • action: utter_noted

if he denies the bot is intended to skip that part and move on to the rest of the story that is defined right under the intent “deny”

I have a feeling that rasa has something for conditional cases in stories.yml but I couldn’t find it, if you know anything that could help please let me know :slight_smile:

Hi,

I believe you can use Checkpoints, although it is not generally recommended to overuse them. You can however ensure that your story is progressing as you intended it to using checkpoints at appropriate locations of the story. For example, you can use utter_any_questions as a checkpoint for the story to branch out into two different stories - one if they user affirms and another if the user denies.

Please do note that it would be better to split your story into different parts, each corresponding to a specific task, so that you can have clarity as well as debug issues easily.

Finally, I believe that it is better to build stories using rasa interactive. Please consider it.

1 Like

Thanks for the reply I have just tried checkpoints as you recommended, however, whenever I enter the value of the first intent in the interview_po_1 (greet) it totally neglects it and goes with the story continue_story I never tried rasa interractive, I will try it out it might be the solution

- story: continue_story
  steps:
  - action: utter_pres_question1
  - intent: pres_answer1
  - action: utter_feedback
  - checkpoint: questions

- story: interview_po_1
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ready_check
  - intent: candidate_ready
  - action: utter_company_pres_po
  - action: utter_any_questions
  - intent: affirm
  - checkpoint: questions
  - action: utter_hr_follow_up
  - intent: candidate_question
  - action: utter_noted
  - intent: deny

Hi, I believe that checkpoints occur either at the beginning or at the end of the story or both. It is necessary that if you end a story with a checkpoint, you have to start a story with a checkpoint as well. Details are in the documentation. Perhaps you can try like so:


- story: Interview
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ready_check
  - intent: candidate_ready
  - action: utter_company_pres_po
  - action: utter_any_questions
  - checkpoint: utter_any_questions
  

- story: User has followup questions
  steps:
  - checkpoint: utter_any_questions
  - intent: affirm
  - checkpoint: questions
  - action: utter_hr_follow_up
  - intent: candidate_question
  - action: utter_noted

- story: User does not have any followup questions
  steps:
  - checkpoint: utter_any_questions
  - intent: deny
  # Any further logic goes below if the user does not have followup questions
  # For example, say goodbye to candidate
  - action: utter_goodbye

Please note that using checkpoints excessively decreases story readability and increases training time.

This works as intended except for the fact that I want it to go through - action: utter_goodbye right after - story: User has followup questions, the logic behind this is to have the bot go through the same closure after taking the candidate’s question. Taking that in consideration, this how I would edit the code:

- story: Interview
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ready_check
  - intent: candidate_ready
  - action: utter_company_pres_po
  - action: utter_any_questions
  - checkpoint: utter_any_questions
  

- story: User has followup questions
  steps:
  - checkpoint: utter_any_questions
  - intent: affirm
  - checkpoint: questions
  - action: utter_hr_follow_up
  - intent: candidate_question
  - action: utter_noted
  - action: utter_goodbye #This is what I added


- story: User does not have any followup questions
  steps:
  - checkpoint: utter_any_questions
  - intent: deny
  # Any further logic goes below if the user does not have followup questions
  # For example, say goodbye to candidate
  - action: utter_goodbye

The only issue here is that I have - action: utter_goodbye replicated which is something that I don’t want, I m using this story just to test stuff out but in the main project I’m working on I have a lot more intents and actions going on, there will be around +20 intents and actions replicated if I go by the same logic.

Hi,

The idea of checkpoints is to have a part of a story that remains the same and then branch the story into distinct parts, as I mentioned earlier. If you have a large number of intents/actions that are same for two stories and if you cannot have checkpoints that make sense to your flow of stories, I would recommend you play around with rasa interactive and also have a look at custom actions to see if you can have some sort of logic in your action.py file and then call the action onto your story, depending on your needs.

1 Like

I found a solution, I made another checkpoint that has the shared part between the 2 scenarios, so that after “branching the story into distinct parts” it goes back to the part where it remains the same. Thanks a lot Shenin for the time and effort that you have provided :slight_smile:

stories:

- story: Interview
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ready_check
  - intent: candidate_ready
  - action: utter_company_pres_po
  - action: utter_any_questions
  - checkpoint: utter_any_questions
  

- story: User has followup questions
  steps:
  - checkpoint: utter_any_questions
  - intent: affirm
  - checkpoint: questions
  - action: utter_hr_follow_up
  - intent: candidate_question
  - action: utter_noted
  - checkpoint: shared_questions

- story: User does not have any followup questions
  steps:
  - checkpoint: utter_any_questions
  - intent: deny
  - action: utter_trans
  - checkpoint: shared_questions



- story: shared questions
  steps:
  - checkpoint: shared_questions
  - action: utter_pres_question1
  - intent: pres_answer1
  - action: utter_feedback


1 Like

Long stories like this along with checkpoints are not recommended. I would use forms.

1 Like

I read the documentation about the forms but I still can’t see how I could achieve the same functionality with forms, could you perhaps give me a tip? thank you in advance :slight_smile:

1 Like

I have a similar case here. I have a “Happy story” that conceptually is alike:

  • Story: Happy story
    • action: utter_greeting_help
    • intent: general_info
    • action: utter_general_info
    • intent: agree
    • action: utter_requirements
    • intent: agree
    • action: action_lookup_kiosk_info
    • action: utter_all_questions_answered
    • intent: agree
    • action: utter_goodbye The problem I am having is that each confirmation step wold diverge into more stories that go into either: A
    • action: utter_all_questions_answered
    • intent: agree
    • action: utter_goodbye

or B

  • action: utter_all_questions_answered
  • intent: deny
  • action: utter_offer_help

On top of that any person could ask for the requirements and ideally would stem into the middle of the “Happy story” pipeline.

I can not see how can this be handled only by defining end to end stories. As variations would escalate greatly the more validations there are, given that they need to be created “manually”.

I think such behavior can be achieved using a checkpoint after each validation. Despite reading quite often how using checkpoint is discouraged, little I have found about how much it would impact the bots performance. It is always mentioned it will slow the training process.

Can you think of any approach for this case? Is there any documentation on how Checkpoints affect training and operational performance? (besides this hi level explanation on how it works)