How to send an attachment via dispatcher?

Can anyone give a snippet of how to do this ?

@Sherin-Sneha What attachment you looking at text, video, button, image etc

Text:

`dispatcher.utter_message(text="Hello 😀")`

Image:

dispatcher.utter_message(text="Here is something to cheer you up 😉", image="https://i.imgur.com/nGF1K8f.jpg")

Button:

   button_resp=[
                  {
                      "title": "great",
                      "payload": "great"
                  },
                  {
                      "title": "super sad",
                      "payload": "super sad"
                  }
              ]

   dispatcher.utter_message(text="Hey! How are you?", buttons=button_resp)

Video:

msg = { "type": "video", "payload": { "title": "Rasa 14 Series Premier Video", "src": "https://youtu.be/Ap62n_YAVZ8" } }

dispatcher.utter_message(text="Check this video",attachment=msg)

Hope this what you looking and solve you issue.

1 Like

So here in Video: we have msg, type: video and src as link right !! In my use case, I have to send a csv file which is in my system directory … so instead of msg do I have to change anything else, what should I give the type as and how to give the location of my file in the directory in src

If the csv file is small, u can send the csv content like this :
dispatcher.utter_message(text=Path("xxx.csv").read_text()). But this is not a good way to send big data by rasa server, u need a file server, and just send the csv file address,like the video msg, use a url

1 Like

You have any idea how to use the server file because my file is kinda large and I am using telegram channel to give the output, so will I be able to give the csv file to the user to download and use… I didn’t actually get what needs to be done in the server file!! Would be helpful if I could get a snippet of how this could be done

You can build a file server with python, a sample guide. And you can buy a file server , like amazon or others