How to send dataframe as a table in utterance using webchat UI

I am using pandas module for custom actions data processing.

Is there a way to display the dataframe as a table in the Rasa webchat…?

Or how can we send data in table format as utterance? Where the user will get a clear picture about the responce.

help me with this…

I think you can use pandas.DataFrame.to_string method to convert data frame to string and so an utterance (At custom action with dispatcher.utter_message function). It may be a naive solution.

Currently i am using it in that way.

I am having more columns and rows ie. summary like table to send utterance. In that case it will not be a better solution.

@janaesh Hi, currenlty there is no such use case like display the data into data. May be you can convert the data table to image and render it?

1 Like

Hi @nik202 I’m able to convert my dataframe into a table using pandas and dataframe_image module. What it does is that it converts the data into tabular format and downloads the table as an image. Now, I just want this to happen via my webchat widget in rasa. I created a custom action for this but it fails to download the table as an image for me. Rasa server always throws this error -

Also, @janaesh if you found out any solution to this, please help me out buddy

@webdev-rohit That idea doesn’t suit my need and it is not very effective try different approach

@webdev-rohit Send the data frame as JSON to the client and I have rendered it as table using HTML and is.That is how I have done it

Hi @janaesh , can you tell me at the frontend how to retrieve whatever has been sent as json message. My front-end is something like this -

Could you please guide me where or how to extract the json message passed by rasa here. Or you could even provide a snippet of your code if you don’t mind. Thanks in advance!

HI @webdev-rohit I can see that you are using Webchat for client it works on react I am not that good in react. I do have some idea in basic FE tech so i started using this UI https://github.com/JiteshGaikwad/Chatbot-Widget .

@webdev-rohit It was quite easy to customize.

@webdev-rohit For your case you can try to get some help from React developers or learn to customize the widget according

@janaesh I’m not using react. It’s a simple html page with rasa parameters defined within the script tag

@webdev-rohit I think you havent understand it quite well pls do check this vedio Best Ways To Customize Rasa-webchat - YouTube

Thank you @janaesh , I watched the video but nowhere in the video, he has shown how he could receive data sent by Rasa into his front-end.

If you see in this post, Jitesh has dispatched a json message via his custom action and used it in his frontend. However, his frontend is entirely different. I need to just do something like this in my front-end code.

@Horizon733 Hi Dishant, please check my query here since I’m following the frontend which you’ve been using in your videos. Thanks in advance!

if you want to do same as Jitesh then you will also have to customize rasa-webchat

or the other way around is to put those stuff in metadata and capture it via custom socketio channel and get it from events

Hi @Horizon733 could you provide an example snippet code with respect to [this] post

Hi, you will have to write custom socketio channel by yourself by looking at the code on Rasa github repo. to get metadata from events,
Events are list of dict so you will have to parse and search and extract it yourself.

tracker.events

to get events