Execute only once on telegram bot

Hello everyone, I'm totally new to Node-RED (5 days)
How can i only execute 1 command when everytime I call my telegram bot?
by the way this is my flow, suggestions welcome :smiley:

and i want to ask one more thing, what can I do to remove the "undefined" thing when I called the telegram


[{"id":"569cdb27f329ea92","type":"tab","label":"FINALE","disabled":false,"info":"","env":[]},{"id":"25baba9fb0f5a5ea","type":"mqtt in","z":"569cdb27f329ea92","name":"acVolt","topic":"bts/noc/ac/acVolt","qos":"2","datatype":"json","broker":"ab5d3aec78c4252c","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":180,"wires":[["fd7d36364496112b"]]},{"id":"fd7d36364496112b","type":"function","z":"569cdb27f329ea92","name":"","func":"msg.nocav = msg.payload\nmsg.payload = msg.nocav\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":180,"wires":[["95e0c68effc44ed9"]]},{"id":"797f30155666dbb3","type":"debug","z":"569cdb27f329ea92","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":200,"wires":[]},{"id":"e089098f482382e5","type":"mqtt in","z":"569cdb27f329ea92","name":"acCurrent","topic":"bts/noc/ac/acCurrent","qos":"2","datatype":"json","broker":"ab5d3aec78c4252c","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":260,"wires":[["04489801898c80b4"]]},{"id":"1ec9d39c7133849f","type":"mqtt in","z":"569cdb27f329ea92","name":"acEnergy","topic":"bts/noc/ac/acEnergy","qos":"2","datatype":"json","broker":"ab5d3aec78c4252c","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":420,"wires":[["531f8de7d2a1322d"]]},{"id":"9a81b7f7ea9b265d","type":"mqtt in","z":"569cdb27f329ea92","name":"acPower","topic":"bts/noc/ac/acPower","qos":"2","datatype":"json","broker":"ab5d3aec78c4252c","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":340,"wires":[["cdf02351be96c6f3"]]},{"id":"dd04cb76f9acceac","type":"mqtt in","z":"569cdb27f329ea92","name":"acFreq","topic":"bts/noc/ac/acFreq","qos":"2","datatype":"json","broker":"ab5d3aec78c4252c","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":500,"wires":[["765c7f7d9dc8a89e"]]},{"id":"837f9501c81c1eb2","type":"mqtt in","z":"569cdb27f329ea92","name":"acPf","topic":"bts/noc/ac/acPf","qos":"2","datatype":"json","broker":"ab5d3aec78c4252c","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":580,"wires":[["bd0a9512f937a30b"]]},{"id":"04489801898c80b4","type":"function","z":"569cdb27f329ea92","name":"","func":"msg.nocaccurrent = msg.payload\n\nmsg.payload = msg.nocaccurrent\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":260,"wires":[["95e0c68effc44ed9"]]},{"id":"cdf02351be96c6f3","type":"function","z":"569cdb27f329ea92","name":"","func":"msg.nocaccurrent = msg.payload\n\nmsg.payload = msg.nocaccurrent\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":340,"wires":[["95e0c68effc44ed9"]]},{"id":"531f8de7d2a1322d","type":"function","z":"569cdb27f329ea92","name":"","func":"msg.nocaccurrent = msg.payload\n\nmsg.payload = msg.nocaccurrent\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":420,"wires":[["95e0c68effc44ed9"]]},{"id":"765c7f7d9dc8a89e","type":"function","z":"569cdb27f329ea92","name":"","func":"msg.nocaccurrent = msg.payload\n\nmsg.payload = msg.nocaccurrent\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":500,"wires":[["95e0c68effc44ed9"]]},{"id":"bd0a9512f937a30b","type":"function","z":"569cdb27f329ea92","name":"","func":"msg.nocaccurrent = msg.payload\nmsg.payload = msg.nocaccurrent\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":580,"wires":[["95e0c68effc44ed9"]]},{"id":"95e0c68effc44ed9","type":"function","z":"569cdb27f329ea92","name":"","func":"let test1 = \"Power Details\\r\\n\"\ntest1 += \"Current Volt: \" + msg.nocav\ntest1 += \"\\r\\n\"\ntest1 += \"Current Volt: \" + msg.nocaccurrent\ntest1 += \"\\r\\n\"\ntest1 += \"Current Volt: \" + msg.nocacpower\ntest1 += \"\\r\\n\"\n    \nmsg.payload = test1;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":380,"wires":[["797f30155666dbb3","8b43c6ebcbd3f2b5"]]},{"id":"101f44abc2cd3a33","type":"telegram command","z":"569cdb27f329ea92","name":"","command":"/test","description":"","registercommand":false,"language":"","scope":"default","bot":"fc62e3f73418bc8d","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":290,"y":100,"wires":[["95e0c68effc44ed9"]]},{"id":"8b43c6ebcbd3f2b5","type":"telegrambot-notify","z":"569cdb27f329ea92","name":"","bot":"e4207fff45b6f8d3","chatId":"","message":"","parseMode":"","x":850,"y":480,"wires":[]},{"id":"ab5d3aec78c4252c","type":"mqtt-broker","name":"BTS","broker":"","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"1","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"fc62e3f73418bc8d","type":"telegram bot","botname":"Bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"1500","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"e4207fff45b6f8d3","type":"telegrambot-config","botname":"Bot","usernames":"","chatIds":"","pollInterval":"300"}]

Your flow confuses me.

  1. The function node connected to each mqtt-in node are doing the same thing. Why?
  2. What do you except the msg coming from the telegram-in is going to cause the function node to do?

each msg going into a node will be processed with only the data it contains (with the exception of contect data).

you need to join the various inputs together and this might help you understand how to do that so see this article in the cookbook for an example of how to join messages into one object.

In addition, I recommend watching this playlist: Node-RED Essentials. 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.

1 Like

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