# Telegram Inline keyboard without Command node

**URL:** <https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275>\
**Category:** General\
**Created:** [14 July 2019 18:59 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275 "2019-07-14T18:59:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [14 July 2019 18:59 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/1 "2019-07-14T18:59:04Z")

</div>

Hello,  
From [https://flows.nodered.org/node/node-red-contrib-telegrambot](https://flows.nodered.org/node/node-red-contrib-telegrambot) I can create a flow to start a chat (the /foo example). However this requires the user to send the /foo to start the process using a command node. I would like to query a feedback from the user without him doing sending a message (command) first.  
Basically, my video portal sends an image using telegram when someone rings. After that, I would like to have the inline keyboard to query a Yes/No answer to open the door.  
Is there a way to do that? Can I use directly the sender node? What should be the payload?  
All examples I found are based on the /foo first!  
Thanks,  
GV

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 July 2019 23:28 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/2 "2019-07-14T23:28:49Z")

</div>

You should be able to send a custom keyboard after the image. Unfortunately, I'm not in a position to get you any code right now but this should certainly be possible.

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 05:48 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/3 "2019-07-15T05:48:18Z")

</div>

Thanks... Yes, I guess it is possible. I just don't know how 🙂  
GV

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 July 2019 08:16 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/4 "2019-07-15T08:16:28Z")

</div>

Do you know how to set up a keyboard anyway? That would be the place to start. Once you've done that, you probably need to send the image in one message and then the keyboard in the next.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 08:18 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/5 "2019-07-15T08:18:41Z")

</div>

> [@greengolfer](#):
>
> Basically, my video portal sends an image using telegram when someone rings.

This is done via node-red as well ?

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 08:32 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/6 "2019-07-15T08:32:18Z")

</div>

Yes. I am using a Grandstream GDS3710. When someone rings, it sends a HTTP request, received by nodered. Then, NodeRed takes a snapshot and sends using telegram.  
After that, I am stuck!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 08:57 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/7 "2019-07-15T08:57:20Z")

</div>

I am using [node-red-contrib-telegrambot-home](https://github.com/scraton/node-red-contrib-telegrambot-home) and which has a "command" node that can 'listen' for keywords and trigger actions based on that. Then in your case I would send the image + a text and based on the text I would trigger the reply\_markup keyboard.

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 09:03 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/8 "2019-07-15T09:03:56Z")

</div>

