Telegram Client icon

Telegram Client

Use Telegram Client API

Overview

This node enables interaction with the Telegram Client API, allowing users to perform various chat-related operations programmatically. Specifically, the "Leave Chat" operation lets a user or bot leave a specified Telegram chat or channel. This is useful in scenarios where automated workflows need to manage group memberships, such as leaving inactive groups, managing subscriptions, or cleaning up after certain events.

Practical example:

  • Automatically leave a Telegram channel after processing messages or completing a campaign.
  • Leave a chat when a user unsubscribes from notifications managed via n8n.

Properties

Name Meaning
Chat ID The identifier of the chat or channel to leave. Can be a numeric ID (e.g., -100xxxx) or username (e.g., @username).
Options A collection of optional parameters (not specifically used for "Leave Chat" but available for other operations).

Note: For the "Leave Chat" operation, only the Chat ID property is required and relevant.

Output

The output JSON object for the "Leave Chat" operation contains:

  • success (boolean): Indicates if the operation was successful (true).
  • left (boolean): Confirms that the client has left the chat (true).
  • chatId (string): The ID of the chat or channel that was left.

Example output:

{
  "success": true,
  "left": true,
  "chatId": "@examplechannel"
}

No binary data is produced by this operation.

Dependencies

  • Requires an active Telegram Client API credential with valid session, API ID, and API hash.
  • The node uses the Telegram Client SDK internally to connect and perform actions.
  • Network connectivity to Telegram servers is necessary.
  • No additional environment variables are required beyond the configured credentials.

Troubleshooting

  • Common issues:

    • Missing or invalid credentials will cause authentication failure.
    • Invalid or inaccessible chat ID may result in errors or inability to leave the chat.
    • Network issues can prevent connection to Telegram servers.
  • Error messages:

    • "No credentials provided": Ensure the Telegram Client API credentials are properly set up.
    • "Authentication failed: ...": Check that the session, API ID, and API hash are correct and valid.
    • "Operation "leaveChat" is not supported": This should not occur if the operation is correctly selected; verify node configuration.
    • Other errors returned by Telegram API (e.g., insufficient permissions to leave a chat) should be handled by reviewing the Telegram account's rights.
  • Resolution tips:

    • Verify credentials and re-authenticate if needed.
    • Confirm the chat ID is correct and accessible by the authenticated user/bot.
    • Check network connectivity.
    • Enable "Continue on Fail" in the node settings to handle errors gracefully during batch executions.

Links and References

Discussion