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

**URL:** <https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998>\
**Category:** General\
**Tags:** node-red-dashboard, telegram\
**Created:** [4 August 2022 06:08 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998 "2022-08-04T06:08:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 06:08 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/1 "2022-08-04T06:08:51Z")

</div>

Hi,  
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??

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/550e282a1e57a4b081c6d46ac2d188914bd51bb6.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36ec79295724b90c97356c95ef9ae681ea4d791f.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/48185a8606377e2e1210085fe4c41e399c97f1ad.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/2/d25d1d1d970d3150b1efe160dc4b7b8fab67df9e.png)

---

<div class="post-metadata">

**Author:** ![OriolFM](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oriolfm/32/30710_2.png) [@OriolFM](https://discourse.nodered.org/u/OriolFM)\
**Post date:** [4 August 2022 06:34 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/2 "2022-08-04T06:34:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 07:26 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/3 "2022-08-04T07:26:39Z")

</div>

Hi,  
I changed from MOVE to SET, but Telegram doesn't work. and It shows an error happened to the F3 node  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5be801aed077299d456c33e43ade6b5af4216c35.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/00123a0cac55ead67c6bfa479376d3c0472d2354.png)

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 07:30 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/4 "2022-08-04T07:30:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [4 August 2022 07:35 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/5 "2022-08-04T07:35:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 07:39 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/6 "2022-08-04T07:39:04Z")

</div>

Oh, yes. This telegram needs 'chatId' address

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [4 August 2022 07:41 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/7 "2022-08-04T07:41:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 07:50 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/8 "2022-08-04T07:50:04Z")

</div>

Oh, I forget about that. Thanks for your suggest

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [4 August 2022 07:58 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/10 "2022-08-04T07:58:59Z")

</div>

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?

```auto
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;

```

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 08:30 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/11 "2022-08-04T08:30:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [4 August 2022 08:37 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/12 "2022-08-04T08:37:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [4 August 2022 08:53 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/13 "2022-08-04T08:53:52Z")

</div>

Just a thought... what are the two green/blue colored nodes at the far left of your flow.  
 ![two_green](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a12972b228ad3392ae672cdb5651b44136ea7612.png)

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).

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [4 August 2022 09:07 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/14 "2022-08-04T09:07:58Z")

</div>

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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c57dd875e6d7f5ed807e8f60c583aa4562727b6.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5cb1dfca3537724bc95e2d70e8a7cb569526b0b0.jpeg)

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [7 August 2022 09:43 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/15 "2022-08-07T09:43:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DamianosS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damianoss/32/16990_2.png) [@DamianosS](https://discourse.nodered.org/u/DamianosS)\
**Post date:** [7 August 2022 13:51 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/16 "2022-08-07T13:51:44Z")

</div>

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 `msg.telegram.chat.id = [YourChatId]` and `msg.payload = [value]`

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

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [7 August 2022 16:55 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/17 "2022-08-07T16:55:49Z")

</div>

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.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

(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.

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [8 August 2022 11:48 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/18 "2022-08-08T11:48:23Z")

</div>

I tried a lot, but it doesn't working

---

<div class="post-metadata">

**Author:** ![thanhbinh](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@thanhbinh](https://discourse.nodered.org/u/thanhbinh)\
**Post date:** [8 August 2022 11:51 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/19 "2022-08-08T11:51:53Z")

</div>

(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.

---

<div class="post-metadata">

**Author:** ![DamianosS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damianoss/32/16990_2.png) [@DamianosS](https://discourse.nodered.org/u/DamianosS)\
**Post date:** [8 August 2022 18:58 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/20 "2022-08-08T18:58:11Z")

</div>

> [@thanhbinh](#):
>
> I tried a lot, but it doesn't working

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 October 2022 18:58 UTC](https://discourse.nodered.org/t/node-red-and-telegram-msg-payload-content-is-empty/65998/21 "2022-10-07T18:58:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
