# From webcam image to file \[for Telegram bot\]

**URL:** <https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300>\
**Category:** General\
**Tags:** telegram\
**Created:** [27 August 2021 21:02 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300 "2021-08-27T21:02:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bubugian](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@bubugian](https://discourse.nodered.org/u/bubugian)\
**Post date:** [27 August 2021 21:02 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/1 "2021-08-27T21:02:42Z")

</div>

Hi all !

I'm using NR 7.2.10 inside HA and I'd like to send (to Telegram) a snapshopt from my Reolink ipcamera when an event is triggered (MQTT message from BlueIris).  
I have success configuring the bot and to send Telegram text messages.

With same script as below, I have success to send a picture if 'content' is a .jpg (or something else) FILE taken from the web

```auto
if (msg.payload == "0")
{
  msg.payload = {
    chatId: 'mychatID',
    type: "photo",
    content: "https://images-na.ssl-images-amazon.com/images/I/41jaOv44rsL._SX331_BO1,204,203,200_.jpg" 
  }
  return msg;
}

```

BUT, if I chance content to image from my Reolink camera,  
`content: "http://192.168.1.5/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=123daf&user=USERNAME&password=PASSWORD"`  
it does not work.

Considering that the address works perfectly in my browser but not in Telegram, I suppose it's due to the fact the link it's not a file... is it correct ?

Probably I should somehow create a picture from camera address and use it for telegram..  
How could I do this ?

Any help is really appreciated !

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [27 August 2021 21:12 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/2 "2021-08-27T21:12:11Z")

</div>

Try replacing all the **&** in you url with `&amp;`

```auto
content: "http://192.168.1.5/cgi-bin/api.cgi?cmd=Snap&amp;channel=0&amp;rs=123daf&amp;user=USERNAME&amp;password=PASSWORD"

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 August 2021 21:37 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/3 "2021-08-27T21:37:38Z")

</div>

> [@bubugian](#):
>
> "[http://192.168.1.5/cgi-bin/api.cgi?cmd=Snap&channel](http://192.168.1.5/cgi-bin/api.cgi?cmd=Snap&channel)

How do you expect the telegram server to have access to your local network. The url has to be accessible from the internet.

---

<div class="post-metadata">

**Author:** ![jcgalvezv](https://avatars.discourse-cdn.com/v4/letter/j/58f4c7/32.png) [@jcgalvezv](https://discourse.nodered.org/u/jcgalvezv)\
**Post date:** [27 August 2021 23:42 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/4 "2021-08-27T23:42:10Z")

</div>

What I do is to get the image from camera via HTTP node request. In the following node I write the image to /tmp directory and finally I build, in a Function node, the message to Telegram like this:

```auto
msg.payload = {chatId: <yourchatid>, type: 'photo', content: '/tmp/securitycam1picture.jpg'};
return msg;

```

Replace with you actual Chat Id.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 August 2021 06:14 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/5 "2021-08-28T06:14:20Z")

</div>

There is no need to create a file, this can be all done in-memory

grab the a buffer image from camera, build the telegram msg in a function, send it...

Here is a demo: [Node red sending picture to telegram - #4 by Steve-Mcl](https://discourse.nodered.org/t/node-red-sending-picture-to-telegram/39656/4)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 August 2021 11:47 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/6 "2021-08-28T11:47:43Z")

</div>

Note: I've added a `telegram` tag to the forum as this is a commonly used service with Node-RED. I've tagged this thread and the one that Steve linked.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 October 2021 11:47 UTC](https://discourse.nodered.org/t/from-webcam-image-to-file-for-telegram-bot/50300/7 "2021-10-27T11:47:58Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
