Telegram CoPilot icon

Telegram CoPilot

Your Personal Telegram CoPilot

Overview

The Send Message with File operation of the Message resource in this custom n8n node allows you to send a file (document) to a specified Telegram chat. This is useful for automating workflows where you need to deliver documents, reports, logs, or any other files directly to a Telegram user or group.

Common scenarios:

  • Sending automated reports or exports to a Telegram group.
  • Delivering log files or error dumps to a support chat.
  • Sharing generated PDFs, images, or other documents as part of an n8n workflow.

Example:
After generating a PDF invoice in your workflow, use this node to send the invoice directly to a customer’s Telegram chat.


Properties

Display Name Type Required Description
Chat ID String Yes ID of the target Telegram chat to send the file to. Example: 122323
File Path String Yes Path to the local file on the n8n server that should be sent.
File Caption String No Optional caption text to accompany the file.
Reply to messageId String No If set, the file will be sent as a reply to the specified message ID in the chat.

Output

The output is a JSON object representing the result of the Telegram API's sendMessage call with a document attachment. The structure typically includes:

{
  "chat_id": "<Chat ID>",
  "reply_to_msg_id": "<Replied Message ID or null>",
  "input_message_content": {
    "_": "inputMessageDocument",
    "document": {
      "_": "inputFileLocal",
      "path": "<File Path>"
    },
    "caption": {
      "_": "formattedText",
      "text": "<File Caption or null>"
    }
  },
  // ...additional fields returned by Telegram API
}
  • The actual response may include more details such as message IDs, timestamps, and status information as provided by the Telegram API.

Note: This operation does not output binary data; it sends the file to Telegram and returns the API response.


Dependencies

  • External Service: Requires access to the Telegram API via the TelePilot integration.
  • API Credentials: You must configure the telePilotApi credentials in n8n, including apiId, apiHash, and phoneNumber.
  • File Access: The file path provided must be accessible from the n8n server environment.
  • Node Modules: Relies on the TelePilotNodeConnectionManager and related dependencies bundled with the node.

Troubleshooting

Common Issues:

  • File Not Found: If the file path is incorrect or inaccessible, the operation will fail. Ensure the file exists and the path is correct relative to the n8n server.
  • Invalid Chat ID: If the chat ID is invalid or the bot/user does not have permission to send messages to the chat, the request will fail.
  • Session/Authorization Errors: If the Telegram session is closed or unauthorized, you may see errors like:
    • "Session was closed or terminated. Please login again: https://telepilot.co/login-howto"
    • "Please login: https://telepilot.co/login-howto"
      In these cases, re-authenticate your TelePilot credentials.
  • Telegram API Errors: Any issues with the Telegram API (e.g., rate limits, file size limits) will be reflected in the error message returned.

Error Messages & Resolutions:

  • "File not found at path:" – Check the file path and ensure the file exists on the n8n server.
  • "Cannot send messages to this chat." – Verify the bot/user has permission to write to the chat.
  • "Unauthorized" / "Session was closed..." – Re-login using the TelePilot authentication process.

Links and References


Discussion