DimitraK
(Dimi)
October 28, 2021, 6:00am
1
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!!
DK
ChrisRahme
(Chris Rahmé)
October 28, 2021, 6:47am
2
Welcome to the community
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 = f.read()
dispatcher.utter_message(text = my_text)
return []
1 Like
DimitraK
(Dimi)
October 28, 2021, 6:58am
3
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!
ChrisRahme
(Chris Rahmé)
October 28, 2021, 9:49am
4
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.