Form Stories - Form action within another form story not working

Story generated using Interactive learning

  • greet
    • action_greet
    • utter_selection
  • orderline_details{“lineAttributes”:“delay”}
    • slot{“lineAttributes”:“delay”}
    • action_attribute_check
    • order_delay_form
    • form{“name”:“order_delay_form”}
    • slot{“requested_slot”:“orderNumber”}
  • deny
    • utter_ask_searchtype
  • searchby_po
    • action_poNumber_reset
    • slot{“poNumber”:null}
    • ponumber_form
    • form{“name”:“ponumber_form”}
    • slot{“requested_slot”:“poNumber”}
  • inform{“catalogNumber”:“S100151603”}
    • slot{“catalogNumber”:“S100151603”}
    • ponumber_form
    • slot{“poNumber”:“S100151603”}
    • slot{“orderNumber”:“3008492574”}
    • slot{“bomid”:“abdemx00c_04012001_00_00_M00”}
    • slot{“quotename”:“4951 - AHS MANAHAWKIN”}
    • form{“name”:null}
    • slot{“requested_slot”:null}
    • order_delay_form
    • form{“name”:“order_delay_form”}
    • slot{“orderNumber”:“3008492574”}
    • slot{“lineNumber”:null}
    • slot{“is_order_validated”:true}
    • slot{“lineAttributes”:null}
    • form{“name”:null}
    • slot{“requested_slot”:null}
    • utter_anythingelse
  • deny
    • utter_goodbye

When the user doesn’t know the input slot value(If the user deny(intent) the requested slot) I will ask for know value which initiate second form(which is also used for different situation/stories) to get the details and then I will come back again to the first form to complete it.

The problem is when the user deny the slot, the first form is getting predicted as next action and fails because of no slot value because of form action policy. It is not following the story that was trained. Then the next actions are getting predicted correctly and finally the first form is not getting executed due to it’s failure.

In this example first form - order_delay_form second form - ponumber_form

I can change the priority to solve this. But If I change the I might affect the other stories. Can someone tell me how to create this kind of story?. Is there any better way to do this? @akelad

Hey @gunalaksh, if you take a look at the second example here, you can see that in order to exit a form completely, you need to use the action_deactivate_form action. So the deny part of your story would look like:

  - form{“name”:“order_delay_form”}
  - slot{“requested_slot”:“orderNumber”}
* deny
  - action_deactivate_form
  - form{"name":null}
  - utter_ask_searchtype
  - searchby_po
  - action_poNumber_reset

But I have to continue with order_delay_form after second form is completed. If I deactivate it, I have to again activate this form to continue with the flow. This can only be achieved by providing stories similar to this.

The problem is I have different forms that needs to work in similar way. Do I have to provide stories for all the different forms to work in this way?

Yes, you have to re-activate it - but that’s what you’re doing in your story already:

* inform{“catalogNumber”:“S100151603”}
  - slot{“catalogNumber”:“S100151603”}
  - ponumber_form
  - slot{“poNumber”:“S100151603”}
  - slot{“orderNumber”:“3008492574”}
  - slot{“bomid”:“abdemx00c_04012001_00_00_M00”}
  - slot{“quotename”:“4951 - AHS MANAHAWKIN”}
  - form{“name”:null}
  - slot{“requested_slot”:null}
  - order_delay_form
  - form{“name”:“order_delay_form”}
  - slot{“orderNumber”:“3008492574”}
  - slot{“lineNumber”:null}
  - slot{“is_order_validated”:true}
  - slot{“lineAttributes”:null}
  - form{“name”:null}
  - slot{“requested_slot”:null}
  - utter_anythingelse

And yes you have to provide stories for your forms if you want this custom behaviour

Thanks @akelad

rawnakrawnghyah

2d

thank u so much can you please help me for solving other problem if u don’t mind here my nlu.md:

intent: create0

  • how I can [create] (create) a map
  • I want to [create] (create) a map
  • can you [create] (create) a card for me
  • [creation] (creation) card

intent: create

  • my name is [rawand] (name)
  • [ahmed ayadi] (name)
  • my name is [ilhem] (name)
  • [rawnak yahyaoui] ( name )
  • it is [iheb soltani] ( name)

intent: create1

  • my CIN number [00000000] (numCIN)
  • my CIN is [01224578] (numCIN)
  • CIN card [87995412] (numCIN)
  • [54661425] (numCIN)
  • [01245698] (numCIN)

