How to send images as bot responses in Slack?

Hi,

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:

  utter_cheer_up:
  - text: "Here is something to cheer you up:"
    image: "https://i.imgur.com/nGF1K8f.jpg"

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?

Thanks,

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