Telegram Convert File
Description
Section titled “Description”This module downloads files (images, documents, etc.) received through a Telegram bot using the file_id provided by the Telegram API. Its execution flow is:
- Gets the
file_idfrom the input content (data.content). - Verifies that the
botTokenis available in the input data. - Calls the Telegram
getFileAPI to get the file path on Telegram servers. - Downloads the file from
https://api.telegram.org/file/bot{token}/{file_path}. - Saves the file to the temporary directory
temporal/cli_{client_id}/:- For photos: generates a name with timestamp (
image-{timestamp}.png). - For documents: uses the original file name (
data.metadata.file_name).
- For photos: generates a name with timestamp (
- Generates a public download URL based on
ENGINE_HOST. - Returns the original data enriched with
filename,filePath(local path) andurlPath(public URL).
The downloaded file is available for subsequent nodes that need to process it (e.g.: agentChat for image analysis, sendMail for attachments, etc.).
Configuration
Section titled “Configuration”This module has no configuration parameters in scheme. The necessary data is obtained from the flow input:
| Parameter (in input data) | Type | Required | Description |
|---|---|---|---|
| content | text | Yes | The file_id of the file sent by Telegram (e.g.: message.photo[n].file_id). |
| botToken | text | Yes | Telegram bot token. |
| chatId | text | No | Telegram chat ID. |
| type | text | No | File type: “photo” for images, other for documents. |
| metadata.file_name | text | No | Original file name (for documents). |
Credentials
Section titled “Credentials”The Telegram bot botToken is expected in data.botToken. It does not use the credentials system directly but receives the token from the Telegram trigger node.
Output
Section titled “Output”{ "nextModule": "siguiente-nodo", "data": { "content": "AgACAgIAAxkBAAI...", "botToken": "123456:ABC-DEF...", "chatId": "987654321", "type": "photo", "filename": "image-1711180800000.png", "filePath": "/app/temporal/cli_1/image-1711180800000.png", "urlPath": "https://mi-engine.com/download/cli_1/image-1711180800000.png" }}Usage Example
Section titled “Usage Example”Basic case
Section titled “Basic case”This module is placed after a Telegram trigger that receives messages with files. Typical input data comes automatically from the trigger:
{ "content": "AgACAgIAAxkBAAI...", "botToken": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11", "chatId": "987654321", "type": "photo", "metadata": { "file_name": "documento.pdf" }}API Used
Section titled “API Used”- Telegram Bot API:
GET https://api.telegram.org/bot{token}/getFile?file_id={fileId}- Get file path.GET https://api.telegram.org/file/bot{token}/{file_path}- Download the file.
- Documentation: https://core.telegram.org/bots/api#getfile
- Files are saved in
temporal/cli_{client_id}/. The directory is created automatically if it doesn’t exist. - Telegram has a 20 MB limit for file downloads via the bots API.
- For photos, the name is automatically generated with a timestamp. For documents, the original name is used.
- The public download URL depends on the
ENGINE_HOSTenvironment variable. - The original input data is preserved in the output, enriched with the file fields.
- This module is ideal for preprocessing files before passing them to modules like
agentChat(image analysis) orsendMail(attachments).
Related Nodes
Section titled “Related Nodes”- agentChat (Conversational AI Agent - for analyzing downloaded images)
- sendMail (Send Mail - for attaching downloaded files)
- openaiImages (OpenAI Generate Image)