Bot is able to recognise slot values from the sentence, but not considering them

For example, input sentence - " I want to invest money in the bank" , where “invest” is a slot value for “purpose”. When I gave such a sentence, bot responds with:

*bank{“purpose”:“invest”}

  • bank_form
  • form[“name”: “complaint_form”]

but also requestin slot again,

  • slot{“requested_slot”:“purpose”}

Even though bot recognizes the slot value “invest” in the sentence, it fails to consider it and requesting the value again. I added stories for such cases, still not working. Help me here.

Hi @ManiNuthi, can you please share more details? What kind of Rasa version are you using? Can you also please paste some of the stories you mentioned and also share the logs of a conversation with the bot (e.g. rasa shell --debug). Thanks!

Rasa version - Rasa 1.10.8

Stories looks something like :

* bank{"purpose":"invest"}
    - utter_raise_branch
    - slot{"purpose":"invest"}
    - bank_form
    - form{"name":"bank_form"}
    - action_reset
    - utter_continue

logs of rasa shell --debug:

2020-08-10 15:36:43 DEBUG    rasa.core.processor  - Action 'bank_form' ended with events '[BotUttered('దయచేసి ఇష్టపడే ఆహార వనరును ఎంచుకోండి', {"elements": null, "quick_replies": null, "buttons": [{"title": "\u0c06\u0c28\u0c4d\u200c\u0c32\u0c48\u0c28\u0c4d \u0c2c\u0c41\u0c15\u0c3f\u0c02\u0c17\u0c4d"}, {"title": "\u0c2a\u0c4d\u0c2f\u0c3e\u0c02\u0c1f\u0c4d\u0c30\u0c40 \u0c15\u0c3e\u0c30\u0c41"}, {"title": "\u0c38\u0c4d\u0c1f\u0c47\u0c37\u0c28\u0c4d \u0c35\u0c26\u0c4d\u0c26"}], "attachment": null, "image": null, "custom": null}, {}, 1597054003.2855725), <rasa.core.events.Form object at 0x7fb9aa438dd8>, <rasa.core.events.SlotSet object at 0x7fb9aa438c18>]'.
2020-08-10 15:36:43 DEBUG    rasa.core.processor  - Current slot values: 
	Code: None
	CompDesc: None
	CompEntity: None
	CompIssue: None
	CompIssueDetail: None
	ContactNo: None
	Recipient: None
	purpose: None
	TransType: None
	Support: None
	SeqNo: None
	Time: None
	Paper: None
	Name: None
	due: None
	transact: None
	date: None
	requested_slot: purpose
	required_slot: None
2020-08-10 15:36:43 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, {}, {'intent_food': 1.0, 'entity_FoodSource': 1.0, 'prev_action_listen': 1.0}, {'prev_utter_raise_branch': 1.0, 'intent_bank': 1.0, 'entity_purpose': 1.0}]
2020-08-10 15:36:43 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2020-08-10 15:36:43 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'service'.
2020-08-10 15:36:43 DEBUG    rasa.core.policies.form_policy  - There is an active form 'bank_form'
2020-08-10 15:36:43 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_3_FormPolicy
2020-08-10 15:36:43 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2020-08-10 15:36:43 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'.
2020-08-10 15:36:43 DEBUG    rasa.core.lock_store  - Deleted lock for conversation '41ce96b349104eb699b9cf4f1ee32806'.

From the logs I cannot recognise if the entity was actually detected or not. Did you pasted the full log? E.g. for the whole conversation? Also how does your form action look like?

in the logs it doesnt, but the story displayed (in the right side bar in the rasa interface) representing the flow of conversation displays something like this:

*bank{“purpose”:“invest”}

  • bank_form
  • form[“name”: “complaint_form”]
  • slot{“requested_slot”:“purpose”}

doesn’t that mean entity was detected.

Yes, * bank{“purpose”:“invest”} means the intent bank and the entity purpose was detected. However, you also need to define NLU data with examples containing the entity purpose. Otherwise the assistant will not be able to detect the entity. Did you do that?

Yes, there are a lot of examples in nlu for this case.

Screenshot from 2020-08-11 17-09-03

Ok. I guess I need some more information before I can actually help you. Can you please share your form action and your domain file? Thanks.

form action :

