Telegram CoPilot icon

Telegram CoPilot

Your Personal Telegram CoPilot

Overview

The Telegram CoPilot node for n8n, when configured with the resource Chat and operation Get Chat History, retrieves a segment of message history from a specified Telegram chat. This is useful for automating workflows that need to analyze, archive, or process past conversations in Telegram groups, channels, or private chats.

Common scenarios:

  • Archiving chat messages for compliance or backup.
  • Triggering actions based on recent chat activity (e.g., sentiment analysis, keyword detection).
  • Integrating Telegram chat data into other systems (CRMs, databases, etc.).

Example:
You could use this node to fetch the last 10 messages from a support group chat and then analyze them for customer satisfaction trends.


Properties

Display Name Type Required Description
Chat ID String Yes ID of the chat from which to retrieve the message history. Example: 122323
From Message ID String Yes Identifier of the message starting from which history must be fetched. Use 0 for latest.

Output

The output is a JSON object representing the result of the Telegram API's getChatHistory method. The structure typically includes:

{
  "_": "messages",
  "total_count": <number>,
  "messages": [
    {
      "_": "message",
      "id": <number>,
      "date": <timestamp>,
      "chat_id": <number>,
      // ...other message fields
    }
    // ...more messages
  ]
}
  • total_count: Total number of messages available in the chat.
  • messages: An array of message objects, each containing details such as message ID, date, chat ID, sender, content, etc.

Note: The actual fields may vary depending on the Telegram API response and the specific chat/message types.


Dependencies

  • External Service: Requires access to the Telegram API via the TelePilot integration.
  • Credentials: You must configure the telePilotApi credential in n8n, including your Telegram API ID, API Hash, and phone number.
  • n8n Configuration: No special environment variables are required beyond standard credential setup.

Troubleshooting

Common Issues:

  • Invalid Chat ID: If the provided Chat ID does not exist or you do not have access, the node will return an error.
  • Session Not Logged In: If your Telegram session is not authenticated, you may see errors prompting you to log in again.
  • Unauthorized Error: Indicates expired or invalid credentials; re-authenticate using the login flow.
  • A closed client cannot be reused, create a new Client: Your session was terminated; follow the login instructions to restore access.

How to resolve:

  • Double-check the Chat ID and ensure your account has permission to access the chat.
  • If prompted, use the login flow described at https://telepilot.co/login-howto.
  • Reconnect or refresh your TelePilot credentials in n8n if you encounter authorization issues.

Links and References


Discussion