Forms not working on failure

I was using the form to fill out different slots. The problem i am facing is that when an intent isn’t successfully recognized, the entity is not extracted and thus, the slot is not filled. I read in the docs that if a slot is not filled, the user asked to fill the slot again. For example, location is a slot, if location is not extracted from the intent, it fails to ask again using utter_ask_location. My slot mapping function is as follows:

“location”: [self.from_entity(entity=“location”,intent=[“inform”,])]

The error I then get is failed to extract slot with “location_form”. Can somebody help me out?

could you please post your actions.py?

class EmergencyForm(FormAction): “”“Example of a custom form action”""

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

    return "emergency_form"

@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""

    return ["location","etype","people"]

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 {
        "location": [self.from_entity(entity="location",intent=["inform",])],
        "people": [self.from_entity(entity="inform",intent="inform")],
        "etype": [self.from_entity(entity="etype",intent="inform")]
    }

Hi @taimoor-ahmed!

I don’t see any submit method in this. You should be getting a NotImplementedError. Have you implemented this method?

@saurabh-m523 I mistakenly did not copy the whole file:

from typing import Dict, Text, Any, List, Union, Optional from datetime import datetime from rasa_sdk import Tracker from rasa_sdk.executor import CollectingDispatcher from rasa_sdk.forms import FormAction

class EmergencyForm(FormAction): “”“Example of a custom form action”""

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

    return "emergency_form"

@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""

    return ["location","etype","people"]

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 {
        "location": [self.from_entity(entity="location",intent=["inform",])],
        "people": [self.from_entity(entity="inform",intent="inform")],
        "etype": [self.from_entity(entity="etype",intent="inform")]
    }

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"""
    records = open('slots.txt', 'a+')
    records.write('\nEmergency Alert: {}\n'.format(datetime.now()))
    slots_list = ["Etype: "+str(tracker.get_slot('etype')),"people: "+str(tracker.get_slot('people')),"Location: "+str(tracker.get_slot('location'))]
    records.write('\n'.join(slots_list))
    records.close() 
    dispatcher.utter_message(template="utter_confirmation")
    dispatcher.utter_message(template="utter_submit")
    return []

Hi, the same is happening for me. Instead of again asking the SLOT value, it is showing error message and sometimes even the correct value is not recognised and fall back message is given. It was working fine till a moment and then suddenly it starts behaving weird. @RASA team any clue? I have posted the same as a TOPIC on the forum but till now no help!. Form Slots Not Working

Now feeling little bit demotivated as I’m trying to get this thing work from past 3 weeks!.