# RASA Forms not predicting correctly

**URL:** <https://forum.rasa.com/t/rasa-forms-not-predicting-correctly/15434>\
**Category:** Rasa Open Source\
**Created:** [September 9, 2019, 4:40pm UTC](https://forum.rasa.com/t/rasa-forms-not-predicting-correctly/15434 "2019-09-09T16:40:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![surya1994](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@surya1994](https://forum.rasa.com/u/surya1994)\
**Post date:** [September 9, 2019, 4:40pm UTC](https://forum.rasa.com/t/rasa-forms-not-predicting-correctly/15434/1 "2019-09-09T16:40:51Z")

</div>

Hi

I created story using forms but when all the slots gets set and form(user\_easypay1\_form) get deactivated instead of going to next action(action\_due\_amount\_check) it goes to fallback action as nlu threshold is less than nlu threshold i mentioned in config file but here i defined slots as free text (ie it should not depend on nlu data) in actions.py but it still checks nlu when ever i enter values for slots.Can you please let me know how to solve this issue

Below is a story and actions.py

## make\_a\_payment\_easy\_pay

- user\_payment\_message

- action\_rasa\_properties
- slot{“owcs\_url”:"/u01/app/anaconda3"}
- slot{“common\_url”:"/u01/app/anaconda3"}
- action\_check\_user\_login\_or\_not
- slot{“login\_check\_user” : 0}
- action\_get\_payment\_again\_slot\_validate
- slot{“get\_payment\_again”:0}
- utter\_message\_login\_credentials
- utter\_yes\_no\_buttons

- deny

- user\_easypay1\_form
- form{“name”: “user\_easypay1\_form”}
- slot{“err\_reason”:“noerror”}
- slot{“billingentityname”:“VAEP TESTER”}
- slot{“dueamount”:“123”}
- slot{“groupsyskey”:“15565”}
- slot{“billingentitysyskey”:“37366”}
- slot{“brandCode”:“VIRGINIA”}
- slot{“systemcode”:“STAR”}
- slot{“businessunitcode”:“SMGRP”}
- slot{“lockboxnumber”:“11792”}
- form{“name”:“null”}
- action\_due\_amount\_check
- slot{“due\_amount\_check”:“pass”}
- action\_due\_amount\_check\_validated
- slot{“due\_amount\_flag”: 0}
- utter\_payment\_message
- utter\_yes\_no\_buttons

- affirm

- utter\_make\_a\_payment\_select\_options
- utter\_make\_a\_payment\_select\_buttons

- paymentselectoption\_complete

- utter\_type\_payment
- utter\_type\_payment\_buttons

- paymenttype{“accounttype”:“Checking”}

- user\_easypay2\_form
- form{“name”: “user\_easypay2\_form”}
- form{“name”:“null”}
- utter\_receive\_payment\_mail
- utter\_yes\_no\_buttons

- affirm

- utter\_email\_message

- user\_email{“[Email\_address":"nara@yah.com](mailto:Email_address%22:%22nara@yah.com)”}

- utter\_review\_payment\_details
- action\_payment\_details\_review
- utter\_yes\_no\_buttons

- affirm

- action\_bank\_payment\_easypay\_success
- action\_due\_amount\_check
- slot{“due\_amount\_check”:“pass”}
- action\_due\_amount\_check\_validated
- slot{“due\_amount\_flag”: 0}
- utter\_ask\_rating
- utter\_rating\_buttons

- user\_rating{“rate”:“poor”}

- utter\_thanks
- action\_user\_restart

actions.py: class UserLoginForm1(FormAction): “”“Example of a custom form action”""

```
def name(self):
    """Unique identifier of the form"""

    return "user_easypay1_form"

@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""
    print(" *************required slots form has to fill started****************")
    return ["group_num","tax_id"]

def slot_mappings(self):
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
  """A dictionary to map required slots to
    - an extracted entity
    - intent: value pairs
    - a whole message
      or a list of them, where a first match will be picked"""
  print(" *****slot mappings*******")
  return {"group_num": [self.from_text()],
        "tax_id": [self.from_text()]}

def submit(self,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> List[Dict]:
    """Define what the form has to do after all required slots are filled"""
    print(" ******Submitted button activated**********")
    print("Enter into validation Part of api")
    # utter submit template
    group_num= tracker.get_slot('group_num')
    tax_id= tracker.get_slot('tax_id')
    print("Valid")
    API_ENDPOINT="some link"
    params={"values"}
    print("params",params)
    print("API_ENDPOINT",API_ENDPOINT)
    try:		
      response = json.loads(requests.post(url=API_ENDPOINT,json=params).text)
      print(" **************response for make a payment easy pay**************",response)
      if(response["billingDetailsList"] is not None):
        print("you have successfully loaded")
        billingentityname=response["billingDetailsList"][0]["billingEntityName"]
        dueAmount=response["billingDetailsList"][0]["invoiceDetails"][0]["amount"]
        groupsyskey=response["billingDetailsList"][0]["groupSysKey"]
        billingentitysyskey=response["billingDetailsList"][0]["billingEntitySysKey"]
        brandCode=response["billingDetailsList"][0]["brandCode"]
        systemcode=response["billingDetailsList"][0]["systemCode"]
        businessunitcode=response["billingDetailsList"][0]["businessUnitCode"]
        lockboxnumber=response["billingDetailsList"][0]["lockBoxNumber"]
        print("!!!!!!!!!!Slots field set!!!!!!!!")
        print("billingentityname : ",billingentityname)
        print("dueAmount : ",dueAmount)
        print("groupsyskey : ",groupsyskey)
        print("billingEntitySysKey : ",billingentitysyskey)
        print("brandCode : ",brandCode)
        print("systemcode : ",systemcode)
        print("businessunitcode : ",businessunitcode)
        print("lockboxnumber : ",lockboxnumber)
        dueAmount = str(dueAmount)
        outMessage="The total outstanding amount for your "+group_num+"-"+billingentityname+" is "+"$"+dueAmount+"." 
        print("outMessage",outMessage)
        dispatcher.utter_message(outMessage)
        return[SlotSet("err_reason","no error"),SlotSet("billingentityname",billingentityname),SlotSet("dueamount",dueAmount),SlotSet("groupsyskey",groupsyskey),SlotSet("billingentitysyskey",billingentitysyskey),SlotSet("brandCode",brandCode),SlotSet("systemcode",systemcode),SlotSet("businessunitcode",businessunitcode),SlotSet("lockboxnumber",lockboxnumber)]
      elif(response["billingDetailsList"] is None):
         dispatcher.utter_template("utter_ask_other",tracker)
         return[UserUtteranceReverted()]
    except:
         print("Error",sys.exc_info()[0])
         outMessage="System is down please try again later"
         dispatcher.utter_message(outMessage)
         return[SlotSet("err_reason" ,"bill empty")]

```

config.yml:

# Configuration for Rasa NLU.

# [Components](https://rasa.com/docs/rasa/nlu/components/)

language: en pipeline: supervised\_embeddings

# Configuration for Rasa Core.

# [Policies](https://rasa.com/docs/rasa/core/policies/)

policies:

- name: MemoizationPolicy max\_history: 37
- name: KerasPolicy max\_history: 37
- name: MappingPolicy
- name: FormPolicy
- name: TwoStageFallbackPolicy nlu\_threshold: 0.5 core\_threshold: 0.5 fallback\_nlu\_action\_name: “action\_custom\_fallback” fallback\_core\_action\_name: “action\_custom\_fallback” deny\_suggestion\_intent\_name: “out\_of\_scope”

Also please let me know how can i revert back and ask user again if user enter wrong values for slots in same form action

---

<div class="post-metadata">

**Author:** ![surya1994](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@surya1994](https://forum.rasa.com/u/surya1994)\
**Post date:** [September 12, 2019, 11:36am UTC](https://forum.rasa.com/t/rasa-forms-not-predicting-correctly/15434/2 "2019-09-12T11:36:01Z")

</div>

Can any one please reply

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [September 13, 2019, 8:00am UTC](https://forum.rasa.com/t/rasa-forms-not-predicting-correctly/15434/3 "2019-09-13T08:00:42Z")

</div>

If the form is finished, then nlu thresholds are important, so I’d recommend to add nlu data to improve intent classification
