Hi !
I have some trouble creating "sub-keys" in msg.payload.
This is for telegram bot, I need:
msg.payload.content
msg.payload.chatId
msg.payload.type
I want to build the message in a function node.
Sometime using this is good enough:
msg.payload.type = "message";
But sometime is just says "msg.payload.type is empty" in debug window.
I found a workaround by creating the message this way:
msg = { payload: { chatId : 11111111111 , type : "message" , content : "Hello World" } };
(1111111111 is a dummy value)
But it's a bit "heavy" (in my opinion) sometime and I would prefer set the keys one by one, when I need.
The point is that I don't understand exactly what's the issue, so if I missed something simple, I would be happy to learn
If there's a better way to create sub-key of msg or msg.payload, I would be happy to know too
That's clarify the reason why my initial attempt to simply add msg.payload.type = ... (without msg.payload = {}; ) sometimes worked, sometimes not.
I assume it depends if the payload was already an object or not.
I think it's now very clear on how to manage msg.payload, thank you!
But I'm still not sure to understand how to add a key to the root msg without loosing other keys.
For example, how to properly add a non existing msg.limit to msg, without effect on msg.payload