How to give a document (csv file) as response in RASA

I don’t know how to give document which I have in csv format as a response… Can someone give a sample code of how we must add a document as response

for displaying an image here it uses an url but i wanna use a csv file which is in my local disk/project file


  • buttons:
    • payload: /affirm title: Yes
    • payload: /deny title: No, cancel the transaction button_type: vertical text: Would you like to transfer {currency}{amount_of_money} to {PERSON}? image: “

when i tried using document in a similar way it uses an image i got the following error Key ‘document’ was not defined. Path: ‘/responses/utter_doc/0’

What’s your frontend? If it’s Rasa X, you cannot do it.

Look at JiteshGaikwad’s Chatbot-Widget for example:

[function line 42] While retrieving the bot’s response, you can see the rendering code for if the message has text, an image, buttons, an attachment, or a custom property.

  • Inside the attachement code, it’s checking if the attachement is of type == "video", you could add your own code for type == "csv"
  • Inside the custom code, there could be a pdf_attachement property, which renders the file using this function.

You could implement any of those two ways in your frontend.

1 Like

@Sherin-Sneha Heya! If you can answer some of my questions please:

  1. As per user query or user input, how your .csv file pick the response and render as output based on user input; output can be text, image or video links.
  2. How you will train the bot as per intents, related to response, as user can asked anything, or with different phrases?
  3. Or you just planning to fetch the individual column response data as a response based on slots, entities etc.
  4. Or are you able to fetch any response from the .csv or excel file? Do you have a plan for this? I can be wrong whilst understanding your question :slight_smile: Thanks.

@Sherin-Sneha Please do consider Chris suggestion also, hope his suggestion solves your issue.

I am using python !! Would be helpful if I can get a python code. THANK YOU !!

I am converting my .json to .csv and downloading it to my project folder, from there I want to show a download feature of the .csv file in telegram. Hope you get my point now ?

@Sherin-Sneha If I get you right, your data currently in .JSON and by using some python code, you converted to .CSV file into you project folder and from that file you want to fetch the data using telegram. For doing first half .JSON → .CSV code it ready as it will fetch the code instantly when we run rasa or it was backend process? Can you share the small snippet code of your JSON file or CSV will be better.