Get the value and unit of a duration extracted with Duckling

I am struggling to get the unit of a duration extracted with Duckling. The slot only contains the value but not the unit of it. For example, I told my bot , “I slept for 7 hours”. and it only extracted and displayed the value 7 instead of the value and unit, 7 hours.

I would like some help in getting the value and unit out of duckling. TIA!

I was able to use this code in the ‘’ under the slot validation.

data = tracker.latest_message[“entities”] data = list(filter( lambda entity: entity[‘entity’] == “duration”, tracker.latest_message[“entities”] ))

if data:

values = data[0][“additional_info”][“value”] unit = data[0][“additional_info”][“unit”]

return {“slot_name”: f’{values} {unit}’}


return {“slot_name”: None}