Slot value is None with custom slot mappings when get from validate_{slot_name} function

Hello,

I’m using custom slot mappings for the slot ‘ot_id’:

def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
    return {
        'ot_id': self.from_entity(entity='id', intent='inform_id')      
        }

In the debug log of action server, the ‘ot_id’ slot was extracted successfully:

2019-08-13 11:48:33 DEBUG    rasa_sdk.forms  - Trying to extract requested slot 'ot_id' ...
2019-08-13 11:48:33 DEBUG    rasa_sdk.forms  - Got mapping '{'type': 'from_entity', 'entity': 'id', 'intent': ['inform_id'], 'not_intent': []}'
2019-08-13 11:48:33 DEBUG    rasa_sdk.forms  - Successfully extracted '2' for requested slot 'ot_id'
2019-08-13 11:48:33 DEBUG    CustomActions.CustomFormAction  - Validating extracted slots: {'ot_id': '2'}

But after that when i get the ‘ot_id’ slot value from validate_ot_id(), it’s None:

    ot_id = tracker.get_slot('ot_id')
    print(ot_id)

I don’t have any idea how this happened.

After checking the code from the forms.py of Rasa, i figured it out. It’s because the validation happens before the slot get assigned with SlotSet(slot, value). And since it doesn’t automatically get assigned when the bot pick up the entity (cause they don’t share the same name), it has value None when i called ot_id = tracker.get_slot('ot_id').

So i guess instead of get_slot('ot_id'), i have to use get_latest_entity_values('id') and validate that data.

Anyway, i think it would be nice if you guys add some kind of clarification on this matter in the docs: Forms, since without looking into the forms.py, most of us users will think the slot get assigned automatically when using custom slot mappings, just with a different name entity.