About this workflow
Save New Files Received on Telegram to Google Drive – Workflow Analysis
This n8n workflow template automates the process of saving files sent via Telegram directly into a specified folder in Google Drive. It leverages real-time message monitoring, conditional logic, and cloud storage integration to create a seamless file archival or backup system without manual intervention.
What the Workflow Does
The workflow listens for new messages in a Telegram chat (typically a private bot conversation), checks whether the message includes a file (specifically a document), and—if so—downloads that file and uploads it to a preconfigured folder in Google Drive. This enables users to forward documents, images, PDFs, or any supported file types from Telegram straight into their cloud storage.
Key Features and Capabilities
- Real-time Triggering: Uses a Telegram webhook to instantly react to incoming messages.
- File Detection Logic: Employs a conditional "If" node to verify the presence of a document in the message payload.
- Automatic File Download: The Telegram trigger is configured with
download: true, ensuring binary file data is retrieved automatically. - Google Drive Integration: Securely uploads files using OAuth2 authentication to a designated folder.
- Metadata Preservation: Retains the original filename from Telegram during the upload to Google Drive.
- No-Code Automation: Entirely configurable through n8n’s visual interface—no scripting required.
Main Nodes and Their Purposes
-
On new Telegram Message (
n8n-nodes-base.telegramTrigger)- Acts as the entry point by subscribing to message updates from a Telegram bot.
- Configured to download file content automatically when a message contains a document.
- Requires valid Telegram Bot API credentials.
-
If Message contains a File (
n8n-nodes-base.if)- Evaluates whether the incoming message includes a
documentobject (indicating a file was sent). - Uses an expression
={{ $json.message.document }}to check for the existence of this field. - Only passes execution to the next node if the condition is met (i.e., a file is present).
- Evaluates whether the incoming message includes a
-
Upload File to GDrive (
n8n-nodes-base.googleDrive)- Takes the downloaded file binary and metadata from the Telegram message.
- Uploads the file to Google Drive using OAuth2 credentials.
- Saves the file in the “Demos” folder (ID:
11gyG2TvG0sqCG202CN-w9rloGW-CzKBc) under “My Drive”. - Dynamically sets the filename using
={{ $json.message.document.file_name }}.
Use Cases and Benefits
- Personal Document Archiving: Users can send receipts, contracts, or notes to their Telegram bot and have them auto-saved to Google Drive.
- Team Collaboration: Teams can use a shared Telegram bot to collect submissions (e.g., reports, designs) that are automatically centralized in Drive.
- Backup Automation: Prevents loss of important files sent over Telegram by creating redundant cloud copies.
- Time Savings: Eliminates manual downloading and uploading steps, reducing human error and effort.
- Scalability: Can be extended to handle multiple file types, apply naming conventions, or trigger downstream actions (e.g., email notifications).
Step-by-Step Workflow Logic
-
Trigger Activation:
A user sends a message containing a file (e.g., a PDF) to the configured Telegram bot. ThetelegramTriggernode detects this event via Telegram’s webhook API. -
Automatic File Download:
BecauseadditionalFields.downloadis set totrue, n8n automatically fetches the file content from Telegram’s servers and attaches it as binary data to the workflow item. -
Conditional Check:
The workflow passes the message payload to the If node, which evaluates whethermessage.documentexists. If the message is text-only or contains unsupported media (e.g., a sticker), the condition fails and the workflow stops. -
Google Drive Upload:
If a document is detected, the workflow proceeds to the Google Drive node. It uses:- The original filename from
message.document.file_name - Predefined folder ID (
11gyG2TvG0sqCG202CN-w9rloGW-CzKBc) corresponding to the “Demos” folder - Authenticated Google Drive credentials to perform the upload
- The original filename from
-
Completion:
The file is now stored in Google Drive, and the workflow ends successfully. Future messages will trigger the same sequence independently.
This workflow exemplifies efficient, event-driven automation between two popular platforms—Telegram and Google Drive—enabling users to streamline digital workflows with minimal setup.
How to use: download the JSON, then in n8n choose “Import from File”.