How slot influence conversation

Hi, i am new with Rasa, so i am sorry if i will tell stupid things. I would ask how a entity that i put in a slot can influence my stories, in particular i use RegexEntityExtractor for extract an simple code of six digits that i received from user and i would like to follow different sories depending on value of this code.

My simple example:

nlu.yml

- regex: id_story examples: | - [\d{6}]
  • intent: stories_selector examples: |

stories.yml

  • story: story 000001 steps:

    • intent: stories_selector
    • slot_was_set:
      • id_story: 000001
    • action: utter_sory_000001
  • story: story 000002 steps:

    • intent: stories_selector
    • slot_was_set:
      • id_story: 000002
    • action: utter_sory_000002

and of course in domain.yml i have also defined the intent, entity, slot, responses and actions.

Thank for your time.

Hi @Dani966IT! Welcome to the forum :slight_smile:

This looks like a pretty good start to me! (nlu.yml has some wonky formatting, but I’m guessing this happened when you pasted it here). You probably want to change the example for the intent stories_selector as below. The only difference is that in the example below we have labeled [000001] as the id_story slot. This allows the model to generalize to other values that follow the id_story pattern of six digits.

- intent: stories_selector:

examples: |

-[000001](id_story)

Let me know if that works for you!

1 Like

@fkoerner i tried in this way, but he doesn’t work really well.

It set correctly slot, in all cases, but it predict correctly (with almost 70% confience) only if i send s000010 and s000002; if i send s000001 the confience is 22% and it call fallback action.

The question is, why if slot is set correctly? There is some wrong in config.yml (i use a config file found in a example).

Thanks for you patience.

nlu.yml

  • regex: id_story

    examples: |

    • [s\d{6}] (id_story)
  • intent: selected_story_000001

    examples: |

    • [s000001] (id_story)
  • intent: selected_story_000002

    examples: |

    • [s000002] (id_story)
  • intent: selected_story_000010

    examples: |

    • [s000010] (id_story)

stories.yml

  • story: story 000001

    steps:

    • intent: selected_story_000001
    • slot_was_set:
      • id_story: s000001
    • action: utter_sory_000001
  • story: story 000002

    steps:

    • intent: selected_story_000002
    • slot_was_set:
      • id_story: s000002
    • action: utter_sory_000002
  • story: story 000010

    steps:

    • intent: selected_story_000010
    • slot_was_set:
      • id_story: s000010
    • action: utter_sory_000010

domains.yml

entities:

  • id_story

slots:

   000001_step1:

       type: bool
       initial_value: false
        influence_conversation: true

config.yml

pipeline:

  • name: WhitespaceTokenizer

  • name: RegexFeaturizer

  • name: LexicalSyntacticFeaturizer

  • name: CountVectorsFeaturizer

  • name: CountVectorsFeaturizer

    analyzer: char_wb

    min_ngram: 1

    max_ngram: 4

  • name: DIETClassifier

    epochs: 100

  • name: EntitySynonymMapper

  • name: ResponseSelector

    epochs: 100

  • name: FallbackClassifier

    threshold: 0.3

    ambiguity_threshold: 0.1

policies:

  • name: MemoizationPolicy

  • name: TEDPolicy

    max_history: 5

    epochs: 100

  • name: RulePolicy

I think i founded a solution, one story that only set the slot, with a checkpoint at the end, and other three stories that start from checkpoint and with “slot_was_set” rasa could choose the right one.

I will update the post, it could be helpful for other new user like me.

1 Like

Hi @Dani966IT sorry for the slow response – but one other thing you can try is to use rules instead of stories. They are slightly “stricter” than the stories, but the drawback is that they can’t generalize like stories do. However, your use case looks like rules could work: your stories are quite short :slight_smile: