How to make rasa chatbot Fetching csv file

@nik202 faq_d.csv (26.9 KB) actions.py (1.2 KB)

Thank you so much

@dan246 I am sorry for the major mistake

Please update this:

class GetAnswer(Action):
     def __init__(self):
         self.faq_d = pd.read_csv('./data/faq_d.csv')
         qs = list(self.faq_d['question'])
         with open("./data/dan.yml", "wt", encoding="utf-8") as f:
             f.write('version: "2.0"\n')
             f.write("nlu: \n- intent: question\n  examples: | \n")
             for q in qs:
                 f.write(f"    - {q}\n") 

     def name(self) -> Text:
        return "action_get_answer"

        return []

We are not updated the self.faq_data too faq_d

Mean we have to change the file name faq_d 3 place

I check your code and I was also getting this error and then I realise that faq_data should be faq_d

Please run and this time it will create the file, what ever name you will give.

Output:

1 Like

@nik202 It works! Thank you very much!!

The next step is to put it (dan.yml) in rasa x and train it to work?

You need to work a lot it’s only a baby step and do ref my first post and good luck for the project.

@nik202 can you please help me i need to fetch the answer and it is hard for me to code this part. Because you have to go to domaine.yml and write the response for the intent question. thanks

@dan246 if you have solved this can you please share the code. I need it very much

HI @Sniper44 You need to set the reply in action.py

This is my code, I use fuzzywuzzy to grab the questions in the csv file and let rasa reply to the answer

I hope it can help you, please let me know if you can improve the code, thank you

(This is google translate, sorry :cry:)

@dan246 Thank you very much. Can you share with me you action.py and thanks again

actions.py (2.2 KB)

@Sniper44

Here,if you can make it easier please let me know, thanks

@dan246 thank you my friend i will try

Hi Nik Does the faq.yml also gets trained in rasa train ? If yes then how to pick the answers for the questions in faq.yml file ?

What will be the rule or story to trigger this ?

All mentioned in the code, it will create the intent questions but first you need to run the Rasa actions then train the bot.

Whatever you have mention in questions wrt to there answers. It will create the questions for question intent.

Simple story also will work fine.

1 Like