# Telegram button problem

**URL:** <https://discourse.nodered.org/t/telegram-button-problem/98546>\
**Category:** General\
**Tags:** telegram, function-node\
**Created:** [6 August 2025 20:35 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546 "2025-08-06T20:35:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [6 August 2025 20:35 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/1 "2025-08-06T20:35:50Z")

</div>

Hello,

I have Telegram running and I can send and receive text messages.  
I can also send buttons, but nothing comes back to the Telegram receiver when a button is clicked.  
I have no idea where else to look or what to check.

This is my test to send the button

> ```auto
> [{"id":"callback_handler","type":"function","z":"716b40efe6f3823e","name":"Callback auswerten","func":"if (msg.payload.type === \"callback_query\") {\n const aktion = msg.payload.content;\n const antwort = (aktion === \"heizung_an\")\n ? \"Heizung wurde eingeschaltet!\"\n : (aktion === \"heizung_aus\")\n ? \"Heizung wurde ausgeschaltet!\"\n : \"Unbekannte Aktion!\";\n\n // Telegram erwartet IMMER eine Antwort bei callback_query\n return {\n payload: {\n chatId: msg.payload.chatId,\n type: 'message',\n content: antwort\n }\n };\n}\n\nreturn null;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":,"x":550,"y":200,"wires":[["90dbcc0849fea872","20787d840b66999b"]]},{"id":"188773d7aebf5c10","type":"telegram event","z":"716b40efe6f3823e","name":"","bot":"8d8ccc97ab1d3524","event":"callback_query","autoanswer":false,"x":240,"y":180,"wires":[["38a2ea75151eb98b","callback_handler"]]},{"id":"90dbcc0849fea872","type":"debug","z":"716b40efe6f3823e","name":"debug 80","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":200,"wires":},{"id":"20787d840b66999b","type":"telegram sender","z":"716b40efe6f3823e","name":"","bot":"8d8ccc97ab1d3524","haserroroutput":false,"outputs":1,"x":890,"y":240,"wires":[]},{"id":"38a2ea75151eb98b","type":"debug","z":"716b40efe6f3823e","name":"debug 79","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":520,"y":140,"wires":},{"id":"f45ac2b76240b9d4","type":"function","z":"716b40efe6f3823e","name":"function 13","func":"msg.payload = {\n chatId: 44444444, // Ersetze hier deine Telegram Chat-ID\n type: \"message\",\n content: \"Was soll mit der Heizung geschehen?\",\n options: {\n reply_markup: {\n inline_keyboard: [\n [\n { text: \"Heizung AN\", callback_data: \"heizung_an\" },\n { text: \"Heizung AUS\", callback_data: \"heizung_aus\" }\n]\n ]\n }\n }\n};\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":,"x":530,"y":240,"wires":[["20787d840b66999b"]]},{"id":"94781efeec2338e6","type":"inject","z":"716b40efe6f3823e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":240,"wires":[["f45ac2b76240b9d4"]]},{"id":"8d8ccc97ab1d3524","type":"telegram bot","botname":"Testtobienbot","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}]
> 
> ```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [6 August 2025 20:49 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/2 "2025-08-06T20:49:25Z")

</div>

Your flow json is corrupt due to no following forum guidelines on posting code.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

Saying that you are using a inline keyboard, so you should receive the call back using a event node set to callback not a receiver node, Check the node examples in  
ctrli i \> examples \> telegrambot.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 August 2025 20:58 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/3 "2025-08-06T20:58:36Z")

</div>

