Sending photo with Telegram-messenger using http-request node

2,350 views
Skip to first unread message

Egg Nine

unread,
Mar 5, 2017, 10:11:30 AM3/5/17
to Node-RED

Hi,

I am trying to send a photo with Telegram messenger using an URL request with a http-request node. For some reason my photo is not being sent.
It seems I have problems indluding the photo (/tmp/img.jpg) itself.

This is what I put in the http-request node fields:

msg.url="https://api.telegram.org/bot12345678/sendPhoto?chat_id=-1234567890&photo=/tmp/img.jpg";
msg.headers = {"Content-type" : "multipart/form-data"};
msg.method="POST"

When I run a curl command from the cli it works:
curl -F photo=@/tmp/img.jpg -H "Content-Type:multipart/form-data" "https://api.telegram.org/bot123456789/sendPhoto?chat_id=-123456789"

Can someone advice how I can translate the curl command into a http-request node?

Thanks,
Rene

Julian Knight

unread,
Mar 5, 2017, 10:53:41 AM3/5/17
to Node-RED
Can;t help with that but have you tried the 2 different nodes that talk to Telegram?

Ivan Tarozzi

unread,
Mar 6, 2017, 2:57:38 AM3/6/17
to Node-RED
I don't use telegram API url directly, but as Julian wrote you can use chatbot nodes for that.

Here an example using chatbot

[{"id":"61e604a1.e39d9c","type":"chatbot-telegram-receive","z":"f246fc4f.98409","bot":"470553c2.b789cc","x":385.0994110107422,"y":66.81817626953125,"wires":[["c680f813.01e598"]]},{"id":"41b56b59.b13da4","type":"chatbot-telegram-send","z":"f246fc4f.98409","bot":"470553c2.b789cc","track":false,"outputs":0,"x":1093.0995330810547,"y":176.81817626953125,"wires":[]},{"id":"c680f813.01e598","type":"chatbot-command","z":"f246fc4f.98409","name":"","command":"/get_image","x":588.5625,"y":77,"wires":[["f792191c.fd9358"]]},{"id":"36d3d904.198226","type":"chatbot-image","z":"f246fc4f.98409","name":"img","filename":"","caption":"Hello !","x":947.5625,"y":128,"wires":[["41b56b59.b13da4"]]},{"id":"f792191c.fd9358","type":"http request","z":"f246fc4f.98409","name":"","method":"GET","ret":"bin","url":"http://www.xperiaforce.com/wp-content/uploads/2014/02/one-merhaba-dunyai.jpg","tls":"","x":763.147705078125,"y":77.28125,"wires":[["36d3d904.198226"]]},{"id":"470553c2.b789cc","type":"chatbot-telegram-node","z":"","botname":"itlabTestBot","usernames":"IvanTarozzi","polling":"200","log":""}]

This sends an image picked from the web, but you can use file image too
Reply all
Reply to author
Forward
0 new messages