Creating a graph in the custom action and rendering the graph to the UI

Hi @souvikg10 / @akelad ,

I want to render a graph on the slack from the custom action.

Let say the NLU layer has classified the intent of the user utterance and the Rasa Core now pass the control to the custom action where the sql query will be executed and data would be fetched from the database table. Now let say the data extracted need to be converted to a graph and the graph need to be dispatched to the UI ( slack)

I am not able to find any help either in the doc or on the github. Kindly help in achieving it.



your best option is to first create an image of the graph and then post it as an image.

e.g. in your custom action you can send images via url or attachment (depends on channel)

for the slack channel check the methods send_image_url and send_attachment:

1 Like

@amn41 can you please send a code which sends image as attachment… I have tried but no luck

can you please post the code you have, any error output you have, and what you have tried so far to diagnose the problem?

@amn41 here is the error

recipient = self.slack_channel or recipient_id

AttributeError: ‘ActionTrend’ object has no attribute ‘slack_channel’

I’m calling the function as below:

from rasa_core.channels.slack import SlackBot SlackBot.send_attachment(self,recipient_id=‘slack_token’, attachment=‘file location’)

hi mohan,

I think the issue is that you are calling send_attachment method on the name of the class: SlackBot. What you want to do is create an instance of the class first, and then call this function, e.g.

my_slackbot = SlackBot(slack_token, slack_channel)

does that work?

1 Like

@amn41 can you tell me what should i pass as recipient_id?

that depends, if you are sending a message to a channel, then the recipient id can just be None. You just have to make sure that your slackbot instance has a channel set

1 Like

@amn41 Thank you so much Alan:+1: