Send a photo to Telegram


#1

I need some help in order to send a photo taken with the pi camera to Telegram.

I am using "node-red-contrib-telegrambot-home" and these are the flow and nodes:

flow

camerapi-takephoto

telegram_payload

--

telegram_notify

With this flow the picture is taken and stored in the Pi, but I get nothing in Telegram.

I also tried with a "funtion" node instead of a "telegram payload" node:

funtion

In this case what I get is a text in the TelegramBot: "/home/pi/Pictures/foto". But not picture at all.

Could somebody help me?

Thank you so much.


#2

Have you checked to see that the photo actually exists and checked the name?

It's often easier to break a problem down.
i.e a flow to capture a photo and store it
a flow that gets a stored photo and sends it to telegram

That way you can see where the problem occurs


#3

Thanks for your response.
Yes, I have checked that the photo is in the right folder and with the right name.


#4

Is the send too quick... has the photo been fully written to disk and the file closed before the payload node tries to read it ?


#5

dceejay, thank you so much for your response.

That does not seem to be the problem. I have put a delay (first of 1 and then of 5 seconds) after the "camerapi-takephoto" node and it does not work.


#6

You have to send the data as a multi-part form similar to any other file upload to a server. Details are here:


#7

Thank you so much for your response.

I have tried this node:

Still not working. I am afraid this multi-part form thing is far out of my current knowledge.

I copy the flow just in case somebody can detect any mistake.

Thanks again.

[{"id":"85be023a.0552e","type":"inject","z":"91952aac.1bd658","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":100,"wires":[["6544f6e3.7a6388"]]},{"id":"6544f6e3.7a6388","type":"camerapi-takephoto","z":"91952aac.1bd658","filemode":"1","filename":"foto","filedefpath":"0","filepath":"/home/pi/Pictures/","fileformat":"jpeg","resolution":"1","rotation":"0","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":"","x":360,"y":180,"wires":[["21262984.983446"]]},{"id":"21262984.983446","type":"delay","z":"91952aac.1bd658","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":240,"wires":[["c637d704.e41cd8"]]},{"id":"c637d704.e41cd8","type":"http-send-multipart","z":"91952aac.1bd658","name":"","ret":"bin","filepath":"/home/pi/Pictures/foto.JPEG","url":"my_public_IP:my_port","tls":"","x":450,"y":280,"wires":[["73793f29.5deae"]]},{"id":"73793f29.5deae","type":"telegrambot-payload","z":"91952aac.1bd658","name":"","bot":"ab134760.32e278","chatId":"My_Chat_ID","sendMethod":"sendPhoto","payload":"{\n    \"photo\": \"/home/pi/Pictures/foto.JPEG\",\n    \"caption\": \"Test\"\n}","x":510,"y":340,"wires":[["d68268c7.c33238"]]},{"id":"d68268c7.c33238","type":"telegrambot-notify","z":"91952aac.1bd658","name":"","bot":"ab134760.32e278","chatId":"My_chat_ID","message":"","parseMode":"HTML","x":520,"y":400,"wires":[]},{"id":"ab134760.32e278","type":"telegrambot-config","z":"","botname":"NodeRedBot","usernames":"Talud08","chatIds":"209723044","pollInterval":"300"}]