windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
264 stars 117 forks source link

No callback query from inline keyboard #296

Closed schlaggi closed 1 year ago

schlaggi commented 1 year ago

Hi,

I'm struggling to get the callback from inline keyboards for some time now.

Attached you find my small test flow (which is basically one of the examples) and I see the keyboard in Telegram but I don't get an answer from the callback_query at all.

Is it something with my flow or do I have to activate something in the bot itself? (I tried activating some features in the bot like "Inline Feedback" but that didn't help.)

I also checked some other issues (like #152) but wasn't able to get this working.

Do you have a hint what I'm doing wrong?

Thank you!

[ { "id": "f7c18f49.063c4", "type": "telegram sender", "z": "96eb8f9f52b8d776", "name": "", "bot": "ca0d901f8fddf18c", "haserroroutput": false, "outputs": 1, "x": 640, "y": 360, "wires": [ [] ] }, { "id": "f97878f7.de1bf8", "type": "function", "z": "96eb8f9f52b8d776", "name": "Optionen", "func": "var opts = {\n reply_markup: JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"Container\",\n \"callback_data\": \"1\"\n }],\n [{\n \"text\": \"Paperless-NGX\",\n \"callback_data\": \"2\"\n }]\n ]\n })\n};\n\nmsg.payload.content = \"Was soll aktualisiert werden?\";\nmsg.payload.options = opts;\n//msg.payload.chatId = 304272248;\n//msg.payload.messageId = 29;\n//msg.payload.sentMessageId = 29;\nmsg.payload.type = \"message\";\n\nreturn [ msg ];\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 360, "y": 360, "wires": [ [ "f7c18f49.063c4", "67925ff5.4c7c9" ] ] }, { "id": "67925ff5.4c7c9", "type": "debug", "z": "96eb8f9f52b8d776", "name": "", "active": true, "tosidebar": true, "console": true, "tostatus": true, "complete": "true", "targetType": "full", "statusVal": "payload", "statusType": "auto", "x": 610, "y": 300, "wires": [] }, { "id": "981d4537.1ced18", "type": "telegram event", "z": "96eb8f9f52b8d776", "name": "", "bot": "ca0d901f8fddf18c", "event": "callback_query", "autoanswer": false, "x": 160, "y": 440, "wires": [ [ "385615779f4b3364", "5c8152de396b348c" ] ] }, { "id": "93430912.0f4f4", "type": "comment", "z": "96eb8f9f52b8d776", "name": "## Inline keyboard: Reply with \"callback_query\"", "info": "", "x": 260, "y": 320, "wires": [] }, { "id": "385615779f4b3364", "type": "function", "z": "96eb8f9f52b8d776", "name": "answerCallbackQuery", "func": "var text = \"You clicked \" + msg.payload.content;\nvar options = {\n text : \"Hallo Welt\",\n show_alert : true,\n cache_time : 10\n};\n\nmsg.payload.content = text;\nmsg.payload.options = options;\nmsg.payload.type = \"answerCallbackQuery\";\n\nreturn [ msg ];\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 400, "y": 440, "wires": [ [ "f7c18f49.063c4" ] ] }, { "id": "5c8152de396b348c", "type": "debug", "z": "96eb8f9f52b8d776", "name": "", "active": true, "tosidebar": true, "console": true, "tostatus": true, "complete": "true", "targetType": "full", "statusVal": "payload", "statusType": "auto", "x": 350, "y": 520, "wires": [] }, { "id": "062eedf73561c45f", "type": "telegram command", "z": "96eb8f9f52b8d776", "name": "", "command": "/update", "description": "", "registercommand": false, "language": "", "scope": "default", "bot": "ca0d901f8fddf18c", "strict": false, "hasresponse": false, "useregex": false, "removeregexcommand": false, "outputs": 1, "x": 130, "y": 360, "wires": [ [ "f97878f7.de1bf8" ] ] }, { "id": "ca0d901f8fddf18c", "type": "telegram bot", "botname": "ServerBot", "usernames": "", "chatids": "", "baseapiurl": "", "updatemode": "polling", "pollinterval": "750", "usesocks": false, "sockshost": "", "socksprotocol": "socks5", "socksport": "6667", "socksusername": "anonymous", "sockspassword": "", "bothost": "", "botpath": "", "localbotport": "8443", "publicbotport": "8443", "privatekey": "", "certificate": "", "useselfsignedcertificate": false, "sslterminated": false, "verboselogging": true } ]

windkh commented 1 year ago

Bei mir gehts image

windkh commented 1 year ago

ist der bot in einem channel oder kommunizierst du direkt?

schlaggi commented 1 year ago

Hm. Schön zu wissen, dass der Code schonmal funktioniert.

Ich kommuniziere direkt mit dem Bot.

schlaggi commented 1 year ago

In Telegram steht oben nur "Lädt...", wenn man auf eine der Auswahlbuttons drückt, und das wars dann.

B2DFF7AC-CDE1-4E07-8ADB-769E8713A57A_4_5005_c

windkh commented 1 year ago

Mit welchem Telegram Client arbeitest du? Ich nutze den Desktop Client unter Windows.

schlaggi commented 1 year ago

Bisher hatte ich das nur auf meinem iPhone getestet. Habe es jetzt nochmal von web.telegram.org aus versucht, aber mit demselben Ergebnis.

Ist das Ergebnis auf den verschiedenen Clients nicht gleich?

windkh commented 1 year ago

Wie sind denn beine bot settings? Polling?

schlaggi commented 1 year ago

Neben meinem Bot-Namen und -Token eine ChatID. Und der Update Mode ist Polling, das Intervall steht auf 300.

Auf meine /commandos reagiert er ja, nur wenn man auf einen Button unter einer Frage drückt passiert nichts. Auch über die Debug node in NodeRed lässt sich keine Reaktion feststellen.

windkh commented 1 year ago

Keine Ahnung.... nimm mal einen anderen bot token

schlaggi commented 1 year ago

Tatsächlich. Hab mir einen neuen Bot angelegt und da funktioniert es auf anhieb. Was für ein Käse. 🤯

windkh commented 1 year ago

Revoke mal den token der nicht ging und erzeuge einen neuen für den bot der nicht ging

schlaggi commented 1 year ago

Jo, das hat auch geholfen. Wäre ich sicherlich nicht drauf gekommen. Vielen Dank für die Hilfe!