How exactly do stories work?

I had read the documentation on Stories and looked up tutorials but I could not find an explanation. I have no idea what the expected behaviour of stories is supposed to be.

I have these 4 stories and 1 checkpoint:

- story: provide recipe path
  steps:
  - checkpoint: provide_recipe
  - action: utter_provide_recipe

- story: happy neutral path want recipe
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_greet_follow_up
  - intent: mood_great_or_neutral
  - action: utter_happy
  - action: utter_want_recipe
  - intent: affirm
  - slot_was_set:
    - want_recipe: true
  - checkpoint: provide_recipe


- story: happy neutral path dont want recipe
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_greet_follow_up
  - intent: mood_great_or_neutral
  - action: utter_happy
  - action: utter_want_recipe
  - intent: deny
  - slot_was_set:
    - want_recipe: false

- story: sad path want recipe
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_greet_follow_up
  - intent: mood_unhappy
  - action: utter_sympathy
  - action: utter_want_recipe
  - intent: affirm
  - slot_was_set:
    - want_recipe: true
  - checkpoint: provide_recipe

- story: sad path dont want recipe
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_greet_follow_up
  - intent: mood_unhappy
  - action: utter_sympathy
  - action: utter_want_recipe
  - intent: deny
  - slot_was_set:
    - want_recipe: false

I had assumed that stories strictly control the flow of the conversation, until I came across these two posts Cant we skip and jump to some intent within a story and Story Flow , and they seem to imply that conversation is not meant to strictly follow the story paths. However, as mentioned at the beginning of the post, I could not find any documentation explaining the expected behaviour of stories.

In my project, in any story path, no matter which step of the story I’m at, if I type “yes” or any other affirmative word, the chatbot replies with utter_want_recipe.

Similarly, if I’m on “sad path want recipe” and type “im fine”, the chatbot responds with utter_happy; if I’m on “happy neutral path want recipe” and type “sad”,the chatbot responds with utter_sympathy.

My stories appear to be acting like rules instead of stories. Am I doing something wrong, or is this supposed to happen?

@lamxw2 Your chatbot is train based on mood bot, a pre-trained rasa model, change the utterances & Intents from nlu.yml of both happy and sad you will be good to go, i.e utter_happy and utter_sympathy etc. Note, please delete all the previous trained model and re-train and run. Thanks. Nik

Hi, what do you mean by change? Do I rename the intents and utterances to something else? How do I know if my chatbot is trained on mood bot?

@lamxw2 Just check the intent of utter_happy, mood_greet_or_neutral and mood_unhappy and its example in nlu.yml you will get the idea. What you enter as the input to the bot and then check the domain.yml for utter_happy and utter_sympathy. Example, you enter is all related to the old utterances and intent in short.

@lamxw2 please do change your topic category from Getting Started with Rasa to Rasa Open source. Thanks.

I’m afraid I don’t understand what you mean by change. Are you asking me to make changes to the text in intents like mood_great_or_neutral and mood_unhappy? I have done that for every intent in nlu.yml. I also rewrote the text for every utter action. My chatbot has been re-trained multiple times but the chatbot still acts like this.

I have changed the category, thanks.

@lamxw2 Share me the bot/user conversation screenshots, what output you are getting based on your story and the input. Thanks.

@lamxw2 See yourself because in your intent examples and utterance mention in the story, you are getting the response, which you not expected. So change the story.

@lamxw2 Just follow on story, check its intent and utterances in domain you will get it what I am saying and why I am saying.

The story works as intended if I use inputs that follow the story’s flow.

In domain.yml, I have these:

config:
  store_entities_as_slots: true
session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true
intents:
- greet:
    use_entities: true
- goodbye:
    use_entities: true
- affirm:
    use_entities: true
- deny:
    use_entities: true
- mood_great_or_neutral:
    use_entities: true
- mood_unhappy:
    use_entities: true
entities: []
slots:
  want_recipe:
    type: rasa.shared.core.slots.BooleanSlot
    initial_value: null
    auto_fill: true
    influence_conversation: true

And without showing the text for every utterance, I have these for actions:

actions:
- action_check_want_recipe
- utter_goodbye
- utter_greet
- utter_greet_follow_up
- utter_happy
- utter_provide_recipe
- utter_want_recipe
- utter_fallback
- utter_default
forms: {}
e2e_actions: []

I have also checked the stories against test_stories.yml and they pass. I’m not sure how I should be changing the story, as I don’t fully understand how stories work, and I don’t know what the expected outcome of stories is supposed to be.

