Chat → Get File
AI-generatedOverview
This node allows you to interact with Telegram chats using the GramJS library. Specifically, the Chat - Get File operation downloads a file attached to a specific message in a Telegram chat and outputs it as binary data. This is useful when you want to programmatically retrieve media or documents shared in Telegram conversations for further processing, storage, or analysis.
Common scenarios:
- Automatically downloading images, documents, or other files sent in a Telegram group or private chat.
- Archiving important files shared in Telegram chats.
- Integrating Telegram file downloads into automated workflows, such as sending downloaded files to cloud storage or other services.
Example:
You have a Telegram chat where users share reports as PDF files. Using this node, you can download those PDFs by specifying the chat and message ID, then process or save them automatically.
Properties
| Name | Meaning |
|---|---|
| Delete File After Output | Whether to delete the downloaded file from disk after output (recommended for temporary files). |
| File Name | The desired file name for the downloaded file. Leave empty to auto-detect from the message. |
| Chat ID | Identifier of the chat (ID, username, or phone number) where the message with the file exists. |
| Message ID | The ID of the message containing the file to download. |
Output
The node outputs one item per execution containing:
json:message: A confirmation string"File downloaded"indicating success.
binary.data:data: The base64-encoded content of the downloaded file.fileName: The file name used for the downloaded file (either user-specified or auto-detected).mimeType: The MIME type of the downloaded file (e.g.,"image/jpeg","application/octet-stream").
This binary output can be used downstream in n8n workflows to save the file, upload it elsewhere, or process it further.
Dependencies
- Requires an API authentication credential for Telegram that includes:
- API ID
- API Hash
- Session string or phone number for authentication (session string preferred)
- Uses the GramJS Telegram client library internally.
- Requires filesystem access to temporarily store the downloaded file before reading it into memory.
- No additional environment variables are explicitly required beyond the Telegram API credentials.
Troubleshooting
Authentication errors:
If the node throws errors related to authentication, ensure you provide a valid session string credential. Phone code or password authentication is not supported in this node.No message found:
If the specified message ID does not exist in the given chat, the node will throw an error "No message found". Verify the chat ID and message ID are correct.File name issues:
If no file name is provided and the message does not contain a recognizable file name attribute, the node defaults to"file". You can specify a file name manually if needed.Temporary file deletion:
If you enable "Delete File After Output" but encounter permission errors, ensure the node has rights to delete files in the/tmpdirectory or adjust permissions accordingly.