Dynamic Inline keyboard for Telegram bot

I have a code block that gets Google sheet rows with necessary Inline keyboard options (with callback names) as an input. These inline keyboard buttons are necessary for my bot, and might be changed time to time, so I wish to make them dynamic.

import json

items = _input.all()

chat_id = _("Telegram Trigger").first().json.message.chat.id

# Generate inline keyboard (1 button per row)

keyboard = [

[{"text": item.json.regime_type, "callback_data": item.json.regime_type_callback}]

for item in items

]

telegram_payload = {

"chat_id": chat_id,

"text": "Choose regime:",

"reply_markup": {"inline_keyboard": keyboard},

}

return [{"json": telegram_payload}]

Then I need to use the result in the next SendMessage. json.text will be the text of the message, and “reply_markup” ought to be the Inline keyboard. GPT told me that I can use Reply Markup Expression Like this: {{ JSON.stringify($json.reply_markup) }}

But I only get the text of the message without any inline buttons. How to do so?

1 Like

hello @deeemash

Telegram node doesn’t support dynamic inline options. Use HTTP node instead

3 Likes

I was stuck for a while on this issue until I saw your post. Not even ChatGPT could help me resolve it. Thanks a ton!

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