Trying to exit a form loop if a specific intent is detected

I am trying to exit a form loop if a specific intent is responded to the first question. It’s an edge case and if the first response is a particular one, I want to deactivate the form and take a different path.

According to all the docs, I’ve done it correctly.

It correct detected the edge case intent I am looking for, but then continues with wanting to execute the form and doesn’t go to my alternative path.

  - active_loop: seller_form # the form 
  - slot_was_set:
    - requested_slot: seller_time_frame #the first questions
  - intent: seller_already_listed #user response is an edge case that I want to detect
  - action: action_deactivate_loop # deactivate the current loop
  - active_loop: null # no current loops running.
  - slot_was_set: 
    - requested_slot: null #no more questions
  - action: utter_ask_wants_free_valuation #ulterior action path based on detecting seller_already_listed
  - intent: affirm # cont..
  - action: completed_happy_goodbye  # cont..

As I mentioned… interactive sessions shows that it detected the correct intent “seller_already_listed” but continue to loop through seller form.

Any ideas? It’s driving me bonkers!

Thanks! John

my config is

language: en

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
    retrieval_intent: faq
  - name: ResponseSelector
    epochs: 100
    retrieval_intent: chitchat
  - name: ResponseSelector
    epochs: 100
    retrieval_intent: out_of_scope
  - name: FallbackClassifier
    threshold: 0.2
    ambiguity_threshold: 0.001
policies:
  - name: MemoizationPolicy
  - name: TEDPolicy
    max_history: 10
    epochs: 100
  - name: RulePolicy
    core_fallback_threshold: 0.2
    core_fallback_action_name: "donna_fallback_action"


I also tried adding a rule. seems to completely ignore it!

- rule: seller_already_listed
  steps:
  - intent: seller_already_listed
  - action: action_deactivate_loop
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  wait_for_user_input: false

Hello! This is an example of how I did it:

In the stories: (the out_of_scope intent is detected when the user gives their usernames - don’t mind it)

- story: User fills form_log_in and stops
  steps:
  - intent: log_in
  - action: form_log_in
  - active_loop: form_log_in
  - or:
    - intent: stop
    - intent: deny
  - action: action_deactivate_loop
  - active_loop: null
  - action: utter_okay

- story: (Conversation) User fills login form and stops when asked for username
  steps:
  - intent: log_in
  - action: form_log_in
  - active_loop: form_log_in
  - slot_was_set:
    - requested_slot: username
  - intent: stop
  - action: action_deactivate_loop
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  - action: utter_okay

- story: (Conversation) User fills login form and stops when asked for password
  steps:
  - intent: log_in
  - action: form_log_in
  - active_loop: form_log_in
  - slot_was_set:
    - requested_slot: username
  - intent: out_of_scope
  - action: form_log_in
  - slot_was_set:
    - username: chris
  - slot_was_set:
    - requested_slot: password
  - intent: stop
  - action: action_deactivate_loop
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  - action: utter_okay

And for safe measure, I added “not_intent: stop” in the slot mappings in the Domain:

forms:
  form_log_in:
    required_slots:
      username:
      - intent_name: None
        not_intent: stop
        type: from_text
      password:
      - intent_name: None
        not_intent: stop
        type: from_text

The only material difference I can see with your config and mine is that I have the requested slot directives (i also added in some or: intents for good measure)

I’ve removed the now and the stories read as follows:

  - intent: affirm
  - action: seller_form
  - active_loop: seller_form
  - or:
    - intent: seller_already_listed
    - intent: deny+seller_already_listed
    - intent: inform+seller_already_listed
  - action: action_deactivate_loop
  - active_loop: null
  - action: utter_ask_wants_free_valuation
  - intent: affirm
  - action: completed_happy_goodbye

But its always forcing the next question in the seller form - even when it detects the seller_already_listed intent.

In the interactive sessions - when I correct the “seller_form” action and tell it to deactivate_loop instead, it works well from there… so it feels like thats the bit that isn’t being picked up and if it could figure out how to deactivate the loop it’d all work fine…

thanks for any assistance… its a frustrating one!

1 Like

Hmm this is weird. Have you tried setting the not_intent entry in the slot mappings?

I havent - but its detecting the right intent anyhow so adding a “not intent” should be a mute point right? I’ll try it in my next build and see how that goes.

I did a small unit test and it appears to work after removing this rule

  - rule: seller_already_listed always deactivates seller form and asks if they want a free valuation
    condition:
      - active_loop: seller_form   # this form must be active

    steps:
      - action: seller_already_listed
      - active_loop: null         # the form is no longer active because it has been filled
      - slot_was_set:
          - requested_slot: null
      - action: utter_ask_wants_free_valuation

doing a full rebuild now - fingers crossed - thanks for your help (regardless of outcome!)

1 Like

seems weird freeing up the rule and making it less restrictive actually enforced the rule! but that’s ML for ya :wink:

1 Like

Ahaha indeed.

Glad you solved it. Please mark your answer as solution :slight_smile: