How to transfer chatId to the output node

I take a photo on request. If you explicitly specify my chatid in the output node, then the photo comes fine. But I want everyone in my family to be able to request. They have different chatId. how to make the chatid stuck in the first node (the chatid of the one who sent the request) and insert it in the last node to send the photo to the one who requested it.

[{"id":"60cca025.59cf5","type":"telegram command","z":"eaca9e42.f9bc","name":"","command":"/у","bot":"","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":130,"y":680,"wires":[["49239da1.bffaa4"]]},{"id":"49239da1.bffaa4","type":"http request","z":"eaca9e42.f9bc","name":"Фото улицы","method":"GET","ret":"bin","paytoqs":"ignore","url":"http://admin:Sator3120Arepo@","tls":"","persist":false,"proxy":"","authType":"digest","x":330,"y":680,"wires":[["ec574bb0.4db638"]]},{"id":"72e122c7.c3530c","type":"telegram sender","z":"eaca9e42.f9bc","name":"Majordomo_88","bot":"","haserroroutput":false,"outputs":1,"x":780,"y":680,"wires":[[]]},{"id":"ec574bb0.4db638","type":"function","z":"eaca9e42.f9bc","name":"Отправка папе","func":"var photo = msg.payload\nmsg.payload=\n{content:photo,\nchatId: 543173858,\ntype:'photo'}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":680,"wires":[["72e122c7.c3530c"]]}]

Hi and welcome to the forum. Couple of things.

Firstly, the flow that you have shared contains your user id and password. Best to put those into flow variables and reference them in your flow. Then when you export the flow, the id and password won't be visible.

Secondly, it is best to be clear in the title what node(s) you are having problems with rather than trying to make people work it out. One of the Telegram nodes I take it in this instance.

In general, to have a photo appear for multiple people, they should all be in a group. Then you can attach the bot to the group and use the groups ChatID.

Passwords are a test system and I'll change everything. Secondly, I don’t want the photo to be sent to everyone, but only to the person who made the request.

That is, in the first node, you need to somehow remember the chatid and substitute it in the last node.

Why not just send it through with the msg? Just move it to a different property name. Move it back at the end?

Just use a change node AFTER the 1st telegram node, set msg.chatId to msg.payload.chatId (as @TotallyInformation suggests) then in your function, grab the charId from msg.chatId and populate your response.


[{"id":"3d5d9880.e11038","type":"telegram command","z":"5d3f964c.fef898","name":"","command":"/y","bot":"fa7a9376.321ce","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":450,"y":380,"wires":[["e5baa3b0.84538"]]},{"id":"e5baa3b0.84538","type":"change","z":"5d3f964c.fef898","name":"","rules":[{"t":"set","p":"chatId","pt":"msg","to":"payload.chatId","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":380,"wires":[["8580dadc.5a7078"]]},{"id":"8580dadc.5a7078","type":"http request","z":"5d3f964c.fef898","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":790,"y":380,"wires":[["bbb44e07.16ebd"]]},{"id":"bbb44e07.16ebd","type":"function","z":"5d3f964c.fef898","name":"Отправка папе","func":"var photo = msg.payload\nmsg.payload=\n{content:photo,\nchatId: msg.chatId,\ntype:'photo'}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":380,"wires":[["439b50fc.1c1ad"]]},{"id":"439b50fc.1c1ad","type":"telegram sender","z":"5d3f964c.fef898","name":"Majordomo_88","bot":"fa7a9376.321ce","haserroroutput":false,"outputs":1,"x":1140,"y":380,"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}]

Node http request returns the photo in binary. I don't know how to add a load with chatid to this.

You can attach any value you want to a msg object. Just because the http node returns a binary value in msg.payload doesnt mean you cannot store other stuff in other parts of the msg. for example, the flow demo i posted does just that,

telegram node --> copy msg.payload.chatId to msg.chatId --> do HTTP Req --> grab the chatId from msg.chatId --> send telegram reply with binary image

Thank you! I tried this, but I didn't connect correctly. Tried to use flow.chatId and store the chatid in a variable ... but it didn't work. You did the right thing.

Thanks again. My native language is Russian, and I'm not a programmer at all. so it's hard for me to figure it out. But you explained very clearly. I think this has resolved my question.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.