Repository: RasaHQ/rasa-sdk

Issue:
extracting other slots in the form is broken
<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa version, use `rasa --version`. 
Please format any code or console output with three ticks ``` above and below.
If you are asking a usage question (e.g. "How do I do xyz") please post your question on https://forum.rasa.com instead -->

**Rasa version**:

**Rasa SDK version**:

**Python version**:

**Operating system** (windows, osx, ...):

**Issue**:

extracting other slot from arbitrary `from_entity` here: https://github.com/RasaHQ/rasa-sdk/blob/9c0433e4ebb4e141e8010fe2221b5d4153b96d09/rasa_sdk/forms.py#L211 breaks the logic. For example in carbon bot it extracts berlin for both slot_values---> {'travel_destination': 'berlin', 'travel_departure': 'berlin'} while requested slot was only travel_departure


**Error (including full traceback)**:
```

```

**Command or request that led to error**:
```

```

**Content of configuration file (config.yml)** (if relevant):
```yml

```

**Content of domain file (domain.yml)** (if relevant):
```yml

```

**Contents of actions.py** (if  relevant):
```python

```


Comments:

Patch:
diff --git a/changelog/237.enhancement.rst b/changelog/237.enhancement.rst
new file mode 100644
index 0000000..d7f3704
--- /dev/null
+++ b/changelog/237.enhancement.rst
@@ -0,0 +1,1 @@
+Only fill other slots if slot mapping contains a role or group restriction.
diff --git a/rasa_sdk/forms.py b/rasa_sdk/forms.py
index 0c8cea9..ced6ba5 100644
--- a/rasa_sdk/forms.py
+++ b/rasa_sdk/forms.py
@@ -190,33 +190,39 @@ class FormAction(Action):
         return intent_not_blacklisted or intent in mapping_intents
 
     def entity_is_desired(
-        self, requested_slot_mapping: Dict[Text, Any], slot: Text, tracker: "Tracker"
+        self, other_slot_mapping: Dict[Text, Any], other_slot: Text, tracker: "Tracker"
     ) -> bool:
-        """Check whether slot should be filled by an entity in the input or not.
+        """Check whether the other slot should be filled by an entity in the input or
+        not.
 
         Args:
-            requested_slot_mapping: Slot mapping.
-            slot: The slot to be filled.
+            other_slot_mapping: Slot mapping.
+            other_slot: The other slot to be filled.
             tracker: The tracker.
 
         Returns:
-            True, if slot should be filled, false otherwise.
+            True, if other slot should be filled, false otherwise.
         """
 
         # slot name is equal to the entity type
-        slot_equals_entity = slot == requested_slot_mapping.get("entity")
+        other_slot_equals_entity = other_slot == other_slot_mapping.get("entity")
 
         # use the custom slot mapping 'from_entity' defined by the user to check
         # whether we can fill a slot with an entity
-        matching_values = self.get_entity_value(
-            requested_slot_mapping.get("entity"),
-            tracker,
-            requested_slot_mapping.get("role"),
-            requested_slot_mapping.get("group"),
-        )
-        slot_fulfils_entity_mapping = matching_values is not None
+        other_slot_fulfils_entity_mapping = False
+        if (
+            other_slot_mapping.get("role") is not None
+            or other_slot_mapping.get("group") is not None
+        ):
+            matching_values = self.get_entity_value(
+                other_slot_mapping.get("entity"),
+                tracker,
+                other_slot_mapping.get("role"),
+                other_slot_mapping.get("group"),
+            )
+            other_slot_fulfils_entity_mapping = matching_values is not None
 
-        return slot_equals_entity or slot_fulfils_entity_mapping
+        return other_slot_equals_entity or other_slot_fulfils_entity_mapping
 
     @staticmethod
     def get_entity_value(


Test patch:
diff --git a/tests/test_forms.py b/tests/test_forms.py
index d1b9436..e08a7d4 100644
--- a/tests/test_forms.py
+++ b/tests/test_forms.py
@@ -769,7 +769,7 @@ def test_extract_other_slots_with_intent():
             None,
             [{"entity": "entity_type", "value": "some_value"}],
             "some_intent",
-            {"some_other_slot": "some_value"},
+            {},
         ),
     ],
 )