# Displaying image from local storage

**URL:** <https://forum.rasa.com/t/displaying-image-from-local-storage/26204>\
**Category:** Rasa Open Source\
**Created:** [March 17, 2020, 1:29pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204 "2020-03-17T13:29:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@ramya](https://forum.rasa.com/u/ramya)\
**Post date:** [March 17, 2020, 1:29pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/1 "2020-03-17T13:29:23Z")

</div>

Hello everyone, I am using rasa on telegram. I want to display image from my local storage on telegram. Kindly help me with the same. Thanks.

---

<div class="post-metadata">

**Author:** ![Gehova](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gehova](https://forum.rasa.com/u/Gehova)\
**Post date:** [March 17, 2020, 2:21pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/2 "2020-03-17T14:21:31Z")

</div>

1. Copy the telegram.py file in channels to your project. Rename it something like customTelegram.py

2. In the output channel class, add a new function for sending the image:

```auto
def send_image_local(self, recipient_id:Text, image:Text, **kwargs: Any) -> None:
    self.send_photo(recipient_id, open(image, 'rb'))

```

1. Add the new item in the dictionary `send_functions` in the function `send_custom_json` like `("image_local",): "send_image_local",`.

2. Modify credentials.yml, replacing `telegram:` with `customTelegram.TelegramInput:`

3. In your custom actions use:

```auto
attachment = {"image_local": <image_path>}
dispatcher.utter_custom_json(attachment)

```

---

<div class="post-metadata">

**Author:** ![ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@ramya](https://forum.rasa.com/u/ramya)\
**Post date:** [March 17, 2020, 3:25pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/3 "2020-03-17T15:25:10Z")

</div>

Thank you for the reply!

I’m encountering the following error though.

 ![Screenshot%20(117)](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/b/b912f4147dd7be69a11f48eca1d10040a3b77c74.png)

---

<div class="post-metadata">

**Author:** ![Gehova](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gehova](https://forum.rasa.com/u/Gehova)\
**Post date:** [March 17, 2020, 5:09pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/4 "2020-03-17T17:09:36Z")

</div>

That thing is new, I didn’t find it when I made my custom channel. Make a test for the channel with that line commented.

---

<div class="post-metadata">

**Author:** ![ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@ramya](https://forum.rasa.com/u/ramya)\
**Post date:** [March 18, 2020, 5:15pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/5 "2020-03-18T17:15:39Z")

</div>

Okay.I’ll give it a try

---

<div class="post-metadata">

**Author:** ![\_sanjay\_r](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/_sanjay_r/32/4451_2.png) [@\_sanjay\_r](https://forum.rasa.com/u/_sanjay_r)\
**Post date:** [April 18, 2020, 9:51am UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/6 "2020-04-18T09:51:45Z")

</div>

Her @ramya, did you solve this issue ?

---

<div class="post-metadata">

**Author:** ![ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@ramya](https://forum.rasa.com/u/ramya)\
**Post date:** [April 18, 2020, 10:28am UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/7 "2020-04-18T10:28:06Z")

</div>

No.I couldn’t solve it

---

<div class="post-metadata">

**Author:** ![\_sanjay\_r](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/_sanjay_r/32/4451_2.png) [@\_sanjay\_r](https://forum.rasa.com/u/_sanjay_r)\
**Post date:** [April 19, 2020, 7:34am UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/8 "2020-04-19T07:34:59Z")

</div>

Hey @ramya,

From what I understood, unless you have your own bot UI, sending image from local folder is not possible. Other channels renders hyperlinks to images only.

So I uploaded the image to imgur, and shared the link in the response and telegram renders the image. It works now.

You can use the [imgur api](https://apidocs.imgur.com/?version=latest) to upload the image within the custom action itself , which return a link that can be sent as a response and telegram will render that image.

( Additionally you may sometimes run into a timeout error like I did,as default time out is 10 sec, imgur may take a bit longer to upload the image. So you can increase the `DEFAULT_STREAM_READING_TIMEOUT_IN_SECOND` in `console.py`. Refer [this issue](https://github.com/RasaHQ/rasa/issues/4606) )

Cheers.

---

<div class="post-metadata">

**Author:** ![ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@ramya](https://forum.rasa.com/u/ramya)\
**Post date:** [April 23, 2020, 6:17am UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/9 "2020-04-23T06:17:34Z")

</div>

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![rodrigo\_deoliveira](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@rodrigo\_deoliveira](https://forum.rasa.com/u/rodrigo_deoliveira)\
**Post date:** [June 11, 2020, 3:52pm UTC](https://forum.rasa.com/t/displaying-image-from-local-storage/26204/10 "2020-06-11T15:52:16Z")

</div>

Wanted to throw in my 2 cents, if (past and future) folks find it helpful.

The `bot` API by Telegram can actually send images from local disk; you just need to send it as a binary file object. Unfortunately the Rasa channel for Telegram can only send URIs/URLs of images, not file objects. A temporary fix (aka _hack_ =P) is to modify the Rasa connector. Locate `telegram.py` in the Rasa source on your machine, then find the class `TelegramOutput` and the method `send_image_url`, and modify the line that says:

```
self.send_photo(recipient_id, image)

```

to

```
self.send_photo(recipient_id, open(image, 'rb'))

```

And your bot should be able to send local images to Telegram.
