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

**URL:** <https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478>\
**Category:** Rasa Open Source\
**Created:** [August 3, 2021, 12:50pm UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478 "2021-08-03T12:50:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sherin-Sneha](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sherin-sneha/32/16346_2.png) [@Sherin-Sneha](https://forum.rasa.com/u/Sherin-Sneha)\
**Post date:** [August 3, 2021, 12:50pm UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478/1 "2021-08-03T12:50:10Z")

</div>

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

utter\_ask\_transfer\_form\_confirm:

- 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: “[https://i.imgur.com/nGF1K8f.jpg](https://i.imgur.com/nGF1K8f.jpg)”

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’

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [August 3, 2021, 3:24pm UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478/2 "2021-08-03T15:24:13Z")

</div>

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

Look at JiteshGaikwad’s [Chatbot-Widget](https://github.com/JiteshGaikwad/Chatbot-Widget) for example:

[[function line 42](https://github.com/JiteshGaikwad/Chatbot-Widget/blob/main/static/js/components/chat.js)] 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](https://github.com/JiteshGaikwad/Chatbot-Widget/blob/main/static/js/components/pdfAttachment.js) function.

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

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [August 3, 2021, 10:46pm UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478/3 "2021-08-03T22:46:42Z")

</div>

@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 🙂 Thanks.

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

---

<div class="post-metadata">

**Author:** ![Sherin-Sneha](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sherin-sneha/32/16346_2.png) [@Sherin-Sneha](https://forum.rasa.com/u/Sherin-Sneha)\
**Post date:** [August 4, 2021, 2:37am UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478/5 "2021-08-04T02:37:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sherin-Sneha](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sherin-sneha/32/16346_2.png) [@Sherin-Sneha](https://forum.rasa.com/u/Sherin-Sneha)\
**Post date:** [August 4, 2021, 2:38am UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478/6 "2021-08-04T02:38:03Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [August 4, 2021, 8:12am UTC](https://forum.rasa.com/t/how-to-give-a-document-csv-file-as-response-in-rasa/46478/7 "2021-08-04T08:12:15Z")

</div>

@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.
