Extracting slot method - advice on how to use


I have a form which at the end, asks if the user wants to enter freeform comments. If they say “Yes” I dynamically add a slot.

However, validation only occurs if it has been extracted. I have therefore created an extract_<slot_name> method. Using the example from the RASA website it simply gets the user input i.e.

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

However, this picks up the “yes” from the previous user’s input to agreeing to enter comments and skips my slot (as it’s just a freeform text field).

Can you advise on the best way to get the input only if they are being asked the question from the slot you’re in?


In absence of a response, I changed my extract method to only pick up the text for the slot I was on i.e. survey_comments:

if tracker.get_slot('requested_slot') == 'survey_comments':
    text_of_last_user_message = tracker.latest_message.get('text')

This works for me. Not sure if it’s the best way but I am not sure how the sample code works when adding a slot to pre-existing form slots without picking up the current field’s text first.

1 Like