How to send images as bot responses in Slack?


I want display images in the chat bot in slack. Can anyone please help me on how to send images from rasa to slack

Thanks in advance,

You can use urls for images or create a simple REST API for getting the image in rasa actions server using custom actions…there is a parameter image in dispatcher. dispatcher.utter_template(“utter_greet”,tracker, image=“image_url”)

Hope it helps…:slightly_smiling_face:

Hey @Bhargav, you can also create a template in your domain file that has an image like so:

  - text: "Here is something to cheer you up:"
    image: ""

then you can use the utter_cheer_up action directly or via dispatcher.utter_template("utter_cheer_up", tracker).

Hi @imabhinav-am , @erohmensing,

Thank you very much. This is working fine :slight_smile:

One small information. Can we send the images from our local path\system. I am trying to do that. Its not working :frowning_face:

For that you have to create an API on your system or host the image somewhere on internet

HI @imabhinav-am,

Can you please explain me more about how to create API?


@Bhargav are you able to do it with the file URI scheme? file URI scheme - Wikipedia

Depending on your OS it should look something like file:///path/to/image.png or something like that

Hi @erohmensing,

I tried the file url but this is not working

You have to use flask to create a REST Api for sending images

Hi Abhinav ? Is there any example of this on Git ? I Don’t find one :expressionless:

@Bhargav, sorry I haven’t tested myself so I can’t be sure, but if the image path doesn’t work, then you probably have to host the image somewhere.

I have to admit, I’m a bit confused about sending images as a response. Whenever I add an image to a response template, the domain won’t train/validate unless I also include text.

rasa_core.domain.InvalidDomain: Utter template ‘utter_image_reply’ needs to contain’- text: ’ attribute to be a propertemplate

What am I doing wrong?

hi @erohmensing , If I want to send multiple images how can define please help me on that, I want to create image slider in my bot UI.