Send a file to telegram messenger

Hi,

Im trying to send a file to my telegram messenger.


This is my flow.
Is it possible to send a file to Telegram Messenger and if so how can I do this?

The aim is that when I send a command to my bot he grabs the file and I can view it in the chat.

You don't say which telegram node you are using.
But if you read the ReadMe of the node, generally they will include the information you need.

What do you think the flow you posted does?

Using the node-red-contrib-telegrambot I send rpi camera images to my chat via myTelegram bot, specifically using the sender node.

The image can either be taken and sent to the Telegram chat by an external trigger, or by me sending a message from the chat back to the receiver node.

Look at the doco for the telegrambot nodes.

2 Likes

Was looking for a solution like this but keep failing to get it to work. Would you find sharing your flow and respective javascript. Still a newbie at node-red

Their documentation has an example.

Specifically which part are you having trouble with? The Telegram part or the camera part?

The part on sending an image that is immediate captured as a buffer from the rpi cam. i have tried using a http request and response and it seems to work fine. wanted to figure out how to do it by using a telegram bot.

[{"id":"b41eab85.18f638","type":"tab","label":"Homepic","disabled":false,"info":""},{"id":"837d9a14.550c08","type":"http in","z":"b41eab85.18f638","name":"","url":"/pic","method":"get","upload":false,"swaggerDoc":"","x":130,"y":169,"wires":[["8965ee66.63579"]]},{"id":"8965ee66.63579","type":"camerapi-takephoto","z":"b41eab85.18f638","filemode":"0","filename":"pic.jpg","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"3","rotation":"270","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"Photo","x":365,"y":171,"wires":[["f0b93408.f3cbe8","13441894.8b6c27"]]},{"id":"f0b93408.f3cbe8","type":"http response","z":"b41eab85.18f638","name":"","statusCode":"","headers":{"content-type":"image/png"},"x":612,"y":142,"wires":[]},{"id":"13441894.8b6c27","type":"debug","z":"b41eab85.18f638","name":"picdebug","active":true,"console":"false","complete":"true","x":616,"y":202,"wires":[]},{"id":"798a30a2.532a28","type":"inject","z":"b41eab85.18f638","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":120.5,"y":236,"wires":[["8965ee66.63579"]]}]

Tried the following but still failing to send an image.

[{"id":"a0d605c5.f02328","type":"debug","z":"b51e2383.80a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":615,"y":307,"wires":[]},{"id":"8bd4dac1.0f4488","type":"telegrambot-notify","z":"b51e2383.80a08","name":"","bot":"c43b9d15.ca50a","chatId":"","message":"","parseMode":"Markdown","x":638,"y":362,"wires":[]},{"id":"4b4f266f.2843d8","type":"telegrambot-payload","z":"b51e2383.80a08","name":"","bot":"c43b9d15.ca50a","chatId":"","sendMethod":"sendPhoto","payload":"{\n    \"photo\":\"http://vignesk.dlinkddns.com:1880/pic\"\n}","x":388,"y":345,"wires":[["a0d605c5.f02328","8bd4dac1.0f4488"]]},{"id":"add472da.f207c","type":"camerapi-takephoto","z":"b51e2383.80a08","filemode":"0","filename":"pic.jpg","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"3","rotation":"270","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"Photo","x":321,"y":262,"wires":[["4b4f266f.2843d8"]]},{"id":"dca0d43a.2cfc48","type":"telegrambot-command","z":"b51e2383.80a08","name":"test","bot":"c43b9d15.ca50a","command":"/test","commandType":"str","commandCase":false,"x":162,"y":306,"wires":[["4b4f266f.2843d8","add472da.f207c"]]},{"id":"c43b9d15.ca50a","type":"telegrambot-config","z":"","botname":"vighome_bot","usernames":"","chatIds":"","pollInterval":"300"}]

read the file from your pc and convert it into a buffer, then with a function node save the buffer in a file specifying name and extension

Do you realize this thread is three years old?
I’ll be closing it.