@lamxw2 Share domain rest of the code the responses. Then, I will give you idea about story whilst taking on example.

responses:
  utter_greet:
  - text: Hey!
  - text: Hello!
  - text: Hi there!
  utter_greet_follow_up:
  - text: How are you?
  - text: How are you doing?
  - text: How are you today?
  utter_sympathy:
  - text: I'm sorry to hear that, I hope your day gets better.
  utter_happy:
  - text: I'm glad you're doing fine!
  - text: That's great!
  utter_goodbye:
  - text: Bye
  utter_iamabot:
  - text: I am a bot, powered by Rasa.
  utter_want_recipe:
  - text: Would you like a recipe?
  utter_ask_meal:
  - text: What did you have for your meal today?
  utter_ask_if_liked_meal:
  - text: Did you enjoy it?
  utter_nutrition_fact:
  - text: Here's today's nutritional fact for the day!
  utter_provide_recipe:
  - text: Recipe placeholder
  utter_fallback:
  - text: Sorry, I haven't learnt how to understand that.
  utter_ask_rephrase:
  - text: Sorry, I didn't understand that. Could you rephrase?
  utter_default:
  - text: Sorry, I haven't learnt how to handle that.

@lamxw2

Explanation for this story path:

- story: happy neutral path dont want recipe
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_greet_follow_up
  - intent: mood_great_or_neutral
  - action: utter_happy
  - action: utter_want_recipe
  - intent: deny
  - slot_was_set:
    - want_recipe: false

User: Hi Trigger: greet intent from nlu (check the example)
Bot: Hello! or Hi there! Trigger: utter_greet from domain
Bot: How are you? Trigger: utter_greet_follow_up from domain
User: I'm good Trigger: mood_greet_follow_up intent from nlu(check the example)
Bot: That's great! Trigger: utter_happy from domain
Bot: Would you like a recipe? Trigger: utter_want_recipe from domain
User: No  Trigger: deny intent based in nlu but you also set the use_entities: true but not entites:[]
searching for slot want_recipe but its false.

Please check the proper syntax and knowledge of Story, Rules, Intent, Entities and slots.

I hope now it make sense to you.

@lamxw2 Tip: I would encourage please read the documentation of Rasa and its syntax (what is used for what and why we used)

Thanks for the help. I had read the documentation and looked up tutorials multiple times but did not understand it, until I came across this post Does rasa strictly follow stories - #3 by souvikg10

If my understanding is correct, stories are just training data; stories are used to train the chatbot to make responses according to the user’s intent, according to the specific context. They are not used to strictly define what the conversation is supposed to be.

So the problem I am facing with my current chatbot is that my chatbot is trained too well on intent-response groups that were repeated multiple times, like this:

  - intent: greet
  - action: utter_greet
  - action: utter_greet_follow_up

intent greet with utter_greet is trained 4 times in stories.md, and more with data augmentation

  - intent: mood_great_or_neutral
  - action: utter_happy

intent mood_great_or_neutral with utter_happy is trained 2 times in stories.md, and more with data augmentation

  - intent: mood_unhappy
  - action: utter_sympathy

intent mood_unhappy with utter_sympathy is trained 2 times in stories.md, and more with data augmentation

  - intent: affirm
  - slot_was_set:
    - want_recipe: true
  - checkpoint: provide_recipe

intent affirrm with slot want_recipe and checkpoint provide_recipe is trained 2 times in stories.md, and more with data augmentation

  - intent: deny
  - slot_was_set:
    - want_recipe: false

And lastly, intent deny with slot want_recipe is trained 2 times in stories.md, and more with data augmentation.

Is my understanding correct?

@lamxw2 No comments. For story check this Stories. Then delete the story if it’s not relevant? Story is also depends on the right input you are giving to chatbot not what you like every time, see in above chat screen which you sent me.

  1. your bot is asking how are you doing? and you saying yes? what yes? It should be I am doing fine or I am sad, not well, I,e why you bot confuse he picking yes intent.

  2. Your bot is asking would you like a recipe and you saying bad? What bad? It should be Yes or yes please?

Stories are based on dialogue management, check it again.

@lamxw2 For this check this Domain

intents:
- greet:
    use_entities: true [What true huh?]

@lamxw2 check this also initial_value: null why we use and auto_fill:true

@lamxw2 The post you suggesting see the date its Oct’2018, its 2021, so much changed over the time and Rasa Planning Version 3.0, currently 2.7.1

Good Luck with your project!

@lamxw2 Hey! If this suggestion solve your query, can I request please close this thread with the solution for others.