Custom Actions - Create Excel File with Data from Rasa - Rasa Open Source - Rasa Community Forum

Custom Actions - Create Excel File with Data from Rasa

post by theegg on Aug 19, 2019

Hello,

I am new to RASA and i have a small bot to create that interacts with user, ask a question and stock all these answers in an Excel file/sheet.

Is it possible with RASA? How can i do it ?

Thank you

post by IgNoRaNt23 on Aug 19, 2019

Use a FormAction to get all the information you need. Once all information is collected, it runs the ‘submit’-method, where you're free to do whatever you want. In your case, the easiest way is to write a csv-File, which can be easily loaded into Excel.

post by theegg on Aug 21, 2019

Thank you for your reply.

As I am new to rasa I might need a little clarification on how to transfer the user input of a slot, add it to a variable, and send it as a parameter to the create CSV class in the actions. If you have any tips or hints I would love to take them.

Your help is much appreciated.

post by IgNoRaNt23 on Aug 21, 2019

Here’s everything you need

post by jeng on Nov 25, 2019

hi, i also wish to know how to add user input into a file, in this case is excel. Have you figured out the way? thanks.

post by Xaviertoor on Nov 25, 2019

Try to use: pandas.DataFrame.to_csv — pandas 0.25.3 documentation

import os
import pandas as pd

Data = {'Name':  ['Rasa'],
        'E-mail': ['rasa@rasa.com'],
        }

df = pd.DataFrame(Data, columns = ['Name','E-mail'])

if not os.path.isfile('/home/youruser/output1070000.csv'):
   df.to_csv('/home/youruser/output1070000.csv',index = False, header='columns')
else: # else it exists so append without writing the header
   df.to_csv('/home/youruser/output1070000.csv',index = False, mode='a', header=False)

post by Debasmita on Jun 16, 2020

How can I fetch data from an Excel database or MySQL database in RASA chatbot?

post by IgNoRaNt23 on Jun 16, 2020

That’s not a specific problem for rasa. You’re pretty much free to write any code in a custom action. So if you know how to do that in python in general you pretty much solved your problem. I have no experience importing from MySQL or Excel in python myself, but I’m absolutely sure, that there are Python packages, which do most of the work for you.

post by rajas.black on Jul 22, 2021

You can use pandas to fetch data from excel using custom action. I have done it multiple times.