Node-red and Telegram: msg.payload.content is empty

I want to send values to Telegram. But, When I run node-red, it shows the error "msg.payload.content is empty". Do you know how to overcome it??


In the "Change" change node, you are moving from content to topic, which means that basically you are emptying the content. Unless you set a new content in F1, that part of the message will be empty.

Try using SET instead of MOVE in the "Change" change node and see if the issue is solved. That will basically copy the value from msg.payload.content to msg.payload.topic, but won't delete the msg.payload.content.

As for the "Move" change nodes, what's the data type of the original msg.payload? If it's not an object, doing it like this may cause problems. If it is an object, you're nesting the object inside itself. Since you have a function node immediately before and after the change node, I'd do any changes in the previous "function" function node instead, which will remove the need for the change node.

I changed from MOVE to SET, but Telegram doesn't work. and It shows an error happened to the F3 node

Initially, my purpose is when I'm typing the keywords like "Nhiệt độ" "Tốc độ" or other figures... Telegram will send data of these keywords.

Just an observation... is that your real 'chatId' ??
If it is I suggest you edit your posts otherwise you could receive loads of "spam".

Oh, yes. This telegram needs 'chatId' address

I realise Telegram needs a 'chatId' - but you shouldn't use your real chatId on an open forum.

Oh, I forget about that. Thanks for your suggest

Can your nodes F3 or F1 send a message to Telegram or is it just F2 that is misbehaving?

What happens if you use a simple flow like this in a function node?

let cId = global.get("my_chatId");  // Use a global variable or enter your chatId here

msg.payload = { chatId: cId, type:"message", content:"hello from node F2"};

return msg;

oh, thanks.
I will remember for your suggest.
Currently, I just want fix this error on the top.

You didn't answer whether the simple flow (I suggested) worked with Telegram.

OK - to help speed things up... would it be possible for you to post your flow (without your real 'chatId') as we could then see what is happening in the various function node?

Just a thought... what are the two green/blue colored nodes at the far left of your flow.

Are your keywords arriving at one node and the data at the other??
If so - then your flow isn't going to work (it will need a Join node).

Oh, this is S7 node, use to display data from PLC.
Initially, I send successfully data from PLC to Telegram. (photo1)
when I'm typing keywords, telegram will send the name keyword and data. But it shows undefined (photo2)

Join node?, I don't really understand.
Can you speak detail.

If you're getting the msg.payload.content is empty error message it means that when the message arrives to the telegram node msg.payload is empty.

You need to assign = [YourChatId] and msg.payload = [value]

Check with a debug node what information arrives at the telegram node

Can I suggest...

(A) You post your flow by exporting it (not a screenshot) so people can see what is inside your function nodes and help you get it working. Here's a link that explains how to export a flow to the forum.

(B) Put a debug node on the output of S7 nodes and show a typical output.

I'm still not sure what you are trying to achieve with the two S7 nodes.
Are they working independently of each other?
Or do they rely on the two inputs?
You have two "flows" which seems to indicate the two S7 nodes are NOT related.

I tried a lot, but it doesn't working

(B) actually, I just want to try many ways related with datas of PLC. I just want to intervene it to display data that I want when I am typing.

What exactly doesn't work? Can you send a simple message via Telegram?