Form actions returns null after entering form

This is my story

# Balance_single_account
* greet
  - utter_greet
* balance_enquiry
  - action_fetch_profile
  - slot{"account_type" : "multi_acc"}
  - form{"name": "balance_enq_form"}
  - form{"name": null}

this is required response

  utter_ask_accLast4Digits:
  - text: "Multiple accounts found \n Enter last 4 digits of your account number" 

this is my balance form action

class BalanceForm(FormAction):
    """Custom form action to fill all slots required to find specific type
    of healthcare facilities in a certain city or zip code."""

    def name(self) -> Text:
        """Unique identifier of the form"""

        return "balance_enq_form"

    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""
        account_type = tracker.get_slot('account_type')
        if account_type =="multi_acc":
            return ["accLast4Digits"]
        else:
            return []

    # def slot_mappings(self) -> Dict[Text, Any]:
    #     return {"facility_type": self.from_entity(entity="facility_type",
    #                                               intent=["inform",
    #                                                       "search_provider"]),
    #             "location": self.from_entity(entity="location",
    #                                          intent=["inform",
    #                                                  "search_provider"])}

    def submit(self,
               dispatcher: CollectingDispatcher,
               tracker: Tracker,
               domain: Dict[Text, Any]
               ) -> List[Dict]:
        """Once required slots are filled, print buttons for found facilities"""

        accLast4Digits = tracker.get_slot('accLast4Digits')
        [FinalAccountNumber,
             FinalCIFNumber] = accnum_by_mobile(mobile_number, False,
                                                accLast4Digits)
        if FinalAccountNumber == '':
            dispatcher.utter_message("Incorrect account number.\\n \\nPlease enter the last 4 digit of your account for verification. \\n \\n")
        else:
            balance = balance_api_call(FinalAccountNumber)
            dispatcher.utter_message(f'''Your avaliable balance is {balance}''')
        return []

when i do this request after greeting message to this rest url : http://XXXXXX:100/webhooks/rest/webhook {“message”:“bal”,“sender”:“917587XXX023”}

response is

[]

expected : 
    {
    "text": "Multiple accounts found \n Enter last 4 digits of your account number",
    "sender_id":"917587XXX023"
    }

i could get this without form actions… facing issue when using forms

that mobile number is having multi accounts … that is already known but still i am getting null respose from the balance enquiry form

Elaborating what is the expected to happen

As that mobile number is having multiple accounts and i havent set an slot map in my BalanceForm(FormAction) code … so the only unfilled slot is accLast4Digits

so for this slot to be filled accorfing to docs i have written a template response named utter_ask_accLast4Digits in the domain file… i expect to utter Multiple accounts found \n Enter last 4 digits of your account number this message and user fills that slot by entering and action goes to submit part as all the slots are filled… But i am not getting any message related to utter_ask_accLast4Digits this.

what would be possible issue ?

hi @pvbhanuteja!

Could you change your story to this:

# Balance_single_account
* greet
  - utter_greet
* balance_enquiry
  - action_fetch_profile
  - slot{"account_type" : "multi_acc"}
  - balance_enq_form
  - form{"name": "balance_enq_form"}
  - form{"name": null}

and retrain and test again?

1 Like

hi @saurabh-m523 thanks.

now i keep on getting this in console log

any idea ?

Tried to set non existent slot 'requested_slot'. Make sure you added all your slots to your domain file.

There are only two slots i use… which i have mentioned already domains file as above

Add an unfeaturized requested_slot to your domain. This slot is used by the FormAction.

2 Likes

@saurabh-m523 hanks a lot… i was thinking i was missing a slot… didn’t know its a inbuilt slot

Hi @saurabh-m523 one last doubt to end this convo…

Failed to extract slot accLast4Digits with action balance_enq_form

i am getting that error because i missed slot mappings in form actions ?

I thought slots would get carried forward in entire session also even in formactions

I don’t understand what you mean by:

I thought slots would get carried forward in entire session also even in formactions

If you are not implementing slot_mappings then the slot accLast4Digits will only be filled if the nlu extracts an entity of the same name from the user’s message. Anyways, I think its always a good idea to implement the slot_mappings method.

I haven’t sent any entity for that … but as far as from my understanding according to docs… If I set a utter_ask_accLast4Digits (utter_ask_slotname) in the domain file … Then when the flow comes to form action … if the required slot (accLast4Digits) is not already set then it will utter (utter_ask_slotname) and based on user input message it will automatically set the slot with out any spot mappings … Am I wrong ?

It will not automatically fill the slot from the user’s message unless you implement the slot_mappings method. I think you misunderstood it. Implement the slot_mappings like this:

    def slot_mappings(self) -> 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"""

        return {
            'accLast4Digits': self.from_text(),
        }

if you want the slot accLast4Digits to be filled with text input from the user.

1 Like

Hi @saurabh-m523

Thanks a ton. Saved a lot of time of mine today