windkh / node-red-contrib-telegrambot

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

msg.payload.chatId lost if use some other nodes in the flow #210

Closed Cm-8 closed 3 years ago

Cm-8 commented 3 years ago

Congratulations for the great work done. I tried to search but couldn't find an answer to my problem.

When I include some other node (eg html) in a stream that starts with the "Telegram Event" node and ends with the "Telegram Sender" node, I lose the chatId.

The problem is that other nodes put their output in the msg.payload property, this means that all previous data saved on msg.payload is lost.

So the "Telegram Sender" node no longer works because it expects msg.payload.chatId to exist.

On my flow, the user who dispatches an event (e.g. / list), performs a get to a remote json and this parsed json must be sent to the user.

windkh commented 3 years ago

In this case you should store your payload into another variable for later usage. Before you call the node that discards payload you can add a function node which does that msg.chatId = msg.payload.chatId. And then in the node right before the sender you can take the chaId from msg.chatId.

Another way is to store the chatId in the flow context as described here https://stevesnoderedguide.com/node-red-variables