> [@TotallyInformation](#):
>
> Do you know how to set up a keyboard anyway? That would be the place to start. Once you've done that, you probably need to send the image in one message and then the keyboard in the next.

I am using the example from the document of telegrambot and once I have sent the /foo I have the keyboard.  
I have also used another example [https://discourse.nodered.org/t/turn-flow-on-off-via-iphone/8395/16](https://discourse.nodered.org/t/turn-flow-on-off-via-iphone/8395/16) and both are working fine.  
However they all start with a /foo or /start sent by the user.  
GV

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 09:06 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/9 "2019-07-15T09:06:06Z")

</div>

> [@bakman2](#):
>
> I am using [node-red-contrib-telegrambot-home](https://github.com/scraton/node-red-contrib-telegrambot-home) and which has a "command" node that can 'listen' for keywords and trigger actions based on that. Then in your case I would send the image + a text and based on the text I would trigger the reply\_markup keyboard.

I am using the same telegrambot-home. What I can't find is how to "trigger the reply\_markup keyboard." ?  
GV

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 09:32 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/10 "2019-07-15T09:32:27Z")

</div>

You will need read [through the documentation](https://core.telegram.org/bots/api#replykeyboardmarkup) of the telegram bot api.

This is the general idea, put this in a function node:

```auto
out = {
    method: "sendMessage",
    payload: {
        text: "Open the door",
        reply_markup: {
            inline_keyboard: [
                [{
                    text: "Yes"
                }],
                [{
                    text: "No"
                }]
            ]
        }
    }
}
return out;

```

command node -\> function node -\> telegram payload node  
Set the telegram payload node method to `-set-by-msg.method -`

The command node is the trigger.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [15 July 2019 09:52 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/11 "2019-07-15T09:52:39Z")

</div>

I’ve seen flows for this on a Dutch forum with a large NR thread, I’m waiting for an appointment to start so I’ll look up those flows later. Someone hooked a telegram node up to a door camera to be able to see when people are ringing the door, or when the mailman delivers packages. Iirc this one also had commands to unlock the door when someone is there.

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 09:55 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/12 "2019-07-15T09:55:34Z")

</div>

Thank you for the help. I quite don't understand though.

> [@bakman2](#):
>
> You will need read [through the documentation]

Did it... but I don't get it.

> [@bakman2](#):
>
> command node -\> function node -\> telegram payload node  
> Set the telegram payload node method to `-set-by-msg.method -`  
> The command node is the trigger.

With this, the "command" is still the trigger (as far as I understand...)

At the moment, my working flow is:

```auto
[{"id":"94151847.d29f68","type":"telegram sender","z":"fa35c8e.783dd38","name":"show inline keyboard","bot":"8ec03315.965a1","x":720,"y":600,"wires":[["836ad3f.f92053"]]},{"id":"acabf36d.5dca","type":"function","z":"fa35c8e.783dd38","name":"initial inline keyboard message","func":"// context.global.keyboard = { pending : true, messageId : msg.payload.messageId };\n\nvar opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"Oui\",\n \"callback_data\": \"ouvre\" \n }, \n {\n \"text\": \"Non\",\n \"callback_data\": \"ignore\" \n },\n]]\n })\n};\n\nmsg.payload.content = 'Ouverture du portail ?';\nmsg.payload.options = opts;\n\nreturn [msg];\n","outputs":"1","noerr":0,"x":430,"y":600,"wires":[["94151847.d29f68"]]},{"id":"836ad3f.f92053","type":"debug","z":"fa35c8e.783dd38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":910,"y":600,"wires":[]},{"id":"5bccc33.d131b3c","type":"telegram command","z":"fa35c8e.783dd38","name":"/Ouvrir","command":"/Ouvrir","bot":"8ec03315.965a1","strict":false,"x":170,"y":600,"wires":[["acabf36d.5dca"],[]]},{"id":"8ec03315.965a1","type":"telegram bot","z":"","botname":"@Jeedom","usernames":"","chatids":"782589784","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"verboselogging":true}]

```

In order to trigger I need "/Ouvrir" to be sent. This is not what I would like to do... I need to trigger that flow after sending the photo to telegram without any human created message.

GV

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 10:06 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/13 "2019-07-15T10:06:28Z")

</div>

If you send the picture to the bot, include a text as well. That text can be the command trigger (this does not have to start with a `/`)

you can test this:

command-node just with text: "test", connect it to a debug node.

type "test" to your bot, you will get a payload.

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 10:30 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/14 "2019-07-15T10:30:48Z")

</div>

It is exactly what I tried. If I send a "start" message (via the msg.payload and not manually) and even if the command is expecting a "start" to trigger, it doesn't work.  
I tried using the caption or a separate text. Same result.

GV

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 10:31 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/15 "2019-07-15T10:31:52Z")

</div>

> [@afelix](#):
>
> I’ve seen flows for this on a Dutch forum with a large NR thread, I’m waiting for an appointment to start so I’ll look up those flows later. Someone hooked a telegram node up to a door camera to be able to see when people are ringing the door, or when the mailman delivers packages. Iirc this one also had commands to unlock the door when someone is there.

My Dutch is even worse than my English! So, your feedback will be really welcome.

GV

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 10:42 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/16 "2019-07-15T10:42:07Z")

</div>

My example works. (btw I am dutch but don't need that thread to make this work) 😉

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 10:43 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/17 "2019-07-15T10:43:05Z")

</div>

Ok I forgot 1 thing, for the text an [optional property is required](https://core.telegram.org/bots/api#inlinekeyboardmarkup), I removed it in the example:

```auto
out = {
    method: "sendMessage",
    payload: {
        text: "Open door ?",
        reply_markup: {
            inline_keyboard: [
                [{
                    text: "Yes",
                    url: "http://google.com"
                }],
                [{
                    text: "No",
                    url: "http://google.com"
                }]
            ]
        }
    }
}
return out;

```

![36](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1984edd1ab25b844d10243bb7b3b3f2666786acf.jpeg)

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [15 July 2019 11:26 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/18 "2019-07-15T11:26:25Z")

</div>

> [@bakman2](#):
>
> Ok I forgot 1 thing, for the text an [optional property is required](https://core.telegram.org/bots/api#inlinekeyboardmarkup), I removed it in the example:

Would you be kind to share the flow? I can't figure out what to do with your explanation.  
I am fairly new to NR...  
Thanks for helping.

GV

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2019 11:32 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/19 "2019-07-15T11:32:31Z")

</div>

This is the flow (i had to desanitize it).  
Make sure to enter the chatid in the command-node and payload-node.

```auto
[{"id":"4d52e6db.884308","type":"telegrambot-command","z":"30358c58.b1f39c","name":"","bot":"7f0ce88d.8f81e","command":"door_event","commandType":"str","commandCase":false,"x":150,"y":725,"wires":[["ff98728c.b9243"]]},{"id":"54c6182b.d8a728","type":"telegrambot-payload","z":"30358c58.b1f39c","name":"","bot":"7f0ce88d.8f81e","chatId":"","sendMethod":"","payload":"","x":515,"y":725,"wires":[["32b7ce43.71e73a"]]},{"id":"ff98728c.b9243","type":"function","z":"30358c58.b1f39c","name":"","func":"out = {\n method: \"sendMessage\",\n payload: {\n text: \"Open door ?\",\n reply_markup: {\n inline_keyboard: [\n [{\n text: \"Yes\",\n url: \"http://google.com\"\n }],\n [{\n text: \"No\",\n url: \"http://google.com\"\n }]\n ]\n }\n }\n}\nreturn out;","outputs":1,"noerr":0,"x":325,"y":725,"wires":[["54c6182b.d8a728"]]},{"id":"32b7ce43.71e73a","type":"debug","z":"30358c58.b1f39c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":725,"wires":[]},{"id":"7f0ce88d.8f81e","type":"telegrambot-config","z":0,"botname":"","usernames":"","chatIds":"","pollInterval":"1000"}]

```

Now if you receive a message "door\_event", you will get the buttons and as an example url it will take you to google, ofcourse you need to change this to the action you want.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 July 2019 11:52 UTC](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275/20 "2019-07-15T11:52:18Z")

</div>

I would have probably confused you anyway since I user the other Telegram node - [https://github.com/windkh/node-red-contrib-telegrambot](https://github.com/windkh/node-red-contrib-telegrambot) - which also allows you to use the new webhook feature rather than polling if you want.

[Next page](https://discourse.nodered.org/t/telegram-inline-keyboard-without-command-node/13275.md?page=2)
