windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
256 stars 116 forks source link

Send message to a thread (topic) #299

Closed dionelysterrero closed 1 year ago

dionelysterrero commented 1 year ago

Is there a way to send a message to a group thread? I currently have a group with different threads (General, Notifications, etc.) and I want to send messages to the notification thread from node red. How can I implement the payload in node red?

I currently have this configuration, but the message reaches me in the general thread image

windkh commented 1 year ago

@dionelysterrero I would say it should work if you set message_thread_id in the options of the message.
e.g. msg.payload.options = { "message_thread_id" : 247 } https://core.telegram.org/bots/api#sendmessage

LocalHappiness commented 1 year ago

I still can't get this to work using msg.payload.options it only goes to the general topic @windkh image

windkh commented 1 year ago

Something like this msg.payload = { chatId : - 1001950884149, type :"message', content : statusMessage, options : { "message_thread_id" : 3 } return msg;

windkh commented 1 year ago

@LocalHappiness did it work for you?

LocalHappiness commented 1 year ago

It worked perfectly! Thanks for the quick response in resolving my issue.

dionelysterrero commented 1 year ago

It worked perfectly! Thanks....

rozhkovets commented 9 months ago

For those who, like me, found this discussion and still did not immediately understand how to do this. I use "Change" node, select set payload.options.message_thread_id and set value thread id like number

Example for import to NodeRed, thread_id = 3 [{"id":"9ef478a08db0020e","type":"change","z":"010ef8baf06e3950","name":"Send_to_thread","rules":[{"t":"set","p":"payload.options.message_thread_id","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":160,"wires":[[]]}]

1

LocalHappiness commented 9 months ago

I use a function node: image

[{"id":"fda32729892e9e6a","type":"function","z":"7f5313cf.c1dd7c","name":"Test Message","func":"testMessage = \"Test message to topicID\"\n\nmsg.payload = {\nchatId : -1001950884149,\ntype :\"message\",\ncontent : testMessage,\noptions : { \"message_thread_id\" : 702 }\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1350,"y":1690,"wires":[["dd52de77d3ba07ee"]]}]