# Taking a picture and sending it via telegram

**URL:** <https://discourse.nodered.org/t/taking-a-picture-and-sending-it-via-telegram/27905>\
**Category:** General\
**Created:** [6 June 2020 17:48 UTC](https://discourse.nodered.org/t/taking-a-picture-and-sending-it-via-telegram/27905 "2020-06-06T17:48:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [7 June 2020 21:27 UTC](https://discourse.nodered.org/t/taking-a-picture-and-sending-it-via-telegram/27905/4 "2020-06-07T21:27:12Z")

</div>

`msg.payload.content` can also be a buffer object

Are you able to get the image from the webcam into a buffer?

Here is a demo i did...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/e/dee2c25b6ba229b4404e39dd23909e06a6a6a489.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/322b462886fc333ff86c8e10bb26f2fcfac31e0b.png)

```auto
[{"id":"99ee972c.22d088","type":"telegram sender","z":"5d3f964c.fef898","name":"","bot":"fa7a9376.321ce","x":930,"y":280,"wires":[["72b71335.355a9c"]]},{"id":"58e78fc.dd0b27","type":"telegram command","z":"5d3f964c.fef898","name":"/pic","command":"/pic","bot":"fa7a9376.321ce","strict":false,"hasresponse":false,"x":130,"y":280,"wires":[["3eb663cf.b0d58c"]]},{"id":"72b71335.355a9c","type":"debug","z":"5d3f964c.fef898","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":240,"wires":[]},{"id":"2058d729.1a3a48","type":"function","z":"5d3f964c.fef898","name":"send picture","func":"var pl = {\n content: msg.payload,\n message: `Hey ${msg.originalMessage.from.first_name}, here is ${msg.originalMessage.text} you requested`,\n type : 'photo',\n chatId: msg.originalMessage.chat.id,\n chat: msg.originalMessage.chat,\n from: msg.originalMessage.from,\n message_id : msg.originalMessage.message_id\n}\n\nmsg.payload = pl;\n\n\n/* type can be one of the following\nphoto\naudio\nvideo\nsticker\nvoice\ndocument\n*/\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":280,"wires":[["99ee972c.22d088"]]},{"id":"959c0404.742708","type":"image","z":"5d3f964c.fef898","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":false,"active":true,"x":920,"y":360,"wires":[[]]},{"id":"3eb663cf.b0d58c","type":"switch","z":"5d3f964c.fef898","name":"local, random, other","property":"originalMessage.text","propertyType":"msg","rules":[{"t":"eq","v":"/pic local","vt":"str"},{"t":"eq","v":"/pic random","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":280,"y":360,"wires":[["7c8090ca.00c02"],["dec15032.19344"],["c41817dc.703418"]]},{"id":"7c8090ca.00c02","type":"file in","z":"5d3f964c.fef898","name":"load image","filename":"node-red-256.png","format":"","chunk":false,"sendError":false,"encoding":"none","x":510,"y":280,"wires":[["2058d729.1a3a48","959c0404.742708"]]},{"id":"c41817dc.703418","type":"function","z":"5d3f964c.fef898","name":"Dont understand message","func":"var message = \n`\n## I dont understand 🤔\n\nPlease send \\`/pic local\\` or \\`/pic random\\`\n\n`;\n\nmsg.payload.type = 'message';\nmsg.payload.content = message;\n\n// activate markdown\nmsg.payload.options = {\n disable_web_page_preview : true, \n parse_mode : \"Markdown\"\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":440,"wires":[["99ee972c.22d088"]],"info":"## New message\n\nHello *markdown* formatted messages!'\n\nwith `inline` code\n\n> and quote\n>> nested\n\n\\`\\`\\`\nvar code = \"cool\";\n\\`\\`\\`\n\n| table | data |\n|---|---|\n| 1 | fred |\n| 2 | bob |\n\n_Italic_ **bold**"},{"id":"dec15032.19344","type":"http request","z":"5d3f964c.fef898","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://picsum.photos/200/300","tls":"","persist":false,"proxy":"","authType":"","x":510,"y":360,"wires":[["959c0404.742708","2058d729.1a3a48"]]},{"id":"fa7a9376.321ce","type":"telegram bot","z":"5d3f964c.fef898","botname":"my_bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"","usesocks":false,"sockshost":"","socksport":"","socksusername":"","sockspassword":"","bothost":"","localbotport":"","publicbotport":"","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

```

---

_[View the full topic](https://discourse.nodered.org/t/taking-a-picture-and-sending-it-via-telegram/27905)._
