Telegram Inline icon

Telegram Inline

Send messages with inline keyboards using Telegram Bot API

Overview

This node sends a text message with an inline keyboard to a specified Telegram chat using the Telegram Bot API. Inline keyboards are interactive buttons displayed directly below the message, allowing users to trigger callbacks, open URLs, or switch inline queries without sending separate messages.

Common scenarios:

  • Creating interactive Telegram bots that prompt users with choices.
  • Sending messages with quick action buttons (e.g., "Approve", "Reject").
  • Linking to external resources via URL buttons.
  • Implementing conversational flows where user input is captured through button presses.

Practical example:
A bot sends a message "Choose your option:" with an inline keyboard containing two buttons: "Yes" (which triggers a callback) and "More info" (which opens a URL). Users can interact directly by clicking these buttons.


Properties

Name Meaning
Chat ID Unique identifier for the target chat or username of the target channel where the message will be sent.
Text The text content of the message to be sent.
Parse Mode Mode for parsing entities in the message text. Options: None, Markdown, MarkdownV2, HTML. Determines how formatting like bold, italics, links, etc., are interpreted in the message text.
Inline Keyboard JSON array defining the inline keyboard layout. It must be an array of button rows, each row being an array of button objects. Each button requires a text property and at least one action property such as callback_data, url, or inline query switches. Example format:
[
  [
    {"text": "Button 1", "callback_data": "data1"},
    {"text": "Button 2", "url": "https://example.com"}
  ],
  [
    {"text": "Button 3", "callback_data": "data3"}
  ]
]

|
| Additional Fields | Optional extra parameters:
• Disable Notification: Send message silently without sound.
• Disable Web Page Preview: Disable link previews.
• Reply to Message ID: If replying, specify original message ID. |


Output

The node outputs the response from the Telegram API after sending the message. The output JSON contains details about the sent message, including message ID, chat information, date, text, and the inline keyboard markup.

If an error occurs (e.g., invalid inline keyboard JSON), the output will contain an error message describing the issue.

No binary data is produced by this node.


Dependencies

  • Requires a valid Telegram Bot API token configured in n8n credentials (referred generically as an API key credential).
  • Uses the Telegram Bot API endpoint sendMessage to send messages with inline keyboards.
  • The node expects proper JSON formatting for the inline keyboard property.

Troubleshooting

  • Invalid inline keyboard JSON:
    Error message: Invalid inline keyboard JSON: ...
    Cause: The inline keyboard JSON is malformed, not an array, or buttons lack required properties (text and at least one action).
    Resolution: Ensure the inline keyboard is a properly formatted JSON array of arrays, each button has a text field and at least one action property (callback_data, url, switch_inline_query, or switch_inline_query_current_chat).

  • Missing required fields:
    Errors occur if chatId or text is empty or missing.
    Resolution: Provide valid values for these required inputs.

  • API errors from Telegram:
    Could be due to invalid chat IDs, revoked bot permissions, or network issues.
    Resolution: Verify bot permissions, chat identifiers, and network connectivity.

  • Silent failures when Continue On Fail is enabled:
    Errors are returned as part of the output JSON with an error property instead of stopping execution.


Links and References

Discussion