Telegram node: Possible to send flexible data for 'Reply Markup' = 'Inline Keyboard'?

Hi.
I would like to know if it’s possible to send custom data for ‘Inline Keyboard’?

Currently, to send data for Inline Keyboard, one has to fix the rows & buttons using the ‘Add Keyboard Row’ and ‘Add Button’ options.

What i would like to achieve is to send a varying set of rows and buttons everytime. This can currently be done via HTTP node by creating the Inline Keyboard payload programatically.

But, is this option also available in the current Telegram node and i’m not able to figure it out?
Or, if it isn’t, could this feature be added to the node?

This is how i’m doing it currently:

{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://api.telegram.org/bot<BOT_TOKEN>/sendMessage",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "chat_id",
              "value": <CHAT_ID>
            },
            {
              "name": "text",
              "value": "Test message"
            },
            {
              "name": "reply_markup",
              "value": "={{  JSON.stringify({inline_keyboard:[[{text:\"a\",callback_data:\"a\"}]] })  }}"
            }
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        600
      ]
    }
  ],
  "connections": {}
}

Thanks.

1 Like

No sorry. Currently, it is sadly only possible to define a fixed number of rows and buttons. So a HTTP Request node would be the only way to make that work currently.

What could be added in the future is an option to define them as JSON on the Telegram-Node. But it is always hard to keep the balance of making such things possible for the 1% and making at more confusing for the 99%.

A better solution would probably be adding something more generic to all nodes as described here:

Indeed, a quick solution could be something like what the HTTP node has: “JSON/RAW Parameters”.

This should certainly allow the flexibility required for advanced use while keeping the interface simple enough for most users.

Because, otherwise, everytime a HTTP node has to be used as a replacement, it creates a bit of a mess as the bot token:

  • gets exposed, and

  • has to be managed in the workflow.

Looking forward to whenever this feature can be added as well to the Telegram node.
Thanks.