Telegram Bot icon

Telegram Bot

Fetch messages from Telegram bot

Overview

This node connects to a Telegram Bot and fetches new updates (such as messages or events) from it. It is designed to retrieve only new updates since the last check, automatically managing the offset to avoid duplicates. This functionality is useful for workflows that need to react to incoming Telegram messages or commands in real time.

Common scenarios include:

  • Automating responses to user messages on Telegram.
  • Logging or processing chat messages.
  • Triggering other workflow actions based on Telegram bot interactions.

For example, you could use this node to monitor a Telegram group or channel for new messages and then forward those messages to another service or database.

Properties

Name Meaning
Operation The action to perform; here, "Get New Updates" to fetch new messages from the Telegram bot.
Limit Maximum number of updates to retrieve per execution, between 1 and 100.
Timeout Timeout in seconds for long polling (0-50). Higher values reduce the frequency of API calls by waiting longer for new updates.
Auto Confirm Updates Whether to automatically confirm received updates by updating the offset internally (recommended to avoid receiving duplicate updates).

Output

The node outputs an array of JSON objects, each representing a single update received from the Telegram Bot API. Each update contains detailed information about the event, such as message content, sender info, and update ID.

If no new updates are available, the node outputs a JSON object with:

  • message: "No new updates available"
  • last_offset: the last processed update offset
  • timestamp: current timestamp when the check was made

If binary data were involved (e.g., media files), it would be included accordingly, but this node focuses on JSON update data only.

Dependencies

  • Requires a valid Telegram Bot API token credential configured in n8n.
  • Uses Telegram Bot API endpoint https://api.telegram.org/bot<token>/getUpdates.
  • No additional external dependencies beyond standard HTTP requests.

Troubleshooting

  • Common issues:

    • Invalid or expired Telegram Bot API token will cause authentication errors.
    • Setting the limit outside the allowed range (1-100) may cause API errors.
    • Network connectivity problems can lead to request failures.
  • Error messages:

    • "Telegram API error: <description>" indicates an issue reported by Telegram's API, such as invalid parameters or authorization failure.
    • If the node throws errors related to offset management, ensure that the node’s static data storage is not cleared between executions, as it stores the last update offset.
  • Resolutions:

    • Verify the Telegram Bot API token is correct and has necessary permissions.
    • Adjust limit and timeout parameters within allowed ranges.
    • Enable "Auto Confirm Updates" to prevent receiving duplicate updates.
    • Check network connectivity and firewall settings.

Links and References

Discussion