Telegram Response Payload

Good afternoon, everyone!
I use code-red-contrib-telegrambot, I can't understand how to determine the payload for a specific request. The answer comes only YES or NO. But it is not clear to what request. How do I determine which request was answered?

If you have only one command then its that one. Are you somehow multiplexing a command?

Show us your flow and try to describe a bit more what your issue is (e.g. is it a problem for single users or multiple users? are there multiple questions? are you using the keyboard? etc)

I'm doing the logic. If the light in the bathroom is turned on for more than 30 minutes, the bot asks "turn off the light or not", if there is no answer within 5 minutes, the light turns off. Requests will be for the light of the toilet, corridor, etc. How to determine what the answer refers to.
I use this request code in the telegram:

 var buttons = {
   reply_markup: JSON.stringify({
     keyboard: [
     'resize_keyboard' : true, 
     'one_time_keyboard' : true
 msg.error = false;
 msg.payload = {
     chatId : 'id_group',
     type : 'message',
     content : "Turn off the bathroom light?",
     options : buttons,
     //messageId : 99,
     //sentMessageId : 99,
 return msg ;

Note: I edited your post and changed the inserted code to be surrounded by back-tics to make it ore readable,

In the description there is such a code, as I understand it, it adds a payload to the answer:

"inline_keyboard": [[
     {"text": "Yes","callback_data": "FOO YES"},
     {"text": "No", "callback_data": "FOO NO"}

But for some reason it doesn't work. The menu appears in the telegram bot, but the answer does not come in node-red

Are you checking 2nd output?

I took the code from the example and the payload began to come to node red:

var opts = {
  reply_markup: JSON.stringify({
    "inline_keyboard": [[
                    "text": "A1",
                    "callback_data": "1"            
                    "text": "A2",
                    "callback_data": "2"            

msg.payload.content = "Selection?";
msg.payload.options = opts;
msg.payload.chatId = id_group;
msg.payload.messageId = 99;
msg.payload.sentMessageId = 99;
msg.payload.type = "message";

return [ msg ];

But in the Telegram, I can press these buttons many times, they do not disappear, this is bad.

There is no need to stringify the options.

try this flow...

[{"id":"261f71c7.09969e","type":"catch","z":"5d3f964c.fef898","name":"","x":640,"y":960,"wires":[["3188d108.c5c9ce"]]},{"id":"3188d108.c5c9ce","type":"debug","z":"5d3f964c.fef898","name":"No Repsonse","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":960,"wires":[]},{"id":"64d9c2e7.37f9fc","type":"telegram sender","z":"5d3f964c.fef898","name":"show keyboard","bot":"fa7a9376.321ce","haserroroutput":false,"outputs":1,"x":966,"y":785,"wires":[["b9181155c9712c9f"]]},{"id":"922f958f.6b2a18","type":"function","z":"5d3f964c.fef898","name":"confirmation message","func":"const opts = {\n  reply_to_message_id: msg.payload.messageId,\n  reply_markup: JSON.stringify({\n    keyboard: [\n      ['Yes'],\n      ['No']],\n      'resize_keyboard' : true, \n      'one_time_keyboard' : true\n  })\n};\n\nmsg.payload.content = 'Are you sure?';\nmsg.payload.options = opts;\n\nreturn msg;\n","outputs":"1","noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":785,"wires":[["64d9c2e7.37f9fc"]]},{"id":"d50e9648.1c6648","type":"telegram command","z":"5d3f964c.fef898","name":"/bar","command":"/bar","description":"","registercommand":false,"language":"","bot":"fa7a9376.321ce","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":480,"y":812,"wires":[["922f958f.6b2a18"],["d9debf3e.255fe"]]},{"id":"d9debf3e.255fe","type":"function","z":"5d3f964c.fef898","name":"check answer and respond","func":"if(msg.payload.content === 'Yes')\n{\n    msg.payload.content = 'Consider it done';\n    return [msg, null];   \n} else {\n    msg.payload.content = 'No';\n    return [null, msg];   \n}\n","outputs":"2","noerr":0,"initialize":"","finalize":"","libs":[],"x":724,"y":844,"wires":[["7060d4f9.f196dc","68861cc0636dd0a0"],["3188d108.c5c9ce"]]},{"id":"7060d4f9.f196dc","type":"telegram sender","z":"5d3f964c.fef898","name":"send response","bot":"fa7a9376.321ce","outputs":1,"x":1220,"y":840,"wires":[[]]},{"id":"b9181155c9712c9f","type":"debug","z":"5d3f964c.fef898","name":"Show Keyboard","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":780,"wires":[]},{"id":"68861cc0636dd0a0","type":"debug","z":"5d3f964c.fef898","name":"Yes response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":900,"wires":[]},{"id":"fa7a9376.321ce","type":"telegram bot","botname":"my bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"","usesocks":false,"sockshost":"","socksport":"","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"","publicbotport":"","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

it requires you so send /bar but you can adapt it into your solution

It works. But if there are two messages at the same time /bar and /foo for example. I understand correctly that it will be necessary to send commands from node red (/light_off /light_on, etc.) to the chat with the bot

And somehow you can skip entering the command (/bar). My trigger is a timer in node-red.

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