This workflow corresponds to n8n.io template #9254 — we link there as the canonical source.
This workflow follows the Telegram → Telegram Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"nodes": [
{
"id": "6e742911-e7c0-47bc-b2f9-99789571617a",
"name": "Waiting For Message",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-480,
-64
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {
"download": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "2d2c3f99-2df5-4971-bb9f-cfd5d20fa615",
"name": "Get Chat Message Only",
"type": "n8n-nodes-base.set",
"position": [
-32,
128
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "d1590916-031f-4cc6-b6ce-7b1721a53a30",
"name": "text",
"type": "string",
"value": ""
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f06208a9-b6d8-4af1-9cc6-bb68f580df29",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
-288,
-80
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Attachmet+Message(Caption)",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1c36bdfd-7a9a-4f5d-bd53-12ffc8c8f829",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.caption }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Attachment Only",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a0080ad2-7885-4485-ae57-0c4dea199483",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.document }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Message Only",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dd9f3c11-ba4b-4963-bc02-23cd7670bf94",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "74a133e1-f969-4fb9-8661-c323279fca27",
"name": "Split Out",
"type": "n8n-nodes-base.splitOut",
"position": [
-32,
-256
],
"parameters": {
"options": {},
"fieldToSplitOut": "message.document.file_id, message.document.file_name, message.caption"
},
"typeVersion": 1
},
{
"id": "344226d7-fc3f-4170-ada7-6300c31b3f0d",
"name": "Get Attachment Only",
"type": "n8n-nodes-base.set",
"position": [
-32,
-64
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "41cf616c-c640-4f61-a2ba-49715aa1bf2a",
"name": "file_id",
"type": "string",
"value": "={{$json.message.document.file_id}}"
},
{
"id": "22fcf53f-ebd5-4294-9fd8-7a485b8293f2",
"name": "file_name",
"type": "string",
"value": "={{$json.message.document.file_name}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "0dbedca1-1b6d-47ab-8374-1a094d055962",
"name": "Get & Download Attachment",
"type": "n8n-nodes-base.telegram",
"position": [
208,
-64
],
"parameters": {
"fileId": "={{ $json.file_id || $json.message.document.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "ed661779-1132-43e3-98bb-60933169e8ec",
"name": "Get Attachment",
"type": "n8n-nodes-base.set",
"position": [
208,
-256
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "41cf616c-c640-4f61-a2ba-49715aa1bf2a",
"name": "file_id",
"type": "string",
"value": "={{ $json['message.document.file_id'] }}"
},
{
"id": "22fcf53f-ebd5-4294-9fd8-7a485b8293f2",
"name": "file_name",
"type": "string",
"value": "={{ $json['message.document.file_name'] }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "4ae82bee-86f6-424c-857e-bd04f213d9f7",
"name": "Next Step !",
"type": "n8n-nodes-base.noOp",
"position": [
416,
-448
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d478957b-8d4f-4c85-8684-9be3311a59f7",
"name": "Next Step ! ",
"type": "n8n-nodes-base.noOp",
"position": [
416,
-64
],
"parameters": {},
"typeVersion": 1
},
{
"id": "cb0d1d8d-2c9b-48f2-af3d-3eab61173d3d",
"name": "Next Step ! ",
"type": "n8n-nodes-base.noOp",
"position": [
208,
128
],
"parameters": {},
"typeVersion": 1
},
{
"id": "3717aff4-90a4-4d7d-936a-d0dd4ad2e7e8",
"name": "Get Chat Message Content",
"type": "n8n-nodes-base.set",
"position": [
208,
-448
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "8de49002-38ba-43fe-ba48-18e8c85241a2",
"name": "chat_message_content",
"type": "string",
"value": "={{ $json['message.caption'] }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "ee320c2a-da1d-46e7-b0de-325a9f398478",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-560,
-768
],
"parameters": {
"width": 1184,
"height": 1072,
"content": "## **Automate Telegram Message Processing - Separate Text and Files** \ud83d\udcac\ud83d\udcc1 \n### \u26a1\ufe0f **Quick Demo**\n* **Input:** A message sent to your Telegram bot. It can be text-only, a file-only (like a PDF or image), or a file with a text caption.\n* **Output:** The workflow intelligently separates the content. You get the plain text in one field and the ready-to-use file (as binary data) in another, perfectly prepared for the next step.\n\n### \u2705 **What You Get**\n* **Smart Content Routing:** Automatically detects if a message contains text, a file, or both, and sends it down the correct processing path. No complex `IF` logic needed!\n* **Clean Data Separation:** Neatly extracts text from messages or captions and isolates file attachments, preventing data mix-ups in your automations.\n* **Ready-to-Use Files:** Downloads attachments and provides them as binary data, perfect for saving directly to cloud storage or sending to other services for processing.\n\n### \ud83c\udfaf **Perfect For**\n* Building chatbots or automated support bots on Telegram.\n* Creating a system to automatically archive documents or images sent to a group.\n* Anyone who needs to reliably process varied and unpredictable messages from Telegram users."
},
"typeVersion": 1
},
{
"id": "cce8c746-8dcd-4919-8bc1-e532ad7aeda7",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
-768
],
"parameters": {
"width": 592,
"height": 576,
"content": "## \ud83d\udd04 **WORKFLOW FLOW EXPLAINED**\n### \u27a1\ufe0f **INPUT STAGE**\n- Telegram Trigger\n- Listens for any new message sent to your Telegram bot.\n- Fetches the raw message data, including text, captions, and file.\n\n### \ud83d\udd00 **ROUTING STAGE**\n- Switch Node\n- Inspects the incoming data to identify the message type (text, file, or file+caption).\n- Routes the execution down one of three specialized processing paths.\n\n### \u2699\ufe0f **PROCESSING STAGE**\n- Set Nodes \u2192 Split Out Node\n- Path 1 (File + Caption): The `Split Out` node separates file data and caption text into distinct items.\n- Path 2 & 3 (File Only / Text Only): `Set` nodes isolate and reformat the specific data (file info or message text) to make it clean and easy to use.\n\n### \ud83c\udfc1 **OUTPUT STAGE**\n- Telegram Node \u2192 NoOp (Placeholder)\n- If a file was sent, the `Telegram` node downloads the actual file binary data.\n- The workflow ends at a `NoOp` placeholder, presenting the final, separated data ready for your custom logic."
},
"typeVersion": 1
},
{
"id": "fcf591be-4432-44f7-b148-38dcab66dfa3",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-560,
320
],
"parameters": {
"width": 1184,
"height": 288,
"content": "## \ud83d\ude4f **Thank You for Trying This Workflow**\nYour time and trust mean a lot! I truly appreciate you using the Telegram Message Parser.\n\nYour feedback is the key to making this template better, more effective, and more useful for everyone.\nIf you have:\n- Suggestions for improvement\n- Ideas for new features\n- Requests for other automation workflows\n\n### Please share them with me! Every idea helps shape the next update.\n### Thank you again for being part of this journey."
},
"typeVersion": 1
},
{
"id": "4bfb1059-f967-4fe5-bc3a-f43c782fc6ca",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1168,
-768
],
"parameters": {
"width": 592,
"height": 352,
"content": "## \ud83d\udee0\ufe0f **CUSTOMIZATION OPTIONS**\n### \u25b6\ufe0f **Extend Functionality**\n- Save Attachments: Replace the final `NoOp` nodes with **Google Drive**, **Dropbox**, or **AWS S3** nodes to automatically archive files.\n- Process with AI: Connect the text output to a **Gemini** or **OpenAI** node to summarize content, analyze sentiment, or generate a reply.\n- Log to Database: Add a **Google Sheets**, **Airtable**, or **Postgres** node to log all incoming messages.\n\n### \u25b6\ufe0f **Handle More Media Types**\n- Add Rules: Modify the **Switch** node to add new routing rules for photos (`message.photo`), videos (`message.video`), or audio (`message.audio`).\n- Update Logic: Add or clone the `Set` nodes in the new paths to correctly extract the relevant file IDs and metadata for each media type."
},
"typeVersion": 1
},
{
"id": "f38bb91a-5374-42c5-bb66-c784a56cb7b2",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
-176
],
"parameters": {
"width": 592,
"height": 480,
"content": "## \ud83e\ude7a TROUBLESHOOTING\n### \u274c **Common Issues**\n- **\"Workflow doesn't trigger\"**\n - Double-check that you selected the correct **Telegram credential** in the Trigger node.\n - Ensure your workflow is **Active**.\n - Make sure you are sending messages to the correct bot in Telegram.\n- **\"File is not downloading\"**\n - Verify that the **Telegram** node (named \"Get & Download Attachment\") is also configured with the correct credential.\n - Check the execution log for errors from the Telegram API, which might indicate a problem with the file or `file_id`.\n\n### \u2705 **Debug Checklist**\n- [ ] Telegram credential is valid and connected to **both** Telegram nodes.\n- [ ] Workflow is active.\n- [ ] Tested by sending all three message types (text, file, file+caption).\n- [ ] Checked the output of the final `NoOp` node in a test execution to see the structured data."
},
"typeVersion": 1
},
{
"id": "59547980-fcab-4962-aa1a-5a968f6765c0",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1168,
-400
],
"parameters": {
"width": 592,
"height": 784,
"content": "## \ud83d\udd27 **STEP-BY-STEP SETUP GUIDE**\n### 1\ufe0f\u20e3 **Create Your Telegram Bot** ***(2 minutes)***\nCreate a new bot to receive messages and files.\n- Open Telegram and send a message to the official `@BotFather`.\n- Send the command `/newbot` and follow the prompts to give your bot a name and username.\n- \u2757\ufe0f**Important:** BotFather will give you a unique **API Token**. Copy and save this token for the next step.\n\n### 2\ufe0f\u20e3 **Configure n8n Credentials**\nAdd the bot's API Token to your n8n instance.\n- In n8n, navigate to the **Credentials** section in the left panel.\n- Click **Add credential**, search for \"Telegram\", and select it.\n- Paste your API Token into the **Access Token** field and click **Save**.\n\n### 3\ufe0f\u20e3 **Update Workflow Settings**\nConnect your new credential to the required nodes in the workflow.\n- Open the **\"Waiting For Message\" (Telegram Trigger)** node and select your new credential from the dropdown menu.\n- Open the **\"Get & Download Attachment\" (Telegram)** node and select the *same* credential.\n\n### 4\ufe0f\u20e3 **Test Your Setup**\nActivate the workflow and send test messages to your bot.\n1. **Activate** the workflow using the toggle in the top-right corner.\n2. Send your bot a simple text message (e.g., \"Hello!\").\n3. Send your bot a file (like a PDF or image) *without* any text.\n4. Send your bot a file *with* a message (caption).\n5. Check the **Executions** list in n8n to see three successful runs, one for each test.\n\n### \u2705 **Setup complete!** Your workflow is now live and ready to parse incoming Telegram messages."
},
"typeVersion": 1
}
],
"connections": {
"Switch": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
],
[
{
"node": "Get Attachment Only",
"type": "main",
"index": 0
}
],
[
{
"node": "Get Chat Message Only",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Get Chat Message Content",
"type": "main",
"index": 0
},
{
"node": "Get Attachment",
"type": "main",
"index": 0
}
]
]
},
"Get Attachment": {
"main": [
[
{
"node": "Get & Download Attachment",
"type": "main",
"index": 0
}
]
]
},
"Get Attachment Only": {
"main": [
[
{
"node": "Get & Download Attachment",
"type": "main",
"index": 0
}
]
]
},
"Waiting For Message": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Get Chat Message Only": {
"main": [
[
{
"node": "Next Step ! ",
"type": "main",
"index": 0
}
]
]
},
"Get Chat Message Content": {
"main": [
[
{
"node": "Next Step !",
"type": "main",
"index": 0
}
]
]
},
"Get & Download Attachment": {
"main": [
[
{
"node": "Next Step ! ",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
telegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Tired of manually downloading a file through different Telegram messages? This workflow acts as a smart receptionist for your Telegram bot, automatically processing incoming messages to cleanly separate text from file attachments, getting them ready for any automation you can…
Source: https://n8n.io/workflows/9254/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
N8N Complete Final. Uses telegramTrigger, dataTable, telegram, mqtt. Event-driven trigger; 58 nodes.
TextMain. Uses telegramTrigger, stopAndError, telegram, httpRequest. Event-driven trigger; 56 nodes.
Pede Ai. Uses httpRequest, telegram, postgres, telegramTrigger. Event-driven trigger; 53 nodes.
📄 Documentation: Notion Guide
News Digest Bot - Multi-User (Postgres). Uses telegramTrigger, postgres, telegram, rssFeedRead. Event-driven trigger; 45 nodes.