Node red sending picture to telegram

In your original example, the issue is likely because you are NOT sending a buffer.

Here is a working example...

To make it work

  • import the demo flow
  • setup the BOT connection
  • send /picture to your bot

NOTE: this demo uses node-red-contrib-telegrambot

The demo flow...

[{"id":"4cdb400.5a8f3c","type":"telegram command","z":"5d3f964c.fef898","name":"/picture","command":"/picture","bot":"fa7a9376.321ce","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":1390,"y":1760,"wires":[["fdbea5e0.730e08"]]},{"id":"fdbea5e0.730e08","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":1410,"y":1840,"wires":[["352469a3.7bb1d6","d33bab75.38ecb8"]]},{"id":"352469a3.7bb1d6","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 the random piture 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":1610,"y":1840,"wires":[["b5d7e8fa.e4aa08","b2b89b56.bd20f8"]]},{"id":"b5d7e8fa.e4aa08","type":"telegram sender","z":"5d3f964c.fef898","name":"","bot":"","outputs":1,"x":1850,"y":1840,"wires":[[]]},{"id":"d33bab75.38ecb8","type":"debug","z":"5d3f964c.fef898","name":"The image","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1410,"y":1880,"wires":[]},{"id":"b2b89b56.bd20f8","type":"debug","z":"5d3f964c.fef898","name":"the telegram msg","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1630,"y":1880,"wires":[]},{"id":"fa7a9376.321ce","type":"telegram bot","z":"5d3f964c.fef898","botname":"mybot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"","usesocks":false,"sockshost":"","socksport":"","socksusername":"","sockspassword":"","bothost":"","localbotport":"","publicbotport":"","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]
2 Likes