intent: create2

  • my phone number is [+21600000000] (numT)
  • [+21692111111] (numT)
  • my number is [+2169012345] (numT)
  • [+21622222222] (numT) and here my domain.yml:

utter_create:

  • text: “give me u name”

utter_create1:

  • text: “give me ur your identity card number”

utter_create2:

  • text: “give me ur phone number”

utter_create2:

  • text: “your card has been created with successfully” utter_slot_values:

    • text: "voila votre coordonnée

         - name: {name}\n
      
         -numCin: {numCin}\n
      
         - numC: {numC}\n"
      

and this the stories

create0

  • create0
  • admission_Form

  • form{“name”:“admission_Form”}

  • form{“name”:null}

  • utter_slot_values and this my actions : AdmissionForm class (FormAction): from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker

from rasa_sdk.executor import CollectingDispatcher

from rasa_sdk.events import SlotSet

from rasa_sdk.forms import FormAction

import requests def name (self) -> Text: returns “admission_Form”

@staticmethod
def required_slots (tracker: Tracker) -> List [Dict [Text]]:
   
    print ("required_slots (tracker: Tracker)")
    return ["name", "numCin", "numC"]

def slot_mappings (self) -> Dict [Text, Any]:
    return {"name": self.from_entity (entity = "name",
                                    intention = ["create0",
                                            "create",
                                            "create1",
                                            "create2"]),
         "numCIN": self.from_entity (entity = "numCIN",
                                       intention = ["create0",
                                            "create",
                                            "create1",
                                            "create2"]),
            "numT": self.from_entity (entity = "numT",
                                    intention = ["create0",
                                            "create",
                                            "create1",
                                            "create2"])}

def submit (auto, dispatcher: CollectingDispatcher,
           tracker: Tracker,
           domain: Dict [Text, All],) -> List [Dict]:

      # utter submit template
    dispatcher.utter_message (template = "utter_creater2")
    return []

and when I do rasa run action, it gives me this result: 2020-08-24 17:59:48 INFO rasa_sdk.endpoint - Starting action endpoint server… Traceback (most recent call last): File “c:\users\acer\anaconda3\envs\word\lib\runpy.py”, line 193, in run_module_as_main “main”, mod_spec) File “c:\users\acer\anaconda3\envs\word\lib\runpy.py”, line 85, in run_code exec(code, run_globals) File "C:\Users\Acer\anaconda3\envs\word\Scripts\rasa.exe_main.py", line 7, in File "c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_main.py", line 92, in main cmdline_arguments.func(cmdline_arguments) File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa\cli\run.py”, line 52, in run_actions sdk.main_from_args(args) File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_sdk_main_.py”, line 21, in main_from_args args.auto_reload, File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_sdk\endpoint.py”, line 137, in run action_package_name, cors_origins=cors_origins, auto_reload=auto_reload File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_sdk\endpoint.py”, line 80, in create_app executor.register_package(action_package_name) File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_sdk\executor.py”, line 250, in register_package self._import_submodules(package) File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_sdk\executor.py”, line 206, in _import_submodules package = self._import_module(package) File “c:\users\acer\anaconda3\envs\word\lib\site-packages\rasa_sdk\executor.py”, line 227, in import_module module = importlib.import_module(name) File "c:\users\acer\anaconda3\envs\word\lib\importlib_init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “”, line 1006, in _gcd_import File “”, line 983, in _find_and_load File “”, line 967, in _find_and_load_unlocked File “”, line 677, in _load_unlocked File “”, line 728, in exec_module File “”, line 219, in _call_with_frames_removed File “C:\Users\Acer\Desktop\chahtbot word\actions.py”, line 46, in class AdmissionForm(FormAction): File “C:\Users\Acer\Desktop\chahtbot word\actions.py”, line 52, in AdmissionForm def required_slots(tracker:Tracker) -> List[Dict[Text]]: File “c:\users\acer\anaconda3\envs\word\lib\typing.py”, line 254, in inner return func(*args, **kwds) File “c:\users\acer\anaconda3\envs\word\lib\typing.py”, line 632, in getitem _check_generic(self, params) File “c:\users\acer\anaconda3\envs\word\lib\typing.py”, line 208, in _check_generic raise TypeError(f"Too {‘many’ if alen > elen else ‘few’} parameters for {cls};" TypeError: Too few parameters for typing.Dict; actual 1, expected 2.

I don’t know where exactly the problem…