Telegram Message and File Parser - n8n Workflow

Use this efficient n8n workflow to automatically parse incoming Telegram messages, separating text, captions, and file attachments for streamlined data processing. Perfect for custom bots.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers building reliable automated Telegram bots.

  • Users who need to reliably separate file uploads from text instructions.

  • Automation specialists seeking robust n8n templates for social messaging platforms.

  • Anyone who struggles with routing logic for mixed media inputs in an n8n workflow.

Overview

Processing incoming messages from platforms like Telegram can be complex because users send unpredictable mixtures of plain text, files, or files accompanied by captions. This issue often causes downstream automations to fail or misclassify data. This specialized n8n workflow template solves this by providing smart, conditional routing based on the message content.

The core value of this n8n automation is its ability to inspect the payload from the Telegram service and direct the execution path flawlessly. Whether you receive a text-only command, a document-only upload, or a document with descriptive text (caption), this n8n workflow ensures the data is cleanly separated, normalized, and ready for the next stage, such as archival, AI analysis, or database logging. This is one of the most essential n8n templates for managing Telegram data reliably.

How it Works

This comprehensive n8n workflow begins with the Waiting For Message n8n trigger, which activates instantly upon receiving any new message sent to the configured Telegram bot.


  1. Trigger Activation: The Telegram Trigger n8n node fetches the raw message data.

  2. Conditional Routing: The subsequent Switch n8n node inspects the incoming data structure (message.caption, message.document, message.text) to determine the message type. It routes the flow down one of three paths: Attachment + Caption, Attachment Only, or Message Only.

  3. Data Separation (Attachment + Caption): If a file has a caption, the Split Out n8n node separates the file metadata (fileid, filename) and the caption text into distinct items. The Get Chat Message Content and Get Attachment n8n nodes then consolidate this information.

  4. Data Extraction (Attachment Only/Message Only): In the single-content paths, dedicated Set n8n nodes (like Get Attachment Only or Get Chat Message Only) isolate and clean the specific data field (e.g., just the text or just the file IDs).

  5. File Download: If an attachment was present, the Get & Download Attachment Telegram n8n node uses the extracted file_id to download the actual file content as binary data.

  6. Final Output: The flow concludes at the placeholder NoOp n8n node, presenting the clean, separated text and/or binary file data, ready for integration with services like Google Drive, OpenAI, or a database.

Installation Guide

To deploy this n8n workflow template, follow these steps:


  1. Import the Workflow: Copy the provided JSON code and paste it into your n8n instance via the 'Import from JSON' option.

  2. Create Your Telegram Bot: Use Telegram’s @BotFather to create a new bot and obtain its unique API Token.

  3. Configure n8n Credentials: In your n8n Credentials section, add a new Telegram API credential. Paste the API Token obtained from BotFather into the Access Token field and save it.

  4. Update Telegram Nodes: Open the "Waiting For Message" (Telegram Trigger) n8n node and select your newly created Telegram credential. Do the same for the "Get & Download Attachment" (Telegram) n8n node, ensuring both are linked to the correct bot.

  5. Activate: Activate the n8n workflow using the toggle in the top-right corner. It is now live and waiting for messages.

Node Details

Waiting For Message (Telegram Trigger): The initiating n8n trigger. It listens for message updates from Telegram, starting the n8n workflow upon arrival of any new chat content.
Switch (n8n node): Essential flow control. This n8n node uses three conditional rules to inspect the input JSON structure, directing the flow based on the existence of message.caption, message.document, or message.text.
Split Out (n8n node): Used specifically when a file includes a caption. This function takes multiple fields (fileid, filename, caption) and splits them into individual data items, allowing for parallel processing of text and file metadata.
Set Nodes (e.g., Get Attachment Only, Get Chat Message Content): These n8n nodes normalize the data, extracting the relevant fields (like fileid or text) into clean, easily referenced variables for subsequent n8n nodes in the workflow.


  • Get & Download Attachment (Telegram n8n node): This action node handles the API call to download the actual binary content of the file, provided it receives a valid fileid from the previous n8n nodes.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by
EoCi - Mr.Eo
EoCi - Mr.Eo

Featured*