Define responses in external file like txt or anything

Hello everyone, I would like to ask if i can remove my answers from the domain file, create local files with them (like txt or any format), and then connect with some way like reference. This came up beacause my data may change in the future and it would be easier to make any change just from file and not in code.

Thank you in advance!! :grinning: DK

Welcome to the community :slight_smile:

You can use Custom Actions to read your answers from a file as you would with regular Python code, then utter the contents of the file.

class ActionReadFile(Action):
    def name(self):
        return "action_read_file"

    async def run(self, dispatcher, tracker, domain):
        with open('my_answer_file.txt', 'r') as f:
            my_text =
            dispatcher.utter_message(text = my_text)
        return []
1 Like

Dear Chris, Thank you for your quick response!! Generally, is this right strategy for Rasa implementation? I mean is this breaks the basic structure?

Thank you again! :grinning:

Sorry, I’m not sure what you mean.

This does not break anything and is supported by Rasa (since it’s in the docs). Please read the links in my post above for more info.