Automatisation du traitement des messages Telegram
Ceci est unContent Creation, Multimodal AIworkflow d'automatisation du domainecontenant 17 nœuds.Utilise principalement des nœuds comme Set, Switch, SplitOut, Telegram, TelegramTrigger. Automatisation du traitement des messages Telegram - Séparation du texte et des fichiers
- •Token Bot Telegram
Nœuds utilisés (17)
Catégorie
{
"meta": {
"instanceId": "cd9bb7894b11bab249a60976239056d06e4831b51d7348f6790a85241c21fc56"
},
"nodes": [
{
"id": "6e742911-e7c0-47bc-b2f9-99789571617a",
"name": "En Attente de Message",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-480,
-64
],
"webhookId": "3d811399-b5e2-4c6c-833d-9c7c0b0ce4c6",
"parameters": {
"updates": [
"message"
],
"additionalFields": {
"download": false
}
},
"credentials": {
"telegramApi": {
"id": "KDZRFnPXPuAVravz",
"name": "Template"
}
},
"typeVersion": 1.2
},
{
"id": "2d2c3f99-2df5-4971-bb9f-cfd5d20fa615",
"name": "Obtenir Uniquement le Message de Chat",
"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": "Commutateur",
"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": "Séparer",
"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": "Obtenir Uniquement la Pièce Jointe",
"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": "Obtenir et Télécharger la Pièce Jointe",
"type": "n8n-nodes-base.telegram",
"position": [
208,
-64
],
"webhookId": "d73ca4c3-e657-4205-9443-59c111c5cb5f",
"parameters": {
"fileId": "={{ $json.file_id || $json.message.document.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "KDZRFnPXPuAVravz",
"name": "Template"
}
},
"typeVersion": 1.2
},
{
"id": "ed661779-1132-43e3-98bb-60933169e8ec",
"name": "Obtenir la Pièce Jointe",
"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": "Étape Suivante !",
"type": "n8n-nodes-base.noOp",
"position": [
416,
-448
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d478957b-8d4f-4c85-8684-9be3311a59f7",
"name": "Étape Suivante !",
"type": "n8n-nodes-base.noOp",
"position": [
416,
-64
],
"parameters": {},
"typeVersion": 1
},
{
"id": "cb0d1d8d-2c9b-48f2-af3d-3eab61173d3d",
"name": "Étape Suivante !",
"type": "n8n-nodes-base.noOp",
"position": [
208,
128
],
"parameters": {},
"typeVersion": 1
},
{
"id": "3717aff4-90a4-4d7d-936a-d0dd4ad2e7e8",
"name": "Obtenir le Contenu du Message de Chat",
"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": "Note Adhésive3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-560,
-768
],
"parameters": {
"width": 1184,
"height": 1072,
"content": "## 💬 **Telegram Message Parser - Separate Text and Files** ᯓ➤\n### ⚡️ **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### ✅ **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### 🎯 **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": "Note Adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
-768
],
"parameters": {
"width": 592,
"height": 576,
"content": "## 🔄 **WORKFLOW FLOW EXPLAINED**\n### ➡️ **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### 🔀 **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### ⚙️ **PROCESSING STAGE**\n- Set Nodes → 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### 🏁 **OUTPUT STAGE**\n- Telegram Node → 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": "Note Adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-560,
320
],
"parameters": {
"width": 1184,
"height": 288,
"content": "## 🙏 **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": "Note Adhésive2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1168,
-768
],
"parameters": {
"width": 592,
"height": 352,
"content": "## 🛠️ **CUSTOMIZATION OPTIONS**\n### ▶️ **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### ▶️ **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": "Note Adhésive4",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
-176
],
"parameters": {
"width": 592,
"height": 480,
"content": "## 🩺 TROUBLESHOOTING\n### ❌ **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### ✅ **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": "Note Adhésive5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1168,
-400
],
"parameters": {
"width": 592,
"height": 784,
"content": "## 🔧 **STEP-BY-STEP SETUP GUIDE**\n### 1️⃣ **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- ❗️**Important:** BotFather will give you a unique **API Token**. Copy and save this token for the next step.\n\n### 2️⃣ **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️⃣ **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️⃣ **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### ✅ **Setup complete!** Your workflow is now live and ready to parse incoming Telegram messages."
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"f06208a9-b6d8-4af1-9cc6-bb68f580df29": {
"main": [
[
{
"node": "74a133e1-f969-4fb9-8661-c323279fca27",
"type": "main",
"index": 0
}
],
[
{
"node": "344226d7-fc3f-4170-ada7-6300c31b3f0d",
"type": "main",
"index": 0
}
],
[
{
"node": "2d2c3f99-2df5-4971-bb9f-cfd5d20fa615",
"type": "main",
"index": 0
}
]
]
},
"74a133e1-f969-4fb9-8661-c323279fca27": {
"main": [
[
{
"node": "3717aff4-90a4-4d7d-936a-d0dd4ad2e7e8",
"type": "main",
"index": 0
},
{
"node": "ed661779-1132-43e3-98bb-60933169e8ec",
"type": "main",
"index": 0
}
]
]
},
"ed661779-1132-43e3-98bb-60933169e8ec": {
"main": [
[
{
"node": "0dbedca1-1b6d-47ab-8374-1a094d055962",
"type": "main",
"index": 0
}
]
]
},
"344226d7-fc3f-4170-ada7-6300c31b3f0d": {
"main": [
[
{
"node": "0dbedca1-1b6d-47ab-8374-1a094d055962",
"type": "main",
"index": 0
}
]
]
},
"6e742911-e7c0-47bc-b2f9-99789571617a": {
"main": [
[
{
"node": "f06208a9-b6d8-4af1-9cc6-bb68f580df29",
"type": "main",
"index": 0
}
]
]
},
"2d2c3f99-2df5-4971-bb9f-cfd5d20fa615": {
"main": [
[
{
"node": "cb0d1d8d-2c9b-48f2-af3d-3eab61173d3d",
"type": "main",
"index": 0
}
]
]
},
"3717aff4-90a4-4d7d-936a-d0dd4ad2e7e8": {
"main": [
[
{
"node": "cb0d1d8d-2c9b-48f2-af3d-3eab61173d3d",
"type": "main",
"index": 0
}
]
]
},
"0dbedca1-1b6d-47ab-8374-1a094d055962": {
"main": [
[
{
"node": "cb0d1d8d-2c9b-48f2-af3d-3eab61173d3d",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Avancé - Création de contenu, IA Multimodale
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
EoCi - Mr.Eo
@eocimreoPartager ce workflow