windkh / node-red-contrib-telegrambot

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

Missing msg.payload.sentMessageId #256

Closed chrismox closed 2 years ago

chrismox commented 2 years ago

At some point in the last week (having not changed any of my Node-RED flows), I noticed some odd behaviour with my bot.

I have traced the issue to a node where I am trying to track a message ID with the following:

context.global.keyboard.messageId = msg.payload.sentMessageId;

Having debugged the Telegram receiver node output, msg.payload.sentMessageId isn't being sent.

Either I've found an issue or something has gone wrong with my bot.

windkh commented 2 years ago

So what was the output object then?

chrismox commented 2 years ago

{"payload":{"chatId":xxxxxxxxxx,"messageId":538,"type":"message","content":"hw","date":1656702633},"originalMessage":{"message_id":538,"from":{"id":xxxxxxxxxx,"is_bot":false,"first_name":"Chris","last_name":"xxxxx","language_code":"en"},"chat":{"id":xxxxxxxxxx,"first_name":"Chris","last_name":"xxxxx","type":"private"},"date":1656702633,"text":"hw"},"_msgid":"xxxxxxxxxxxxxxxx"}

chrismox commented 2 years ago

(I've removed personal info)

windkh commented 2 years ago

And that output was created by the sender node?

chrismox commented 2 years ago

No, the receiver mode.

windkh commented 2 years ago

Well the receiver does not have a sentMessageId property as it did not send but receive a message. Only the sender can tell you what messageId was sent

chrismox commented 2 years ago

Hmmm, odd. You obviously know this better than anyone, yet my flows worked fine last week and now they don't.

I'll investigate futher, but thanks a lot for your help.

chrismox commented 2 years ago

Sorry for taking your time before I had understood this correctly.

My function node contains the following: context.global.keyboard.messageId = msg.payload.sentMessageId; return msg;

It is connected to a sender node and that node does indeed output msg.payload.sentMessageId

For some reason, however, the fundtion node returns the error "TypeError: Cannot set property 'messageId' of undefined".

Why this worked before but no longer does is my problem, not an issue for you to spend time on.

Once again, thanks for your help and sorry for taking your time!

chrismox commented 2 years ago

For the benfit of anyone else coming across this, I had to change this:

context.global.keyboard.messageId = msg.payload.sentMessageId;

...to this:

context.global.messageId = msg.payload.sentMessageId;

For reasons I can't explain, this has fixed my issue.

windkh commented 2 years ago

…. Maybe it would help if you would paste your flow here so that the others can see what you intended to do….

chrismox commented 2 years ago

Sorry, I'd posted the flows but they contain personal info. I'll try to depersonalise them and add again.