Dynamic Slot mapping - change default mapping for dynamic form

Hi, i am using form action to achieve the use case.

for dynamic slot mapping:
depending on my doc_type entity value I am requesting for dynamic slot standard_doc_type that needs to be updated by an entity named “mention” or from latest text.

  required_slots = slots_mapped_in_domain
  if tracker.slots.get("doc_type") in ["STANDARD"]:
           required_slots = ["standard_doc_type"]+ slots_mapped_in_domain

However i get Failed to extract requested slot ‘standard_doc_type’ precisely because the default mapping if no mapping provided in domain is by the entity of same name. However my requirement is entirely different. Is there a way to provide different mapping for Dynamic slots?

As per documentation:

async def extract_standard_doc_type(

        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict

    ) -> Dict[Text, Any]:

        application = next(tracker.get_latest_entity_values("application"), None)

        user_text = tracker.latest_message.get("text")

        LOG.info(f"value of user action extracted : {user_text}")

        LOG.info(f"latest application entity extracted : {application}")

        if not application and application == "Application_name":

            return {"standard_doc_type": application}

        else:

            user_text = tracker.latest_message.get("text")

            LOG.info(f"value of user action extracted : {user_text}")

            return {"standard_doc_type": user_text}

forms: document_form:

    doc_type:

      - type: from_entity

        entity: doc_type

      - type: from_entity

        entity: mention

        intent: inform

2021-08-11 21:57:43 DEBUG    rasa.core.actions.forms  - Trying to extract requested slot 'standard_doc_type' ...
2021-08-11 21:57:43 DEBUG    rasa.core.actions.forms  - Got mapping '{'type': 'from_entity', 'entity': 'standard_doc_type', 'intent': [], 'not_intent': [], 'role': None, 'group': None}'
2021-08-11 21:57:43 DEBUG    rasa.core.actions.forms  - Failed to extract requested slot 'standard_doc_type'

@SamS

@fkoerner

if not application and application == "Application_name":

What is this line meant to be doing? Both sides of the and condition can’t be true at the same time, so the condition as a whole won’t be true.

Can you confirm that:

  1. extract_standard_doc_type is part of the extended FormValidationAction class?
  2. You are not defining standard_doc_type as part of your form? (it looks like you aren’t, but maybe this is just a snippet)
  3. You’ve overridden required_slots from the extended FormValidationAction class? (again, looks like you aren’t, but maybe this is just a snippet)

If you can confirm the above, can you share the entire FormValidationAction code, as well as how you’ve defined relevant entities and slots?

if not application and application == “Application_name”:

What is this line meant to be doing? Both sides of the and condition can’t be true at the same time, so the condition as a whole won’t be true. - 1st part confirms if there there is a value in application variable(to eliminate exception if application is None and second part checks the condition, but that’s not the problem . Problem is extraction of user text.

  1. Yes
  2. Yes, I am not
  3. Yes

I not sure if i can share the entire Form code but the entities used are

entities:

  • document_type

slots:
document_type:
type: text
influence_conversation: false

standard_doc_type:
type: text
influence_conversation: false

1st part confirms if there is a value in application variable

Then shouldn’t that be if application?

I’m not sure what else could be going wrong. I wasn’t able to replicate this with my own toy bot with dynamically added slots. I don’t know why you are seeing 2021-08-11 21:57:43 DEBUG rasa.core.actions.forms - Got mapping..., this seems to be related to the issue.

Are you seeing these log messages?

LOG.info(f"value of user action extracted : {user_text}")
LOG.info(f"latest application entity extracted : {application}")

Have you specified auto_fill: false?