Telegram Reply node is NOT working?

Hello node-red experts,

Greetings!!

I have been working on creating a telegram bot associated with node-red, which will ask user a series of questions and user need to respond them.

Now if you see I am expecting when a user replies to question: "Are you a new joinee?" then I have attached Telegram Reply node which should send reply back to next switch and accordingly next actions should happen. But Telegram Reply is NOT working. Even I have enabled traces(debug mode) to it but not getting any error in console from it.

I am a newbie in node-red and JS but tried my best to fix it here, any help will be highly appreciated.

Following is my current tried code:

[{"id":"f1ad7bfd5882cc1a","type":"tab","label":"test123456","disabled":false,"info":"","env":[]},{"id":"585d4255e238512f","type":"telegram receiver","z":"f1ad7bfd5882cc1a","name":"","bot":"6b031eeb3ef163ce","saveDataDir":"","filterCommands":false,"x":110,"y":40,"wires":[["8e4658e2b26d5bea"],[]]},{"id":"8e4658e2b26d5bea","type":"switch","z":"f1ad7bfd5882cc1a","name":"","property":"payload.content","propertyType":"msg","rules":[{"t":"regex","v":"^ *(hi|hello|hey|howdy) *$","vt":"str","case":true}],"checkall":"true","repair":false,"outputs":1,"x":110,"y":160,"wires":[["9a7653c6bb6d150d"]]},{"id":"9a7653c6bb6d150d","type":"function","z":"f1ad7bfd5882cc1a","name":"Welcome","func":"var helpMsg = \"/help - shows help\\n\\n\"\ncontext.set(\"chatId\", msg.payload.chatId)\nhelpMsg += \"/foo - opens a dialog\\n\\n\\n\"\nif (msg.payload.chatId === 7) {\n    helpMsg = \"R. Singh, Welcome sir!!!! \"\n}\nelse if (msg.payload.chatId === 12) {\n    helpMsg = \"Ki karda hai ghussuu :) :) :) \"\n}\nelse {\n    helpMsg += \"You are welcome in Singh's bot, \" + msg.originalMessage.from.username;\n}\nhelpMsg += \"Your chat id is: \" + msg.payload.chatId;\nmsg.payload.content = helpMsg;\nmsg.payload.sentMessageId  = msg.payload.chatId;\nmsg.payload.flag = msg.payload.chatId;\nconsole.log(msg + \"+++++++++++\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":160,"wires":[["386a0fe52619624b","133175beaeded35c","59b33f21f66de252"]]},{"id":"386a0fe52619624b","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":280,"y":120,"wires":[]},{"id":"bda0fc24c4a035fb","type":"function","z":"f1ad7bfd5882cc1a","name":"new joinee??","func":"/*function sleep(milliseconds) {\n    const date = Date.now();\n    let currentDate = null;\n    do {\n        currentDate = Date.now();\n    } while (currentDate - date < milliseconds);\n}\nsleep(1500);*/\nmsg.payload.type = 'message';\nmsg.payload.options = { reply_to_message_id: msg.payload.messageId };\nmsg.payload.content = \"Are you a new joinee?\";\nreturn [msg];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":60,"wires":[["6b03f5af1ec023a8","59b33f21f66de252"]]},{"id":"6b03f5af1ec023a8","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":20,"wires":[]},{"id":"133175beaeded35c","type":"delay","z":"f1ad7bfd5882cc1a","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":460,"y":60,"wires":[["bda0fc24c4a035fb"]]},{"id":"25f6f3f143492fac","type":"function","z":"f1ad7bfd5882cc1a","name":"confimed new joinee","func":"msg.payload.content = \"Good to know, welcome to company\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":380,"wires":[["fd4f421c85a6966e","c9265e97ac2d800d"]]},{"id":"fd4f421c85a6966e","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":340,"wires":[]},{"id":"bf0f82dd730d671d","type":"function","z":"f1ad7bfd5882cc1a","name":"not a new joinee","func":"msg.payload.content = \"NOTE: at this point only yes OR no answer is accepted.\\n SO please either enter yes OR no, Thank you!!\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":460,"wires":[["2c73336f9070571d","c9265e97ac2d800d"]]},{"id":"2c73336f9070571d","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":420,"wires":[]},{"id":"dbeb4a3eb521554a","type":"telegram reply","z":"f1ad7bfd5882cc1a","name":"","bot":"6b031eeb3ef163ce","x":400,"y":240,"wires":[["aa1e77582d99edcf","a4e4986658244af0"]]},{"id":"b36440cbecbdc934","type":"switch","z":"f1ad7bfd5882cc1a","name":"","property":"payload.content","propertyType":"msg","rules":[{"t":"regex","v":"^ *yes *$","vt":"str","case":true},{"t":"regex","v":"^ *no *$","vt":"str","case":true}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":420,"wires":[["25f6f3f143492fac","bf0f82dd730d671d"],[]]},{"id":"c9265e97ac2d800d","type":"telegram sender","z":"f1ad7bfd5882cc1a","name":"","bot":"6b031eeb3ef163ce","haserroroutput":false,"outputs":1,"x":730,"y":400,"wires":[["ac4b7e52eb3c80cb"]]},{"id":"ac4b7e52eb3c80cb","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 12","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":360,"wires":[]},{"id":"45c8e6fa42f6707b","type":"function","z":"f1ad7bfd5882cc1a","name":"function 3","func":"if (msg.payload.content === 'yes') {\n    console.log(\"I am in yes answer of user new joinee\");\n    return [ msg, null ];\n}\nelse {\n    return [ null, msg ];\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":120,"y":300,"wires":[["b36440cbecbdc934","5ebb90f9c18a7efd"]]},{"id":"5ebb90f9c18a7efd","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 13","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":120,"y":340,"wires":[]},{"id":"aa1e77582d99edcf","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 14","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":390,"y":280,"wires":[]},{"id":"59b33f21f66de252","type":"telegram sender","z":"f1ad7bfd5882cc1a","name":"","bot":"6b031eeb3ef163ce","haserroroutput":false,"outputs":1,"x":510,"y":140,"wires":[["50a1b5729a79d6f9"]]},{"id":"50a1b5729a79d6f9","type":"function","z":"f1ad7bfd5882cc1a","name":"function 4","func":"console.log(\"---------------------->>>>>>>\");\n\nlet content = msg.payload.content;\nlet chatId = msg.payload.chatId;\nlet sentMessageId = msg.payload.sentMessageId;\nlet type = msg.payload.type;\nlet messageId = msg.reply_to_message_id;\nlet replyTo = msg.payload.messageId;\n\nmsg.payload = {};\nmsg.payload.content = content;\nmsg.payload.chatId = chatId;\nmsg.payload.sentMessageId = sentMessageId;\nmsg.payload.type = type;\n\nconsole.log(\"payload =\" + msg.payload.content);\n\nreturn [ msg ] ; \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":200,"wires":[["dbeb4a3eb521554a","0bef13cf95e04ed1"]]},{"id":"0bef13cf95e04ed1","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 16","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":160,"wires":[]},{"id":"a4e4986658244af0","type":"function","z":"f1ad7bfd5882cc1a","name":"function 5","func":"console.log(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":300,"wires":[["ed75e9e6b836ca3a"]]},{"id":"ed75e9e6b836ca3a","type":"debug","z":"f1ad7bfd5882cc1a","name":"debug 19","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":260,"wires":[]},{"id":"6b031eeb3ef163ce","type":"telegram bot","botname":"sin17","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksprotocol":"socks5","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

Thanks,
Ravinder Singh

Is THIS thread related to the following thread you have posted on the forum?

If it is related, then people will be duplicating their effort in producing answers/suggestions for you.

Thabks @dynamicdave for your answer. It couldn't be said duplicate IMHO but it could be said related(because its same project with different question and node). I had asked about creating communication channel creation in previous one and got a nice JS answer. This is related to I am using Telegram Reply node which is NOT working, even I tried so many things go fix it(code is added in my question) thank you.

Have you tried the 'reply' example in the Help section (to see if that works)?

[{"id":"f0f40237.40f438","type":"function","z":"d82051b0efe978da","name":"create question","func":"msg.payload.type = 'message';\nmsg.payload.content = 'Really?';\nmsg.payload.options = {reply_to_message_id : msg.payload.messageId}\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":420,"wires":[["7705422f.822834"]]},{"id":"4c7274da.77331c","type":"telegram command","z":"d82051b0efe978da","name":"/foo","command":"/foo","bot":"d086776c.7de82","strict":false,"hasresponse":false,"outputs":2,"x":210,"y":420,"wires":[["f0f40237.40f438"],[]]},{"id":"7705422f.822834","type":"telegram sender","z":"d82051b0efe978da","name":"send question","bot":"d086776c.7de82","outputs":1,"x":610,"y":420,"wires":[["b84786d5.195848"]]},{"id":"b84786d5.195848","type":"telegram reply","z":"d82051b0efe978da","name":"get reply","bot":"d086776c.7de82","x":785,"y":420,"wires":[["29d8ebcb.f400fc"]]},{"id":"29d8ebcb.f400fc","type":"function","z":"d82051b0efe978da","name":"switch answer","func":"if(msg.payload.content === 'Yes')\n{\n    return [msg, null];   \n}\nelse\n{\n    return [null, msg];   \n}\n","outputs":"2","noerr":0,"initialize":"","finalize":"","x":957,"y":420,"wires":[["6a50edd.6235114"],["b599b2a2.4b0278"]]},{"id":"6a50edd.6235114","type":"debug","z":"d82051b0efe978da","name":"Yes","active":true,"console":"false","complete":"payload","x":1160,"y":400,"wires":[]},{"id":"b599b2a2.4b0278","type":"debug","z":"d82051b0efe978da","name":"No","active":true,"console":"false","complete":"payload","x":1160,"y":440,"wires":[]},{"id":"d086776c.7de82","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

Yes I tried that and its not working for me. Even in help section its mentioned about 3 parameters content the message contents, type the type of message contents and chatId the chatId number or an array of chatIds should be present and I tried to take care of them also. Since I am new so I am not sure if this is the right use of it or not. Thank you.

Oh - sorry to hear that.
I'm busy at the moment, but will try-out the 'reply' exg this evening and see if it works for me.
Nothing comes out of the 'reply' node.

1 Like

Are you saying that if you click on a message and reply to that message you do not get a output? Can you supply a short example of the node not working for you, as it seems to work fine for me.

1 Like

Thank you @E1cid for replying on this question. Yes after I put yes on answer from user where bot's question is: Are you a new joinee? it doesn't give me anything. With flow I have posted. Could you please confirm if posted flow in question is working for you? If yes then kindly do guide me how to troubleshoot this from my system, Thank you.

Just tried out the example flow for the 'reply' option. Doesn't work for me either.

1 Like

Posted flow is to big and i do not wish to enable all the nodes with my telegram config, It is best to supply the minimal flow that demonstrates your issue. Are you replying to specific message by clicking message and then hit reply and type message and hit return. Can i see a screen shot of the telegram message you send.

1 Like

Sure @E1cid let me quickly create a small snippet of it and get back here. Thank you.

Try the example flow I posted above - imported directly from the node's examples section.

Note: I'm using 'telegrambot' 14.3.0 which I know is not the latest version.

Tried it it is working for me it says "i received your message" after i send. 14.3.0 same as you

1 Like

Here is one more tried sample where I am trying to get response from Telegram Reply button. Sorry I tried to make it small, but basically want to get reply from bot and then move forward with other questions etc.

[{"id":"eb78505f9403d5f9","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"b3cd69470d9f11c1","type":"telegram sender","z":"eb78505f9403d5f9","name":"","bot":"6b031eeb3ef163ce","haserroroutput":false,"outputs":1,"x":470,"y":40,"wires":[["d15e4e8e946e05e7"]]},{"id":"6d61a4ac72f55749","type":"telegram receiver","z":"eb78505f9403d5f9","name":"","bot":"6b031eeb3ef163ce","saveDataDir":"","filterCommands":false,"x":90,"y":180,"wires":[["4c61e9b76a573a67"],[]]},{"id":"4c61e9b76a573a67","type":"switch","z":"eb78505f9403d5f9","name":"","property":"payload.content","propertyType":"msg","rules":[{"t":"regex","v":"^ *yes *$","vt":"str","case":true}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":120,"wires":[["f1f3cadcf76ab072"]]},{"id":"f1f3cadcf76ab072","type":"function","z":"eb78505f9403d5f9","name":"Welcome123","func":"var helpMsg = \"/help - shows help\\n\\n\"\ncontext.set(\"chatId\", msg.payload.chatId)\nhelpMsg += \"/foo - opens a dialog\\n\\n\\n\"\nif (msg.payload.chatId === 7) {\n    helpMsg = \"R. Singh, Welcome sir!!!! \"\n}\nelse if (msg.payload.chatId === 126) {\n    helpMsg = \"Ki karda hai ghussuu :) :) :) \"\n}\nelse {\n    helpMsg += \"You are welcome in Singh's bot, \" + msg.originalMessage.from.username;\n}\nhelpMsg += \"Your chat id is: \" + msg.payload.chatId;\nmsg.payload.content = helpMsg;\nmsg.payload.sentMessageId  = msg.payload.chatId;\nmsg.payload.flag = msg.payload.chatId;\nconsole.log(msg + \"+++++++++++\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":200,"wires":[["6146aa21d792820c","b3cd69470d9f11c1"]]},{"id":"6146aa21d792820c","type":"debug","z":"eb78505f9403d5f9","name":"debug 22","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":160,"wires":[]},{"id":"a910e9e63a444f51","type":"telegram reply","z":"eb78505f9403d5f9","name":"","bot":"6b031eeb3ef163ce","x":660,"y":340,"wires":[["288824be2c7e5844","97a7115e9b837470"]]},{"id":"288824be2c7e5844","type":"debug","z":"eb78505f9403d5f9","name":"debug 23","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":280,"wires":[]},{"id":"97a7115e9b837470","type":"function","z":"eb78505f9403d5f9","name":"function 6","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":400,"wires":[["02a656151a0832aa"]]},{"id":"02a656151a0832aa","type":"debug","z":"eb78505f9403d5f9","name":"debug 24","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":440,"wires":[]},{"id":"a615867a06dcef82","type":"debug","z":"eb78505f9403d5f9","name":"debug 25","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":100,"wires":[]},{"id":"d15e4e8e946e05e7","type":"function","z":"eb78505f9403d5f9","name":"function 7","func":"console.log(\"---------------------->>>>>>>\");\n\nlet content = msg.payload.content;\nlet chatId = msg.payload.chatId;\nlet sentMessageId = msg.payload.sentMessageId;\nlet type = msg.payload.type;\nlet messageId = msg.reply_to_message_id;\nlet replyTo = msg.payload.messageId;\n\nmsg.payload = {};\nmsg.payload.content = content;\nmsg.payload.chatId = chatId;\nmsg.payload.sentMessageId = sentMessageId;\nmsg.payload.type = type;\n\nconsole.log(\"payload =\" + msg.payload.content);\n\nreturn [ msg ] ; \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":140,"wires":[["a615867a06dcef82","a910e9e63a444f51"]]},{"id":"6b031eeb3ef163ce","type":"telegram bot","botname":"si17","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksprotocol":"socks5","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]`

Not working for me either after latest update.

I get the 2nd question in telegram but the users response doesn't register.

1 Like

Expanded Dave's flow slightly:

The 2nd user response triggers a rejection on the original input but nothing else.

image

image

I'll wind back to the older version.

1 Like

Are you all just sending a message or clicking on message and selecting reply?

@RavinderSingh13 I asked for a screenshot.

type in the command, get the response, type in a response.

1 Like

Sure here it goes for very first code from my question:

Not working for v14.3.0 either.

For people where it is working, are you using a webhook or polling?

1 Like