# How to edit a function node for telegram

**URL:** <https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870>\
**Category:** General\
**Tags:** function-node\
**Created:** [8 December 2022 15:24 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870 "2022-12-08T15:24:23Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [8 December 2022 15:24 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/1 "2022-12-08T15:24:23Z")

</div>

Hello, I'm fighting for weeks and I did find no solution since my Java script knowledge is less than basic. 🤯  
I collect 2 temperature values via the serial port. I'm able to get the first on-demand via telegram. Could someone suggest how to modify the function node so I can collect 2 values with the proper topic?  
I tried some different msg types without results.

 ![ksnip_20221208-160340](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f96e8714bc4678961396d9ac97b1b0e53fcba4b6.png)  
My flow

```auto
[{"id":"6ecd5ed5.624c9","type":"debug","z":"d93d62e5.76b86","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":832,"y":336,"wires":[]},{"id":"369ae647.d181ca","type":"telegram command","z":"d93d62e5.76b86","d":true,"name":"","command":"Temp","bot":"5896bb49.2b8254","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":122,"y":304,"wires":[["38109f52.30921"],[]]},{"id":"a398b1de.00022","type":"function","z":"d93d62e5.76b86","name":"","func":"//var msg5 = msg.payload.col7;\n//var msg2 = msg.payload;\n//var msg3 = \"°C\";\n//var date = new Date(msg.payload4)\n//var msg4 = \"Temp Pannelli TK\";\n\n//var msg6 = \"°C\";\n\n//return [{payload:msg3+msg2+msg5}]\n//return msg;\nvar msg1 = \"TK - TEMP. PANNELLI, \";\nvar msg2 = msg.payload;\nvar msg3 = \" C°\";\n\nreturn [{payload:msg1+msg2+msg3}]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":492,"y":192,"wires":[["ee505d58.56427"]]},{"id":"e1ea84e9.ef4928","type":"telegram sender","z":"d93d62e5.76b86","d":true,"name":"","bot":"5896bb49.2b8254","haserroroutput":true,"outputs":2,"x":962,"y":204,"wires":[[],[]]},{"id":"ee505d58.56427","type":"function","z":"d93d62e5.76b86","name":"","func":"var msg1 = msg.payload;\nmsg.payload = {}\n\nmsg.payload.chatId = \"my chat ID\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":684,"y":256,"wires":[["6ecd5ed5.624c9","e1ea84e9.ef4928"]]},{"id":"47b01090.cded7","type":"link in","z":"d93d62e5.76b86","d":true,"name":"","links":["fd34e4cb.408068"],"x":79,"y":208,"wires":[["d71496fe.120b08"]]},{"id":"d71496fe.120b08","type":"trigger","z":"d93d62e5.76b86","name":"","op1":"","op2":"","op1type":"pay","op2type":"pay","duration":"0","extend":false,"overrideDelay":false,"units":"hr","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":272,"y":208,"wires":[["a398b1de.00022"]]},{"id":"38109f52.30921","type":"change","z":"d93d62e5.76b86","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":292,"y":304,"wires":[["d71496fe.120b08"]]},{"id":"5aa9bb6c.00e0d4","type":"ui_button","z":"d93d62e5.76b86","name":"","group":"2e0e750e.824afa","order":28,"width":2,"height":2,"passthru":false,"label":"Temp","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":130,"y":384,"wires":[["38109f52.30921"]]},{"id":"5896bb49.2b8254","type":"telegram bot","botname":"Chris100_bot","usernames":"","chatids":"mychatID","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"2e0e750e.824afa","type":"ui_group","name":"Rotex ","tab":"ebb1ed1c.5ebe2","order":1,"disp":true,"width":"28","collapse":true},{"id":"ebb1ed1c.5ebe2","type":"ui_tab","name":"CBU Power Plant","icon":"Comandi ","order":1,"disabled":false,"hidden":false}]

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [9 December 2022 06:29 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/2 "2022-12-09T06:29:48Z")

</div>

Did you try `Join` Node ?  
set different topic for different incoming message and use a key/value object with manual mode in join node. change the below example suitably

```auto
[{"id":"42020feb6695b1f5","type":"join","z":"c683350141044a66","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":330,"y":660,"wires":[["39a65ddc9b3587e7","1bb525368eaffa3b"]]},{"id":"490d038b2e8d5df1","type":"inject","z":"c683350141044a66","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"one","payload":"50","payloadType":"num","x":170,"y":660,"wires":[["42020feb6695b1f5"]]},{"id":"7d36124aa6abea62","type":"inject","z":"c683350141044a66","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"two","payload":"100","payloadType":"num","x":170,"y":700,"wires":[["42020feb6695b1f5"]]},{"id":"39a65ddc9b3587e7","type":"function","z":"c683350141044a66","name":"","func":"//var msg5 = msg.payload.col7;\n//var msg2 = msg.payload;\n//var msg3 = \"°C\";\n//var date = new Date(msg.payload4)\n//var msg4 = \"Temp Pannelli TK\";\n\n//var msg6 = \"°C\";\n\n//return [{payload:msg3+msg2+msg5}]\n//return msg;\nvar msg1 = \"TK - TEMP. PANNELLI, \";\nvar msg2 = msg.payload.one;\nvar msg3 = msg.payload.two;\nvar msg4 = \" C°\";\n\nreturn [{ payload: msg1 + msg2 + msg4 + msg3 + msg4}]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":660,"wires":[["3481995455469888"]]},{"id":"1bb525368eaffa3b","type":"debug","z":"c683350141044a66","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":620,"wires":[]},{"id":"3481995455469888","type":"function","z":"c683350141044a66","name":"","func":"var msg1 = msg.payload;\nmsg.payload = {}\n\nmsg.payload.chatId = \"my chat id\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":660,"wires":[["a006d4a78bc1daf8"]]},{"id":"a006d4a78bc1daf8","type":"debug","z":"c683350141044a66","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":820,"y":660,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [10 December 2022 10:03 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/3 "2022-12-10T10:03:10Z")

</div>

Hello, as per the screenshot the join node was already used, how to manage properly the function is my issue. The debug message shows twice undefined. Any idea why it happens?  
Thanks in advance

 ![Function node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c509d8d0226d4c715c20c6b80076563763084a7.png)

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [10 December 2022 10:08 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/4 "2022-12-10T10:08:13Z")

</div>

My flow modified based on your input.

```auto
[{"id":"b68e76c0.382808","type":"debug","z":"36ed6d21.1b3dd2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":848,"y":1056,"wires":[]},{"id":"6c43d1d9.40cbf","type":"debug","z":"36ed6d21.1b3dd2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":706,"y":912,"wires":[]},{"id":"ee8a8d5b.e33af","type":"telegram command","z":"36ed6d21.1b3dd2","name":"","command":"Out ","bot":"5896bb49.2b8254","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":138,"y":1024,"wires":[["f335ac61.ad7cf"],[]]},{"id":"58745bb9.1c1af4","type":"function","z":"36ed6d21.1b3dd2","d":true,"name":"","func":"//var msg5 = msg.payload.col7;\n//var msg2 = msg.payload;\n//var msg3 = \"°C\";\n//var date = new Date(msg.payload4)\n//var msg4 = \"Temp Pannelli TK\";\n\n//var msg6 = \"°C\";\n\n//return [{payload:msg3+msg2+msg5}]\n//return msg;\nvar msg1 = \"TK - TEMP. PANNELLI, \";\nvar msg2 = msg.payload;\nvar msg3 = \" C°\";\n\nreturn [{payload:msg1+msg2+msg3}]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":508,"y":912,"wires":[["f0c5b6c8.42a338"]]},{"id":"31fd57fd.c122c8","type":"telegram sender","z":"36ed6d21.1b3dd2","name":"","bot":"5896bb49.2b8254","haserroroutput":true,"outputs":2,"x":978,"y":924,"wires":[[],[]]},{"id":"f0c5b6c8.42a338","type":"function","z":"36ed6d21.1b3dd2","name":"","func":"var msg1 = msg.payload;\nmsg.payload = {}\n\nmsg.payload.chatId = \"Mychatid\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":700,"y":976,"wires":[["b68e76c0.382808","31fd57fd.c122c8"]]},{"id":"db7cc7da.d53ba8","type":"link in","z":"36ed6d21.1b3dd2","name":"","links":["14a6d8ae.670447","5ad2676f.a540a8","fd34e4cb.408068"],"x":95,"y":928,"wires":[["41a19a93.9a0a54"]]},{"id":"41a19a93.9a0a54","type":"trigger","z":"36ed6d21.1b3dd2","name":"","op1":"","op2":"","op1type":"pay","op2type":"pay","duration":"0","extend":false,"overrideDelay":false,"units":"hr","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":288,"y":928,"wires":[["58745bb9.1c1af4","a3e6976a.bee078"]]},{"id":"f335ac61.ad7cf","type":"change","z":"36ed6d21.1b3dd2","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":308,"y":1024,"wires":[["41a19a93.9a0a54"]]},{"id":"87601bbb.6092d8","type":"ui_button","z":"36ed6d21.1b3dd2","name":"","group":"2e0e750e.824afa","order":28,"width":2,"height":2,"passthru":false,"label":"Temp","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":146,"y":1104,"wires":[["f335ac61.ad7cf"]]},{"id":"a3e6976a.bee078","type":"function","z":"36ed6d21.1b3dd2","name":"","func":"//var msg5 = msg.payload.col7;\n//var msg2 = msg.payload;\n//var msg3 = \"°C\";\n//var date = new Date(msg.payload4)\n//var msg4 = \"Temp Pannelli TK\";\n\n//return [{payload:msg3+msg2+msg5}]\n//return msg;\nvar msg1 =\"TK - TEMP. PANNELLI, \";\n \nvar msg2 = msg.payload.one;\nvar msg3 = msg.payload.two;\nvar msg4 = \" C°\";\n\nreturn [{ payload: msg1 + msg2 + msg4 + msg3 + msg4}]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":524,"y":976,"wires":[["f0c5b6c8.42a338","6c43d1d9.40cbf"]]},{"id":"5896bb49.2b8254","type":"telegram bot","botname":"Chris100_bot","usernames":"","chatids":"mychatID","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"2e0e750e.824afa","type":"ui_group","name":"Rotex ","tab":"ebb1ed1c.5ebe2","order":1,"disp":true,"width":"28","collapse":true},{"id":"ebb1ed1c.5ebe2","type":"ui_tab","name":"CBU Power Plant","icon":"Comandi ","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [10 December 2022 10:23 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/5 "2022-12-10T10:23:40Z")

</div>

can you show how the join node is configured ?

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [10 December 2022 10:24 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/6 "2022-12-10T10:24:22Z")

</div>

there is no join node in this flow

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [10 December 2022 12:30 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/7 "2022-12-10T12:30:18Z")

</div>

I guess this is the same as per your input.

```auto
[{"id":"51ce77ef.3124a8","type":"join","z":"36ed6d21.1b3dd2","g":"8d8afaec.d3a588","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":576,"wires":[["1ec2ac68.098584"]]},{"id":"1ec2ac68.098584","type":"debug","z":"36ed6d21.1b3dd2","g":"8d8afaec.d3a588","name":"","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":304,"y":672,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [12 December 2022 07:07 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/8 "2022-12-12T07:07:31Z")

</div>

did you solve the issue ?

your shared flow doesnot have the join node, so i cannot see how the join node is configured.

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [12 December 2022 08:22 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/9 "2022-12-12T08:22:48Z")

</div>

Hello, I'm not able to import the complete flow, the join node only has been uploaded in the flow above.

 ![Inkedjoin node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c9e8d1ca914074b37b0a1b77f307df9774da1bfe.jpeg)

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [12 December 2022 08:37 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/11 "2022-12-12T08:37:36Z")

</div>

what are the inputs to the join node ? i can see only one connection into the join node

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [12 December 2022 08:56 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/12 "2022-12-12T08:56:04Z")

</div>

Currently, it is connected to numbers, but I have also converted as an object.  
I'm able to send only one number, not two.  
For this reason, I think the problem is in the function node.

 ![Inkedjoin node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6da2a6ca6c04f61ffdfa13e8688270af901e835c.jpeg)

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [12 December 2022 09:13 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/13 "2022-12-12T09:13:03Z")

</div>

I am sorry, this is beyond my comprehension, i will let experts pitch in. thanks

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 December 2022 11:06 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/14 "2022-12-12T11:06:16Z")

</div>

@298christian Let's start over.

1. in you first post you provide your flow but it does not show the serial port node.
2. please put a `debug` node on the output of the `serial port` node and copy/paste`*` (see below) the results to show what the data actually is
3. which `function` node are you talking about? It is a good idea to name your nodes so you can easily refer to them.
4. Show us what you want the combined data to look like.
5. are the temperature values you collect in the same msg or different msgs?

Let's see if I can help you with this. Also, if you haven't yet, you should watch this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

* * *

`*` There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

* * *

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [12 December 2022 12:13 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/15 "2022-12-12T12:13:59Z")

</div>

The target was to send two temperature values via telegram. I'm able to send only one if it is a number. I guess that by managing the two numbers as objects, I may add more information easily.

 ![Temp telegram](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/9/e9079bb4889292eb37ec471d63f4e6736c51615c.jpeg)  
Debug serial node  
payload  
0;0;88;0;34;26;32;29;2,6;;736  
Below is my target, to send these two values and descriptions via telegram  
payload  
_ **{"TK - Temp. Pannelli":35,"TS - Temp. bollitore":32}** _  
 ![My flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd3629904c400ef529e47f22cd0094141967de6d.jpeg)

Find below the called "Change topic" node in the picture.

```auto
[{"id":"86863cfc.e02b2","type":"change","z":"36ed6d21.1b3dd2","g":"8d8afaec.d3a588","name":"Change description","rules":[{"t":"set","p":"paylod.col5","pt":"msg","to":"TK-Temp. Pannelli","tot":"msg"},{"t":"set","p":"payload.col7","pt":"msg","to":"TS-Temp. Bollitore","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":378,"y":624,"wires":[["fd34e4cb.408068","1ec2ac68.098584"]]}]

```

```auto
[{"id":"b68e76c0.382808","type":"debug","z":"36ed6d21.1b3dd2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":848,"y":1056,"wires":[]},{"id":"6c43d1d9.40cbf","type":"debug","z":"36ed6d21.1b3dd2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":706,"y":912,"wires":[]},{"id":"ee8a8d5b.e33af","type":"telegram command","z":"36ed6d21.1b3dd2","name":"","command":"temp","bot":"5896bb49.2b8254","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":138,"y":1024,"wires":[["f335ac61.ad7cf"],[]]},{"id":"31fd57fd.c122c8","type":"telegram sender","z":"36ed6d21.1b3dd2","name":"","bot":"5896bb49.2b8254","haserroroutput":true,"outputs":2,"x":978,"y":924,"wires":[[],[]]},{"id":"f0c5b6c8.42a338","type":"function","z":"36ed6d21.1b3dd2","name":"chat Id","func":"var msg1 = msg.payload;\nmsg.payload = {}\n\nmsg.payload.chatId = \"myIDchat\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":976,"wires":[["b68e76c0.382808","31fd57fd.c122c8"]]},{"id":"db7cc7da.d53ba8","type":"link in","z":"36ed6d21.1b3dd2","name":"","links":["14a6d8ae.670447","5ad2676f.a540a8","fd34e4cb.408068"],"x":95,"y":928,"wires":[["41a19a93.9a0a54"]]},{"id":"41a19a93.9a0a54","type":"trigger","z":"36ed6d21.1b3dd2","name":"","op1":"","op2":"","op1type":"pay","op2type":"pay","duration":"0","extend":false,"overrideDelay":false,"units":"hr","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":288,"y":928,"wires":[["a3e6976a.bee078"]]},{"id":"f335ac61.ad7cf","type":"change","z":"36ed6d21.1b3dd2","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":308,"y":1024,"wires":[["41a19a93.9a0a54"]]},{"id":"87601bbb.6092d8","type":"ui_button","z":"36ed6d21.1b3dd2","name":"","group":"2e0e750e.824afa","order":28,"width":2,"height":2,"passthru":false,"label":"Temp","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":146,"y":1104,"wires":[["f335ac61.ad7cf"]]},{"id":"a3e6976a.bee078","type":"function","z":"36ed6d21.1b3dd2","name":"Temperature","func":"//var msg5 = msg.payload.col7;\n//var msg2 = msg.payload;\n//var msg3 = \"°C\";\n//var date = new Date(msg.payload4)\n//var msg4 = \"Temp Pannelli TK\";\n\n//return [{payload:msg3+msg2+msg5}]\n//return msg;\nvar msg1 =\"TK - Temp. Pannelli, \";\n//var msg2 =\"TS - Temp. bollitore, \"; \nvar msg3 = msg.payload.one;\nvar msg4 = msg.payload.two;\nvar msg5 = \" C°\";\n\nreturn [{ payload: msg1 + msg4 + msg3 + msg4 + msg5}]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":534,"y":976,"wires":[["f0c5b6c8.42a338","6c43d1d9.40cbf"]]},{"id":"5896bb49.2b8254","type":"telegram bot","botname":"Chris100_bot","usernames":"","chatids":"mychatID","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"2e0e750e.824afa","type":"ui_group","name":"Rotex ","tab":"ebb1ed1c.5ebe2","order":1,"disp":true,"width":"28","collapse":true},{"id":"ebb1ed1c.5ebe2","type":"ui_tab","name":"CBU Power Plant","icon":"Comandi ","order":1,"disabled":false,"hidden":false}]

```

I don't know how to manage the function node called Temperature, I think that it could solve everything. I did not find any other solution. I hope to have clarify better now.  
Thanks in advance for your efforts.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [12 December 2022 12:53 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/17 "2022-12-12T12:53:31Z")

</div>

The "Change topic" node that you posted above can't be the one in your screen capture since it is invalid. You have a space between **TK-Temp.** and **Pannelli**

Looking at the screen capture I assume that your "Change topic" node outputs

```auto
{
"TK - Temp. Pannelli":52,
"TS - Temp. bollitore":32
}

```

But your "Temperature" node contains

```auto
var msg1 ="TK - Temp. Pannelli, ";
//var msg2 ="TS - Temp. bollitore, ";   
var msg3 = msg.payload.one;
var msg4 = msg.payload.two;
var msg5 = " C°";

return [{ payload: msg1 + msg4 + msg3 + msg4 + msg5}]

```

- You have msg.payload["TK - Temp. Pannelli"] and msg.payload["TS - Temp. bollitore"] but you are trying to concatenate msg.payload.one and msg.payload.two.

I think you are making life unnecessarily difficult by having spaces and dots in element names.  
Your msg1 through to msg5 are confusing to me since they are simple (and unnecessary) variables, not messages.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 December 2022 14:10 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/18 "2022-12-12T14:10:16Z")

</div>

In addition to what @jbudd has poined out, your change node has an error  
 ![Screen Shot 2022-12-12 at 9.08.26 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/25cfcc448d12975906a47461e3376a6596b15d2c.png)

in the first rule you are setting msg.paylod.col5 - you want msg.payload.col5

---

<div class="post-metadata">

**Author:** ![298christian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/298christian/32/33883_2.png) [@298christian](https://discourse.nodered.org/u/298christian)\
**Post date:** [13 December 2022 15:59 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/19 "2022-12-13T15:59:31Z")

</div>

Hello, finally I reached my goal as per the telegram picture.  
I didn't notice some errors pointed out by other members, normally the errors have the red triangle on the top.  
I have modified the function node as follows and it works well.  
On the debug you can see the input and the output of function nodes.

```auto
[{"id":"b68e76c0.382808","type":"debug","z":"36ed6d21.1b3dd2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":848,"y":1056,"wires":[]},{"id":"6c43d1d9.40cbf","type":"debug","z":"36ed6d21.1b3dd2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":578,"y":1056,"wires":[]},{"id":"31fd57fd.c122c8","type":"telegram sender","z":"36ed6d21.1b3dd2","name":"","bot":"ed491692.79e3f8","haserroroutput":true,"outputs":2,"x":978,"y":924,"wires":[[],[]]},{"id":"f0c5b6c8.42a338","type":"function","z":"36ed6d21.1b3dd2","name":"chat Id","func":"var msg1 = msg.payload;\nmsg.payload = {}\n\nmsg.payload.chatId = \"xxxxx\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":976,"wires":[["b68e76c0.382808","31fd57fd.c122c8"]]},{"id":"db7cc7da.d53ba8","type":"link in","z":"36ed6d21.1b3dd2","name":"","links":["14a6d8ae.670447","5ad2676f.a540a8","fd34e4cb.408068"],"x":95,"y":928,"wires":[["41a19a93.9a0a54"]]},{"id":"41a19a93.9a0a54","type":"trigger","z":"36ed6d21.1b3dd2","name":"","op1":"","op2":"","op1type":"pay","op2type":"pay","duration":"0","extend":false,"overrideDelay":false,"units":"hr","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":288,"y":928,"wires":[["a3e6976a.bee078"]]},{"id":"f335ac61.ad7cf","type":"change","z":"36ed6d21.1b3dd2","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":308,"y":1024,"wires":[["41a19a93.9a0a54"]]},{"id":"87601bbb.6092d8","type":"ui_button","z":"36ed6d21.1b3dd2","name":"","group":"2e0e750e.824afa","order":28,"width":2,"height":2,"passthru":false,"label":"Temp","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":146,"y":1104,"wires":[["f335ac61.ad7cf"]]},{"id":"a3e6976a.bee078","type":"function","z":"36ed6d21.1b3dd2","name":"Temperature","func":"\n//var msg2 = msg.payload.one;\n//var msg3 = msg.payload.two;\n//var msg4 = \" C°\";\n\n//return [{ payload: msg1 + msg3 }]\n//return msg;\n\n//copy in the description\n\nvar msg1 =\"TK-Pannelli, \";\nvar msg2 = msg.payload.col5;\nvar msg3 = \"C°\"\nvar msg4 = \"TS-Bollitore, \";\nvar msg5 = msg.payload.col7;\nvar msg6 = \"C°\";\nreturn [{ payload: msg1 + msg2 + msg3 + msg4 + msg5 + msg6 }]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":534,"y":976,"wires":[["f0c5b6c8.42a338","6c43d1d9.40cbf"]],"info":"var msg1 =\"TKTemp Pannelli, \";\nvar msg2 = msg.payload.col5;\nvar msg3 = \"TSTemp Bollitore, \";\nvar msg4 = msg.payload.col7;\nvar msg5 = \"C°\";\nreturn [{ payload: msg1 + msg2 + msg3 + msg4 + msg5 }]\nreturn msg;"},{"id":"3ebda4b3.bf841c","type":"telegram command","z":"36ed6d21.1b3dd2","name":"","command":"temp","bot":"ed491692.79e3f8","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":98,"y":1008,"wires":[["f335ac61.ad7cf"],[]]},{"id":"ed491692.79e3f8","type":"telegram bot","botname":"Chris100_bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"2e0e750e.824afa","type":"ui_group","name":"Rotex ","tab":"ebb1ed1c.5ebe2","order":1,"disp":true,"width":"28","collapse":true},{"id":"ebb1ed1c.5ebe2","type":"ui_tab","name":"CBU Power Plant","icon":"Comandi ","order":1,"disabled":false,"hidden":false}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c02585eee97125e39d4211da850683ae65334fce.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef4d35e28dd213ecd4ca4d8fc57f372ad2ff7a48.png)

Many thanks all for the tips.

---

<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:** [13 December 2022 16:57 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/20 "2022-12-13T16:57:32Z")

</div>

Glad to hear you got your flow working.

---

<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:** [11 February 2023 16:57 UTC](https://discourse.nodered.org/t/how-to-edit-a-function-node-for-telegram/71870/21 "2023-02-11T16:57:32Z")

</div>

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