Ask users to retain previously filled form slots

When a form starts, if slot values are already filled Rasa doesn’t ask the user to fill them again. Is it possible instead to ask the user if wants to retain the previously filled value or not? Example:

  • user: “Tell me the weather”
  • bot: “Where?”
  • user: “Rome”
  • bot: “The weather in Rome is sunny”
  • user: “Tell me the weather”
  • bot: “Do you want to retain Rome as location?”
  • user: “Yes”
  • bot: “The weather in Rome is sunny”

I was able to do this with an additional required slot “retain_weather” and a custom form validation action, but it came up tricky and not easy to mantain, is there a better solution for this?

Welcome to the forum :slight_smile:

In a Custom Action, you can set the slot to null after the action ran:

class ActionWeather(Action):
    def name(self):
        return 'action_weather'

    def run(self, dispatcher, tracker, domain):
        latest = tracker.latest_message
        if latest['entities']:
            for blob in latest['entities']:
                if blob['entity'] == 'city_name':
                    city_name = blob['value']
                    result = get_weather(city_name)
                return [SlotSet('city_name', None)]
            utterance = 'Please provide a city or country to check the weather.'
        return []

Thank you @ChrisRahme

Actually, I want the slot to be saved between conversations, I don’t want to delete it. What I want to achieve is that the user should have a prompt to choose if wants to use the saved value or insert a new value, for every slot of the form.

You can still do that with custom actions, I have given you all the tools you need in my answer above, modify it according to your needs :slight_smile:

Sorry I don’t get how to do it with a single custom action. In the action I can utter “Do you want to retain Rome as location?”, but then I cannot wait for the user response in the same action.

You can build a story :slight_smile: