# Dynamic Slot mapping - change default mapping for dynamic form

**URL:** <https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783>\
**Category:** Rasa Open Source\
**Created:** [August 12, 2021, 2:16am UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783 "2021-08-12T02:16:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhi\_bh\_nlp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/abhi_bh_nlp/32/5905_2.png) [@abhi\_bh\_nlp](https://forum.rasa.com/u/abhi_bh_nlp)\
**Post date:** [August 12, 2021, 2:16am UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783/1 "2021-08-12T02:16:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abhi\_bh\_nlp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/abhi_bh_nlp/32/5905_2.png) [@abhi\_bh\_nlp](https://forum.rasa.com/u/abhi_bh_nlp)\
**Post date:** [August 17, 2021, 8:21am UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783/2 "2021-08-17T08:21:22Z")

</div>

@fkoerner

---

<div class="post-metadata">

**Author:** ![fkoerner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fkoerner/32/11784_2.png) [@fkoerner](https://forum.rasa.com/u/fkoerner)\
**Post date:** [August 18, 2021, 8:19am UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783/3 "2021-08-18T08:19:39Z")

</div>

> `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?

---

<div class="post-metadata">

**Author:** ![abhi\_bh\_nlp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/abhi_bh_nlp/32/5905_2.png) [@abhi\_bh\_nlp](https://forum.rasa.com/u/abhi_bh_nlp)\
**Post date:** [August 18, 2021, 9:03pm UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783/4 "2021-08-18T21:03:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fkoerner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fkoerner/32/11784_2.png) [@fkoerner](https://forum.rasa.com/u/fkoerner)\
**Post date:** [August 19, 2021, 7:43am UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783/5 "2021-08-19T07:43:51Z")

</div>

> 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}")

```

---

<div class="post-metadata">

**Author:** ![fkoerner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fkoerner/32/11784_2.png) [@fkoerner](https://forum.rasa.com/u/fkoerner)\
**Post date:** [August 19, 2021, 11:02am UTC](https://forum.rasa.com/t/dynamic-slot-mapping-change-default-mapping-for-dynamic-form/46783/6 "2021-08-19T11:02:57Z")

</div>

Have you specified [`auto_fill: false`](https://rasa.com/docs/rasa/domain/#slot-auto-fill)?