> [@edstobi](#):
>
> I have no idea where else to look or what to check

There are working examples you can import and adjust (`CTRL+I` -\> examples -\> node-red-contrib-telegrambot)

---

<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:** [7 August 2025 00:23 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/4 "2025-08-07T00:23:37Z")

</div>

I have cleaned up the code for someone to test.

```auto
[{"id":"38a2ea75151eb98b","type":"debug","z":"9cd9fa2d0d2e7202","name":"debug 79","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":460,"y":3220,"wires":[]},{"id":"90dbcc0849fea872","type":"debug","z":"9cd9fa2d0d2e7202","name":"debug 80","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":3280,"wires":[]},{"id":"callback_handler","type":"function","z":"9cd9fa2d0d2e7202","name":"Callback auswerten","func":"if (msg.payload.type === \"callback_query\") {\n const aktion = msg.payload.content;\n const antwort = (aktion === \"heizung_an\")\n ? \"Heizung wurde eingeschaltet!\"\n : (aktion === \"heizung_aus\")\n ? \"Heizung wurde ausgeschaltet!\"\n : \"Unbekannte Aktion!\";\n\n // Telegram erwartet IMMER eine Antwort bei callback_query\n return {\n payload: {\n chatId: msg.payload.chatId,\n type: 'message',\n content: antwort\n }\n };\n}\n\nreturn null;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":3280,"wires":[["90dbcc0849fea872","20787d840b66999b"]]},{"id":"80c15cbff93d494c","type":"telegram receiver","z":"9cd9fa2d0d2e7202","name":"","bot":"8d8ccc97ab1d3524","saveDataDir":"","filterCommands":true,"x":170,"y":3280,"wires":[["callback_handler","38a2ea75151eb98b"],["38a2ea75151eb98b"]]},{"id":"20787d840b66999b","type":"telegram sender","z":"9cd9fa2d0d2e7202","name":"","bot":"8d8ccc97ab1d3524","haserroroutput":false,"outputs":1,"x":830,"y":3320,"wires":[[]]},{"id":"f45ac2b76240b9d4","type":"function","z":"9cd9fa2d0d2e7202","name":"function 13","func":"msg.payload = {\n chatId: 44444444, // Ersetze hier deine Telegram Chat-ID\n type: \"message\",\n content: \"Was soll mit der Heizung geschehen?\",\n options: {\n reply_markup: {\n inline_keyboard: [\n [\n { text: \"Heizung AN\", callback_data: \"heizung_an\" },\n { text: \"Heizung AUS\", callback_data: \"heizung_aus\" }\n]\n ]\n }\n }\n};\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":3320,"wires":[["20787d840b66999b"]]},{"id":"94781efeec2338e6","type":"inject","z":"9cd9fa2d0d2e7202","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":3320,"wires":[["f45ac2b76240b9d4"]]},{"id":"8d8ccc97ab1d3524","type":"telegram bot","botname":"Testtobienbot","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}]

```

---

<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:** [7 August 2025 00:44 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/5 "2025-08-07T00:44:24Z")

</div>

Tried to get some solution, please see if this works.

used an event node instead of a reciever node.

```auto
[{"id":"callback_handler","type":"function","z":"716b40efe6f3823e","name":"Callback auswerten","func":"if (msg.payload.type === \"callback_query\") {\n const aktion = msg.payload.content;\n const antwort = (aktion === \"heizung_an\")\n ? \"Heizung wurde eingeschaltet!\"\n : (aktion === \"heizung_aus\")\n ? \"Heizung wurde ausgeschaltet!\"\n : \"Unbekannte Aktion!\";\n\n // Telegram erwartet IMMER eine Antwort bei callback_query\n return {\n payload: {\n chatId: msg.payload.chatId,\n type: 'message',\n content: antwort\n }\n };\n}\n\nreturn null;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":200,"wires":[["90dbcc0849fea872","20787d840b66999b"]]},{"id":"188773d7aebf5c10","type":"telegram event","z":"716b40efe6f3823e","name":"","bot":"8d8ccc97ab1d3524","event":"callback_query","autoanswer":false,"x":240,"y":180,"wires":[["38a2ea75151eb98b","callback_handler"]]},{"id":"90dbcc0849fea872","type":"debug","z":"716b40efe6f3823e","name":"debug 80","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":200,"wires":[]},{"id":"20787d840b66999b","type":"telegram sender","z":"716b40efe6f3823e","name":"","bot":"8d8ccc97ab1d3524","haserroroutput":false,"outputs":1,"x":890,"y":240,"wires":[[]]},{"id":"38a2ea75151eb98b","type":"debug","z":"716b40efe6f3823e","name":"debug 79","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":520,"y":140,"wires":[]},{"id":"f45ac2b76240b9d4","type":"function","z":"716b40efe6f3823e","name":"function 13","func":"msg.payload = {\n chatId: 44444444, // Ersetze hier deine Telegram Chat-ID\n type: \"message\",\n content: \"Was soll mit der Heizung geschehen?\",\n options: {\n reply_markup: {\n inline_keyboard: [\n [\n { text: \"Heizung AN\", callback_data: \"heizung_an\" },\n { text: \"Heizung AUS\", callback_data: \"heizung_aus\" }\n]\n ]\n }\n }\n};\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":240,"wires":[["20787d840b66999b"]]},{"id":"94781efeec2338e6","type":"inject","z":"716b40efe6f3823e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":240,"wires":[["f45ac2b76240b9d4"]]},{"id":"8d8ccc97ab1d3524","type":"telegram bot","botname":"Testtobienbot","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}]

```

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [7 August 2025 03:10 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/6 "2025-08-07T03:10:54Z")

</div>

Although probably not related and dependent on which Telegram node you are using, I have had situations similar to this where some Telegram nodes appear to stop responding (usually after long periods of NR running without intervention). Doing a full Deploy of NR fixes the issue. There is a little bug somewhere.

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [7 August 2025 06:40 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/7 "2025-08-07T06:40:02Z")

</div>

Well, talk about on queue. I just sent a command via the Telegram Command node, a command that I use periodically to initiate a Keyboard. No keyboard and no output. I have an inject node wired to the keyboard bypassing the above Command node. Injecting works as expected.

Performing a Full Deploy fixes the above.

This using ``node-red-contrib-telegrambot v16.3.2``

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [7 August 2025 20:05 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/8 "2025-08-07T20:05:31Z")

</div>

Hello,

Many thanks 🥰 — parallel to your approach, I realized that I should have been using an event instead of the receiver.

What’s been troubling me is that once I press the button, everything behaves as expected. However, the buttons remain active even after dozens of subsequent messages. How do you prevent this and ensure that only the button relevant to the current situation can be pressed?

In my testing setup, I ended up in a messy state: I turned something on even though it was already active, and the dashboard’s toggle state no longer matched what was displayed in Telegram. I can handle all of these cases in the logic, but I’d like to prevent the root cause: once the command is sent via Telegram, a second press shouldn't be allowed—until a new request with buttons is sent.

---

<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:** [21 August 2025 20:06 UTC](https://discourse.nodered.org/t/telegram-button-problem/98546/9 "2025-08-21T20:06:11Z")

</div>

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