class BankForm(FormAction):

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

        return "bank_form"

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

        return [
            "purpose",
            "Seating"]

    def validate_purpose(
            self,
            value: Text,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> Dict[Text, Any]:
        """Validate purpose slot """

        if value or int(value):
            opt = purposeOptions(value)
            value = opt
            print(value)
            if value == "invest":
                return {
                "purpose": value,
                "Seating": "z0-00"}
            elif value == "transact":
                return {"purpose": value}
        else:
            dispatcher.utter_message(template="utter_wrong_purpose")

        return {"purpose": None}

    def validate_Seating(
            self,
            value: Text,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> Dict[Text, Any]:
        """Validate Seating slot"""

        if value:
            return {"Seating": str(value)}
        else:
            dispatcher.utter_message(template="utter_wrong_Seating")
        return {"Seating": None}

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        """A dictionary to map required slots to
            - an extracted entity - from_entity
            - intent: value pairs
            - a whole message - from_text
            or a list of them, where a first match will be picked"""

        return {
            "purpose": [self.from_entity(entity="purpose"),self.from_entity(entity="Option")],
            "Seating": self.from_entity(entity="Seating")}

    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"""
        source = tracker.get_slot("purpose")

        if source == "invest":
            dispatcher.utter_message(
                "your request is submitted for investment ")

        else:
            dispatcher.utter_message(
                "your request is submitted for transaction")

        return_slots = []
        for slot in [
                "purpose", "Seating"]:
            if slot != "foo":
                return_slots.append(SlotSet(slot, None))

        return return_slots

purpose options :

def purposeOptions(option):
    print(option)
    print (type(option))
    if option in ["invest","Invest","Investment","1",1]:
        value ="invest"
        return value
    elif option in ["transact","transaction","2",2]:
        value ="transact"
        return value

domain file :

session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true
intents:
- greet
- goodbye
- affirm
- deny
- inform
- transact
- complaint
- loan
- bot_challenge
- reset:
    triggers: action_reset
entities:
- purpose
- CompIssue
- Seating
- CompIssueDetail
- Option
- CompDesc
slots:
  ClassCode:
    type: unfeaturized
    auto_fill: false
  CompDesc:
    type: unfeaturized
    auto_fill: false
  CompEntity:
    type: unfeaturized
    auto_fill: false
  CompIssue:
    type: unfeaturized
    auto_fill: false
  CompIssueDetail:
    type: unfeaturized
    auto_fill: false
  ContactNo:
    type: unfeaturized
    auto_fill: false
  IssueSource:
    type: unfeaturized
    auto_fill: false
  purpose:
    type: unfeaturized
    auto_fill: false
  date:
    type: unfeaturized
    auto_fill: false
  requested_slot:
    type: unfeaturized
  required_slot:
    type: unfeaturized
responses:
  utter_ask_date:
  - text: Please enter date(dd-mm-yyyy)
  - text: provide date information(dd-mm-yyyy)
  utter_wrong_date:
  - text: invalid date format, it should be (dd-mm-yyyy)
  - text: entered date format is invalid, it should be (dd-mm-yyyy)
  utter_ask_CompEntity:
  - text: Please enter the {CompIssue}
  utter_wrong_CompEntity:
  - text: Enter valid {CompIssue}
  utter_ask_CompIssueDetail:
  - text: Please select the Issue Domain
    buttons:
    - title: Timing
    - title: Staff
    - title: Other
  utter_wrong_CompIssueDetail:
  - text: provide valid complaint details
  utter_ask_ContactNo:
  - text: Enter a valid Contact Number
  utter_ask_purpose:
  - text: Enter your purpose
  utter_wrong_purpose:
  - text: Please provide valid details
  utter_wrong_ContactNo:
  - text: Enter a valid Phone number
  utter_ask_CompDesc:
  - text: Please describe your complaint.
  utter_wrong_CompDesc:
  - text: Enter valid complaint.
  utter_ask_IssueSource:
  - text: Please select your Issue source
    buttons:
    - title: draw 
    - title: invest
    - title: others
  utter_wrong_IssueSource:
  - text: Please provide valid details
  utter_iamabot:
  - text: I'm Sevak. A bot powered by NLP.
  - text: I.m Sevak, your own chatbot.
  utter_continue:
  - text: Please state your query.
  utter_complaint_reg:
  - text: Thank you for your feedback.
  - text: Thanks, your complaint has been registered.
  - text: We’re happy to take your feedback, thanks for your complaint.
  - text: We have registered your complaint, thanks for your suggestion.
  - text: We are happy to get your valuable feedback
  utter_helpline:
  - text: You can also call the toll free helpline numbers 1800-111-139 and 1800-111-321
      for any bank related queries.
  utter_raise_issue:
  - text: Oh! I really apologize for your inconvenience. Please provide details for
      processing.
  - text: I’m sorry for your inconvenience. Please provide details for processing.
  - text: We’re really sorry for your inconvenience. Please provide details for processing.
  - text: Sorry for the inconvenience caused by us. Please provide details for processing.
  - text: Sir, Sorry for dissatisfaction caused by us. Please provide details for
      processing.
  utter_greet:
  - text: Hello! How can I help you?
  - text: Hello, please tell me how may I help you today?
  - text: Hello, how can I assist you?
  - text: Greetings, I’m here to help you. What’s your query?
  - text: How can i help you Sir/Mam?
  utter_goodbye:
  - text: Happy to help you, See you later.
  - text: Goodbye. Comeback for any issue anytime.
  - text: Bye. Have a nice day.
  - text: Goodbye, See you later.

actions:
- utter_ask_TransactNo
- utter_wrong_TransactNo
- utter_ask_date
- utter_wrong_date
- utter_ask_CompIssue
- utter_wrong_CompIssue
- utter_ask_CompEntity
- utter_wrong_CompEntity
- utter_ask_CompIssueDetail
- utter_wrong_CompIssueDetail
- utter_ask_ContactNo
- utter_wrong_ContactNo
- utter_ask_CompDesc
- utter_wrong_CompDesc
- utter_ask_IssueSource
- utter_wrong_IssueSource
- utter_ask_Seating
- utter_ask_purpose
- utter_greet
- utter_goodbye
- utter_iamabot
- utter_continue
- utter_complaint_reg
- utter_helpline
- action_reset
- utter_raise_issue
forms:
- bank_form
- staff_form
- guest_form