Telegram MTProto Client icon

Telegram MTProto Client

Use Telegram Client API with MTProto protocol

Overview

This node provides a comprehensive interface to interact with Telegram using the MTProto protocol via a client API. It supports a wide range of Telegram operations such as sending text messages, media, and files; replying to or forwarding messages; managing chat members; retrieving message history; searching messages; joining or leaving chats; and creating channels with user invitations.

Common scenarios where this node is beneficial include automating Telegram communications for customer support, broadcasting announcements, managing group memberships, archiving chat histories, or integrating Telegram messaging into broader workflows.

For example:

  • Automatically send a welcome message when a new user joins a Telegram group.
  • Broadcast updates or alerts to multiple Telegram channels.
  • Search and retrieve specific messages from a chat history for analysis.
  • Create a new channel and invite team members programmatically.

Properties

Name Meaning
Options Collection of optional parameters:
- Silent: Send message silently without notification (boolean)
- Caption: Caption text for media messages (string)
- Parse Mode: How to parse message text; options are None, Markdown, HTML
- Limit: Maximum number of items to return (number)

Note: The above "Options" property is a collection that can be added to various operations to customize behavior.

Output

The node outputs an array with one item per input item processed. Each output item contains a json object with fields depending on the operation performed:

  • For sending messages (text, media, file), it returns success status, message ID, date, and relevant details like text or media type.
  • For message history retrieval or search, it returns success status and an array of messages.
  • For chat member retrieval, it returns success status and an array of members.
  • For user info retrieval, it returns success status and user details.
  • For forwarding or replying to messages, it returns success status along with original and new message IDs.
  • For channel creation and invitation, it returns success status, channel details (ID, title, description, type, link), invited users list, invitation statistics, and creation timestamp.
  • For join/leave chat operations, it returns success status and confirmation flags.

If binary data is involved (e.g., sending files or media), the node handles the file upload but does not output binary data itself.

Dependencies

  • Requires an API authentication token with Telegram MTProto credentials including session string, API ID, and API hash.
  • Uses the Telegram MTProto client library internally to connect and perform operations.
  • Needs network access to Telegram servers with WebSocket support enabled.
  • No additional external services are required beyond Telegram.

Troubleshooting

  • No credentials provided: Ensure valid Telegram API credentials are configured in n8n before running the node.
  • Invalid username format: When inviting users to a channel, usernames must start with '@'. Remove or correct any invalid usernames.
  • Channel creation limits: Errors indicating too many channels/supergroups mean you have reached Telegram's limit. Leave some channels before creating new ones.
  • User restrictions: Some errors may indicate your account is restricted from creating channels or adding users due to spam reports or privacy settings.
  • Empty channel title or long description: Provide a non-empty title and keep descriptions within allowed length.
  • Connection issues: Network problems or incorrect credentials can cause connection failures. Verify credentials and network connectivity.
  • Operation not supported: Using an unsupported operation name will throw an error. Use only documented operations.

When errors occur, if the node is set to continue on failure, it outputs the error message and operation name in the JSON output for easier debugging.

Links and References

Discussion