Telegram MTProto Client icon

Telegram MTProto Client

Use Telegram Client API with MTProto protocol

Overview

The node interacts with the Telegram MTProto Client API to perform various chat-related operations. Specifically, the "Get Message History" operation retrieves the message history from a specified Telegram chat or channel. This is useful for scenarios where you want to analyze past conversations, archive messages, or process chat data programmatically.

Practical examples include:

  • Fetching recent messages from a support channel to analyze customer queries.
  • Archiving chat history for compliance or record-keeping.
  • Building analytics dashboards based on chat activity.

Properties

Name Meaning
Chat ID The identifier of the chat or channel from which to retrieve message history. It can be a numeric ID (e.g., -100xxxx) or a username starting with '@'.
Options Additional optional parameters:
• Silent: (not applicable for this operation)
• Caption: (not applicable)
• Parse Mode: (not applicable)
• Limit: Maximum number of messages to return (default 100).

Note: For "Get Message History", only the "Limit" option within "Options" is relevant.

Output

The output JSON contains:

  • success: Boolean indicating if the operation was successful.
  • messages: An array of message objects retrieved from the chat history. Each message object includes details such as message content, sender info, timestamps, and other metadata as provided by the Telegram client API.

No binary data is output by this operation.

Example output snippet:

{
  "success": true,
  "messages": [
    {
      "id": 12345,
      "date": "2024-06-01T12:34:56Z",
      "message": "Hello, world!",
      ...
    },
    ...
  ]
}

Dependencies

  • Requires an active Telegram MTProto API session authenticated via credentials containing a session string, API ID, and API hash.
  • The node uses the Telegram MTProto protocol through a client library bundled in the source.
  • Network connectivity to Telegram servers is required.
  • No additional environment variables are needed beyond the provided credentials.

Troubleshooting

  • No credentials provided: The node will throw an error if the required Telegram API credentials are missing. Ensure that valid credentials with session, API ID, and API hash are configured.
  • Connection issues: If the node cannot connect to Telegram, verify network access and that the credentials are still valid.
  • Limit parameter: Setting an excessively high limit may cause delays or timeouts; use reasonable values (default 100).
  • Invalid Chat ID: Providing an incorrect or inaccessible chat ID or username will result in errors or empty results.
  • API restrictions: Telegram may impose rate limits or restrictions on accessing certain chats or message histories.

Links and References

Discussion