Send a photo to Telegram


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:






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:


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.


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


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


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 ?


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.


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


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"}]


Hi everyone,

Just for the records, I've made a different approach to this problem and now it is solved.

I've used an Exec Node to run a system command and execute a python script, to take a picture with the raspberry pi camera and send it to a telegram bot.

I have to give the credit to Carlo Mascellani
Thanks Carlo

This is the code

import telegram
import picamera

from telegram_keys import (

# Connect to our bot
bot = telegram.Bot(my_token)

# Sets the id for the active chat

#Get the photo

# Sends a message to the chat
bot.sendPhoto(chat_id=chat_id, photo=open('/home/pi/Pictures/capture.jpg', 'rb'))

Thank you everyone for your support.