Telegram GramJS icon

Telegram GramJS

Interact with Telegram using GramJS

Actions9

Message → Get

AI-generated

Overview

This node interacts with Telegram using the GramJS library to perform various operations on Telegram messages, chats, and users. Specifically, for the Message - Get operation, it retrieves a specified number of recent messages from a given chat identified by its ID, username, or phone number.

Common scenarios where this node is beneficial include:

  • Fetching recent conversation history from a Telegram chat for analysis or archiving.
  • Integrating Telegram message data into workflows for monitoring or reporting.
  • Automating responses or processing based on retrieved messages.

For example, you could use this node to get the last 10 messages from a customer support chat to analyze user queries or to trigger further automation based on message content.

Properties

Name Meaning
Chat ID The identifier of the chat to retrieve messages from. Can be a chat ID, username, or phone number.
Limit Number of messages to retrieve from the chat (default is 10).
Additional Options Collection of optional parameters:
- Parse Mode How to parse the message text. Options: None, Markdown, HTML.
- Silent Whether to send the message silently (not applicable for "get" but available in other ops).

Output

The output is an array of JSON objects, each representing a Telegram message retrieved from the specified chat. Each message object contains all relevant Telegram message properties as returned by the GramJS client’s getMessages method.

Example output structure (simplified):

[
  {
    "json": {
      "id": 123,
      "message": "Hello!",
      "date": "2024-06-01T12:00:00Z",
      "fromId": "...",
      "chatId": "...",
      "media": null,
      ...
    }
  },
  {
    "json": {
      "id": 124,
      "message": "How can I help you?",
      "date": "2024-06-01T12:01:00Z",
      ...
    }
  }
]

No binary data is output for this operation.

Dependencies

  • Requires a valid Telegram API authentication setup via credentials including:

    • API ID
    • API Hash
    • Session string (used for authentication)
    • Phone number (used only if session string is not provided, but password and phone code authentication are not supported in this node)
  • Uses the GramJS Telegram client library internally.

  • No additional environment variables are required beyond the configured credentials.

Troubleshooting

  • Authentication errors: If the node throws errors related to authentication, ensure that a valid session string is provided. Password and phone code authentication are not supported in this node; you must generate and supply a session string externally.

  • Invalid Chat ID: If the chat ID, username, or phone number is incorrect or inaccessible, the node may fail to retrieve messages. Verify the chat identifier is correct and accessible by the authenticated user.

  • Limit parameter issues: Setting the limit too high might cause performance issues or API rate limits. Use reasonable values.

  • General errors: Any unexpected errors will be reported with their message. Check network connectivity and Telegram API status if persistent.

Links and References

Discussion