Automatisation de la transition du support Telegram
Ceci est unSupport Chatbot, AI Chatbotworkflow d'automatisation du domainecontenant 40 nœuds.Utilise principalement des nœuds comme If, Set, Switch, Telegram, DataTable. Automatiser la transition du support AI à l'agent humain pour Telegram avec GPT4 et des rappels par e-mail
- •Token Bot Telegram
- •Peut nécessiter les informations d'identification d'authentification de l'API cible
- •Clé API OpenAI
Nœuds utilisés (40)
Catégorie
{
"meta": {
"instanceId": "cfcdd4aa7acb600106c0a4bff4e6959e8e3b32b3b8cbc7d93531b2a4c9012a32"
},
"nodes": [
{
"id": "2dabfa67-8f0b-4662-a929-df1e5bb7037e",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
16,
448
],
"webhookId": "5e5e14f9-5505-466d-b367-7b724bbc0eb5",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "3aAMn4FfzzRDDtfF",
"name": "Loop Template Bot"
}
},
"typeVersion": 1.2
},
{
"id": "b952c1e1-1377-4205-9c92-0702cac12708",
"name": "Configuration",
"type": "n8n-nodes-base.set",
"position": [
608,
528
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "4439ddcb-8bf4-4f40-8461-02f8ba5795d9",
"name": "user",
"type": "string",
"value": "={{ $('Telegram Trigger').item.json.message.from.id }}"
},
{
"id": "c7c23d1c-8325-485a-82b3-784a45f0c7cc",
"name": "smtp",
"type": "string",
"value": "SMTP_ACCOUNT_MAIL"
},
{
"id": "a20a4051-2916-4072-a156-6cc9efeb18d4",
"name": "operator",
"type": "string",
"value": "OPERATOR_MAIL"
},
{
"id": "b94071df-a56f-4ee7-a260-536924518fcb",
"name": "personal",
"type": "string",
"value": "YOUR_PERSONAL_ID(TELEGRAM)"
},
{
"id": "6e49c76e-3308-4691-8996-a98b4e1fcbd8",
"name": "group",
"type": "string",
"value": "GROUP_ID"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "894b9666-fa3f-485c-8330-4890542c65e2",
"name": "Confirmer l'opérateur",
"type": "n8n-nodes-base.telegram",
"position": [
1680,
480
],
"webhookId": "24b54c8f-858f-4313-84f5-8d7190ccfd3a",
"parameters": {
"chatId": "={{ $('Configuration').item.json.user }}",
"message": "Confirm switching to operator?",
"options": {
"appendAttribution": false
},
"operation": "sendAndWait",
"approvalOptions": {
"values": {
"approvalType": "double"
}
}
},
"credentials": {
"telegramApi": {
"id": "3aAMn4FfzzRDDtfF",
"name": "Loop Template Bot"
}
},
"typeVersion": 1.2
},
{
"id": "d82fb377-0efe-43a7-ae6f-73d577b0e3c9",
"name": "Utilisateur approuvé",
"type": "n8n-nodes-base.if",
"position": [
1856,
480
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "85d3c27f-d003-4d7c-b0ff-65574db8385c",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.data.approved }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "4e9e61ed-ba5c-4450-8ee7-f9ea832ba16d",
"name": "Alerter l'opérateur",
"type": "n8n-nodes-base.emailSend",
"position": [
2048,
416
],
"webhookId": "70b1a1dd-4530-4ecb-96d0-f8179cf3e7e6",
"parameters": {
"message": "=User called {{ $('Telegram Trigger').item.json.message.from.username }} has requested an operator in Telegram chat. Please approve this message if the operator will be attending.\n\n**This message will expire in 15 minutes.**\n",
"options": {
"limitWaitTime": {
"values": {
"resumeUnit": "minutes",
"resumeAmount": 15
}
},
"appendAttribution": false
},
"subject": "User Requires Attention",
"toEmail": "={{ $('Configuration').item.json.operator }}",
"fromEmail": "={{ $('Configuration').item.json.smtp }}",
"operation": "sendAndWait",
"approvalOptions": {
"values": {
"approveLabel": "Create Topic"
}
}
},
"credentials": {
"smtp": {
"id": "4DkwbpaAtif3n8IV",
"name": "SMTP MookieLianHD Gmail"
}
},
"typeVersion": 2.1
},
{
"id": "ba253ae3-9c3f-49b9-be17-38c039cf75b6",
"name": "Modèle de chat OpenRouter",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
1184,
768
],
"parameters": {
"model": "x-ai/grok-4-fast",
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "d23pUD37RPrT3pC2",
"name": "OpenRouter account"
}
},
"typeVersion": 1
},
{
"id": "3e5cf322-3f81-460e-8d69-8814c518d504",
"name": "Opérateur confirmé",
"type": "n8n-nodes-base.if",
"position": [
2224,
416
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "d06816f2-6906-4167-a7f5-acb348f5678c",
"operator": {
"type": "boolean",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.data.approved }}",
"rightValue": ""
},
{
"id": "524fefa4-f84b-4725-8500-f8ed9b788bd0",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.data.approved }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "4bfcbf4e-1b16-4993-8b9a-1711fcda85f1",
"name": "Présence de l'opérateur",
"type": "n8n-nodes-base.telegram",
"position": [
2416,
336
],
"webhookId": "6952808f-55d4-4766-9448-d1f28e1006b2",
"parameters": {
"text": "Operator will be with you shortly.",
"chatId": "={{ $('Configuration').item.json.user }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "3aAMn4FfzzRDDtfF",
"name": "Loop Template Bot"
}
},
"typeVersion": 1.2
},
{
"id": "111c38e7-f287-4414-9e8c-6040f322ad1a",
"name": "Présence de l'opérateur refusée",
"type": "n8n-nodes-base.telegram",
"position": [
2416,
496
],
"webhookId": "6952808f-55d4-4766-9448-d1f28e1006b2",
"parameters": {
"text": "Unfortunately, the operator is not free at the moment.",
"chatId": "={{ $('Configuration').item.json.user }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "3aAMn4FfzzRDDtfF",
"name": "Loop Template Bot"
}
},
"typeVersion": 1.2
},
{
"id": "e48beba6-5267-489a-a929-0f8b019f5919",
"name": "Agent IA",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1184,
608
],
"parameters": {
"text": "={{ $('Telegram Trigger').item.json.message.text }}",
"options": {
"systemMessage": "You are a helpful assistant on Telegram platform. To reply to users, call 'Reply to User' tool.\n\n**Critical: Call 'Reply to User' tool once.\n\n**Critical: When users ask to chat with a human agent, reply with 'Human' instead, with no punctuation marks. Do not call the 'Reply To User' tool in this case.**"
},
"promptType": "define",
"needsFallback": true
},
"typeVersion": 2.2
},
{
"id": "8cfdfc0a-893c-4b6c-99df-b3254ad809a4",
"name": "Mémoire simple",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
1280,
1104
],
"parameters": {
"sessionKey": "={{ $('Configuration').item.json.user }}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "4016ffe6-e825-4f92-95b2-082dec181696",
"name": "Répondre à l'utilisateur",
"type": "n8n-nodes-base.telegramTool",
"position": [
1328,
800
],
"webhookId": "32b26e29-eae9-48fa-939b-7fc142656da5",
"parameters": {
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', `Reply message to be sent to user.`, 'string') }}",
"chatId": "={{ $('Configuration').item.json.user }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "3aAMn4FfzzRDDtfF",
"name": "Loop Template Bot"
}
},
"typeVersion": 1.2
},
{
"id": "a8033517-b6e8-44f9-87d2-2a228f396245",
"name": "Demande humaine",
"type": "n8n-nodes-base.if",
"position": [
1488,
608
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2c353a33-ef9c-4ef5-b019-7875e8f80d85",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output }}",
"rightValue": "Human"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "bfe3aa80-2b10-4dd2-8544-e9456a37d0a0",
"name": "Azure OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
"position": [
1232,
928
],
"parameters": {
"model": "gpt-4o-mini",
"options": {}
},
"credentials": {
"azureOpenAiApi": {
"id": "4WyMLAYYCsugTVtc",
"name": "Azure Open AI account"
}
},
"typeVersion": 1
},
{
"id": "6dca4f2a-7f5a-49e3-93a2-e3ed0b21b14a",
"name": "Mettre à jour le dernier message",
"type": "n8n-nodes-base.dataTable",
"position": [
2048,
816
],
"parameters": {
"columns": {
"value": {
"type": "ai"
},
"schema": [
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "type",
"defaultMatch": false
},
{
"id": "user",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "user",
"defaultMatch": false
},
{
"id": "topic",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "topic",
"defaultMatch": false
},
{
"id": "status",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyName": "user",
"keyValue": "={{ $('Configuration').item.json.user }}"
}
]
},
"options": {},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "nSoKY9F43bObeGqD",
"cachedResultUrl": "/projects/M1iORETinbUGzqtC/datatables/nSoKY9F43bObeGqD",
"cachedResultName": "Temporary Last Message"
}
},
"typeVersion": 1
},
{
"id": "84786a93-07fe-47ac-96f5-54f4a2c76e83",
"name": "Dernier message existant",
"type": "n8n-nodes-base.dataTable",
"position": [
1680,
736
],
"parameters": {
"filters": {
"conditions": [
{
"keyName": "user",
"keyValue": "={{ $('Configuration').item.json.user }}"
},
{
"keyName": "status",
"keyValue": "open"
}
]
},
"operation": "rowExists",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "nSoKY9F43bObeGqD",
"cachedResultUrl": "/projects/M1iORETinbUGzqtC/datatables/nSoKY9F43bObeGqD",
"cachedResultName": "Temporary Last Message"
}
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "a27e8718-7b93-4460-9183-c80453158b54",
"name": "Ligne vide",
"type": "n8n-nodes-base.if",
"position": [
1856,
736
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "76c55b53-23a0-4afc-8250-e3d230286d61",
"operator": {
"type": "object",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "539e9e73-006b-4ef0-8dc3-ee3c2bcaf27e",
"name": "Créer un message temporaire",
"type": "n8n-nodes-base.dataTable",
"position": [
2048,
656
],
"parameters": {
"columns": {
"value": {
"type": "ai",
"user": "={{ $('Configuration').item.json.user }}",
"status": "open"
},
"schema": [
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "type",
"defaultMatch": false
},
{
"id": "user",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "user",
"defaultMatch": false
},
{
"id": "topic",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "topic",
"defaultMatch": false
},
{
"id": "status",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "nSoKY9F43bObeGqD",
"cachedResultUrl": "/projects/M1iORETinbUGzqtC/datatables/nSoKY9F43bObeGqD",
"cachedResultName": "Temporary Last Message"
}
},
"typeVersion": 1
},
{
"id": "0055bb76-2c3c-49ad-8381-21b951bfa3a0",
"name": "Mettre à jour le message temporaire",
"type": "n8n-nodes-base.dataTable",
"position": [
2784,
336
],
"parameters": {
"columns": {
"value": {
"type": "human",
"topic": "={{ $json.result.message_thread_id }}",
"status": "open"
},
"schema": [
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "type",
"defaultMatch": false
},
{
"id": "user",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "user",
"defaultMatch": false
},
{
"id": "topic",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "topic",
"defaultMatch": false
},
{
"id": "status",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyName": "user",
"keyValue": "={{ $('Configuration').item.json.user }}"
}
]
},
"options": {},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "nSoKY9F43bObeGqD",
"cachedResultUrl": "/projects/M1iORETinbUGzqtC/datatables/nSoKY9F43bObeGqD",
"cachedResultName": "Temporary Last Message"
}
},
"typeVersion": 1
},
{
"id": "491171e9-75d7-429b-a280-2d099d9d6ab3",
"name": "Obtenir le message temporaire",
"type": "n8n-nodes-base.dataTable",
"position": [
784,
528
],
"parameters": {
"filters": {
"conditions": [
{
"keyName": "user",
"keyValue": "={{ $json.user }}"
},
{
"keyName": "status",
"keyValue": "open"
}
]
},
"matchType": "allConditions",
"operation": "get",
"returnAll": true,
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "nSoKY9F43bObeGqD",
"cachedResultUrl": "/projects/M1iORETinbUGzqtC/datatables/nSoKY9F43bObeGqD",
"cachedResultName": "Temporary Last Message"
}
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "ba334b52-a555-4d95-9eae-a840f5dbfd84",
"name": "Routeur de messages",
"type": "n8n-nodes-base.switch",
"position": [
976,
512
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "human",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2d381ff5-c197-4de5-90ab-43e1163d8f74",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.type }}",
"rightValue": "human"
}
]
},
"renameOutput": true
},
{
"outputKey": "empty",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "ca6f18b7-cc9f-4058-b134-f6cb731a0bd6",
"operator": {
"type": "object",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "ai",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "4a69a2ff-9ee3-476d-bef9-b82a7fe673a7",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.type }}",
"rightValue": "ai"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.3
},
{
"id": "4183f326-c94f-46ad-a86f-30aee2edcd7e",
"name": "Personnel",
"type": "n8n-nodes-base.set",
"position": [
3280,
736
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "4439ddcb-8bf4-4f40-8461-02f8ba5795d9",
"name": "personal",
"type": "string",
"value": "={{ $json.message.from.id }}"
},
{
"id": "899b32df-0124-4751-a09b-21e0afa9b3e6",
"name": "group",
"type": "string",
"value": "={{ $json.message.chat.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "befed495-26fc-45d4-a8d6-66d6b314b201",
"name": "Créer un sujet",
"type": "n8n-nodes-base.httpRequest",
"position": [
2592,
336
],
"parameters": {
"url": "https://api.telegram.org/botBOT_TOKEN/createForumTopic",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $('Configuration').item.json.group }}"
},
{
"name": "name",
"value": "={{ $('Configuration').item.json.user }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "72ce66dd-e1b0-4d97-9b69-1337f8c2d01a",
"name": "Message texte",
"type": "n8n-nodes-base.if",
"position": [
400,
608
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "10537cf3-851f-48c1-94cb-739a47f0cd58",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "13e7a069-6cdd-485e-bdf9-48e3fd55e19e",
"name": "Arrêter le workflow",
"type": "n8n-nodes-base.noOp",
"position": [
608,
688
],
"parameters": {},
"typeVersion": 1
},
{
"id": "b5a3d335-b762-4331-a051-3d75e5258788",
"name": "Transférer le message au groupe",
"type": "n8n-nodes-base.httpRequest",
"position": [
1184,
432
],
"parameters": {
"url": "https://api.telegram.org/botBOT_TOKEN/forwardMessage",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $('Configuration').item.json.group }}"
},
{
"name": "from_chat_id",
"value": "={{ $('Configuration').item.json.user }}"
},
{
"name": "message_id",
"value": "={{ $('Telegram Trigger').item.json.message.message_id }}"
},
{
"name": "message_thread_id",
"value": "={{ $('Get Temporary Message').item.json.topic }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "a90da098-55c7-4d79-8cd9-438cdaff33ff",
"name": "Message de sujet",
"type": "n8n-nodes-base.if",
"position": [
176,
448
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "d5a195e5-5d30-4404-897c-972154ae4776",
"operator": {
"type": "boolean",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.is_topic_message }}",
"rightValue": ""
},
{
"id": "1ca6b333-5a2e-4196-98da-ddb9c81a0d74",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.message.is_topic_message }}",
"rightValue": ""
},
{
"id": "e07c655e-c4ae-4883-bc15-a39ee6e6dd93",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "29fe28b7-3973-41ec-b9c4-c04ce6f9496a",
"name": "Administrateurs du chat",
"type": "n8n-nodes-base.httpRequest",
"position": [
3200,
1024
],
"parameters": {
"url": "https://api.telegram.org/botYOUR_TOKEN/getChatAdministrators",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "=GROUP_ID"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "e64ca366-4c82-4693-90b0-75e36f2775a3",
"name": "Transférer le message",
"type": "n8n-nodes-base.httpRequest",
"position": [
608,
368
],
"parameters": {
"url": "https://api.telegram.org/botBOT_TOKEN/forwardMessage",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $('Telegram Trigger').item.json.message.reply_to_message.forum_topic_created.name }}"
},
{
"name": "from_chat_id",
"value": "={{ $('Telegram Trigger').item.json.message.reply_to_message.chat.id }}"
},
{
"name": "message_id",
"value": "={{ $('Telegram Trigger').item.json.message.message_id }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "b5f03bf1-d898-4b3b-bbaf-bf7092100420",
"name": "Déclencheur personnel",
"type": "n8n-nodes-base.telegramTrigger",
"disabled": true,
"position": [
3136,
736
],
"webhookId": "5e5e14f9-5505-466d-b367-7b724bbc0eb5",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "3aAMn4FfzzRDDtfF",
"name": "Loop Template Bot"
}
},
"typeVersion": 1.2
},
{
"id": "ce4fd19f-1ee3-4932-a43c-0838e5f95a4e",
"name": "Sortie",
"type": "n8n-nodes-base.if",
"position": [
400,
288
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "bc53c1d9-bfee-40f8-8cbf-f78757526fa1",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
"rightValue": "exit"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "420d646c-8db9-4c61-9517-42ec946bd4e8",
"name": "Fermer le sujet",
"type": "n8n-nodes-base.httpRequest",
"position": [
608,
192
],
"parameters": {
"url": "https://api.telegram.org/botBOT_TOKEN/closeForumTopic",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $('Telegram Trigger').item.json.message.reply_to_message.chat.id }}"
},
{
"name": "message_thread_id",
"value": "={{ $('Telegram Trigger').item.json.message.reply_to_message.message_thread_id }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "ada57ab7-782d-4bcf-8c24-3e68afd8aa37",
"name": "Mettre à jour le sujet fermé",
"type": "n8n-nodes-base.dataTable",
"position": [
784,
192
],
"parameters": {
"columns": {
"value": {
"status": "closed"
},
"schema": [
{
"id": "type",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "type",
"defaultMatch": false
},
{
"id": "user",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "user",
"defaultMatch": false
},
{
"id": "topic",
"type": "number",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "topic",
"defaultMatch": false
},
{
"id": "status",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "status",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyName": "topic",
"keyValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message.message_thread_id }}"
}
]
},
"options": {},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "nSoKY9F43bObeGqD",
"cachedResultUrl": "/projects/M1iORETinbUGzqtC/datatables/nSoKY9F43bObeGqD",
"cachedResultName": "Temporary Last Message"
}
},
"typeVersion": 1
},
{
"id": "120db6ad-faf1-4117-82ab-f878d6bc37dd",
"name": "Note adhésive17",
"type": "n8n-nodes-base.stickyNote",
"position": [
2336,
1200
],
"parameters": {
"color": 5,
"width": 1680,
"height": 80,
"content": "# Credentials"
},
"typeVersion": 1
},
{
"id": "7dca3dc6-3735-49c6-85fd-10b4a4f3326b",
"name": "Note adhésive18",
"type": "n8n-nodes-base.stickyNote",
"position": [
2976,
272
],
"parameters": {
"color": 6,
"width": 560,
"height": 928,
"content": "## Telegram - [Docs](https://docs.n8n.io/integrations/builtin/credentials/telegram/)\n\n### Bot Creation\n1. Message BotFather, create new bot and copy token.\n2. Paste token in n8n and save credentials. Name it something unique to identify it(e.g. Handover Bot). \n\n### Group Creation/Support UI\n1. Create a new group from Telegram dropdown menu. Go to Settings and enable Topics. Telegram will automatically create General topic.\n2. From Settings go to Administrators and add your bot as admin. Give 'Read and Manage Topics' permissions.\n\n### Related to Workflow\n\n- To get your group id and personal id deactivate main trigger and activate the one below. Send a message to your group and come back to executions tab. These ID's are required for Configuration node.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n- To check if the Bot is properly added to your group as admin(sometimes n8n doesn't see the bot as admin) execute the node below with correct parameters. Keep in mind that you have to add your Bot Token to all HTTP Request nodes."
},
"typeVersion": 1
},
{
"id": "9c27036e-b7eb-4e71-86ef-cbfbd93ae9ff",
"name": "Note adhésive19",
"type": "n8n-nodes-base.stickyNote",
"position": [
3568,
432
],
"parameters": {
"color": 6,
"width": 448,
"height": 768,
"content": "## Configuration Node\n\n### SMTP Mail - [Docs](https://docs.n8n.io/integrations/builtin/credentials/sendemail/#related-resources)\n- Type in the the SMTP email that you created the credential with.\n- Here is how to setup the credentials for Gmail:\n\n1. Enable 2FA if you haven't already.\n2. Generate an app password and copy it.\n3. In n8n credential page follow these steps:\n\n1. Enter your Gmail email address as the User.\n2. Enter the app password you copied as the Password.\n3. Enter smtp.gmail.com as the Host.\n4. For the Port:\nKeep the default 465 for SSL or if you're unsure what to use.\nEnter 587 for TLS.\n5. Turn on the SSL/TLS toggle.\n\n### Operator\n- Type in the mail address which will receive the alert. Topic will be created only if the mail is confirmed.\n\n### Personal\n- This parameter is not required. Currently not being used in the workflow. You can type it in and use expressions to test pinned data. Otherwise, remove it.\n\n### Group ID\n- Type in the group id that you received from 'Personal Trigger'. Usually starts with '-10...'. This parameter is required."
},
"typeVersion": 1
},
{
"id": "9543d11d-2d11-4785-8534-d952c5952f57",
"name": "Note adhésive20",
"type": "n8n-nodes-base.stickyNote",
"position": [
2336,
752
],
"parameters": {
"color": 6,
"width": 592,
"height": 448,
"content": "## Data Tables - n8n\n\n### Creating a Table\n1. From n8n dashboard go to data tables section. Create a new table.\n2. Add type(string), status(string), topic(number), user(number) columns. **Make sure that each column exists**, otherwise workflow will return an error.\n\n### Alternatives\n- Data tables in n8n are for development stage. If you wish to scale this workflow and work with much bigger data **use hosted databases** (Postgres, Redis etc.)\n\n### Notes\n\n- In this workflow template, data tables are being used to track chat type('human', 'ai' etc.). However when your operator types in 'exit' in the Telegram topic, this row is not deleted. Its status column updates to 'closed'. This is **close to having a ticket system** where each ticket is saved as a row inside a database."
},
"typeVersion": 1
},
{
"id": "0b52da6c-a05e-4b00-b981-01a4d61a2b68",
"name": "Note adhésive21",
"type": "n8n-nodes-base.stickyNote",
"position": [
576,
960
],
"parameters": {
"color": 4,
"width": 560,
"height": 384,
"content": "# Overview Video - 1 Minute\n[](https://youtu.be/U1HBdilbvzc)"
},
"typeVersion": 1
},
{
"id": "4478a416-f352-4f2b-924c-95a2cbdf18ca",
"name": "Note adhésive22",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
912
],
"parameters": {
"color": 4,
"width": 560,
"height": 432,
"content": "# Detailed Setup Video - 10 Minutes\n[](https://youtu.be/Rjj_g9HEuqw)"
},
"typeVersion": 1
},
{
"id": "55172322-f2fe-4245-996e-254ddfcef702",
"name": "Note adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-624,
192
],
"parameters": {
"color": 5,
"width": 576,
"height": 1152,
"content": "# Welcome\n\nTelegram Handover Template by [mookielian](https://n8n.io/creators/mookielian)!\n\n## Before You Start\n\nThis template requires **intermediate knowledge** of workflow logic and APIs. A detailed video guide is available, but please review each node and understand the basics before starting. Consider using the [Telegram Extended community node](https://www.npmjs.com/package/n8n-nodes-telegram-extended) for easier forum operations.\n\n## Quick Setup\n\n### 1. Prerequisites\n\nCreate a Telegram bot via BotFather, set up a group with Topics enabled, add your bot as admin, and prepare a data table with columns: `user`, `type`, `topic`, and `status`. Configure SMTP for operator email alerts.\n\n### 2. Key Nodes\n\n**Configuration Node**: Set operator email and Telegram group chat ID.\n\n**Telegram Trigger**: Connect bot credentials to receive all updates.\n\n**AI Agent**: Select your AI model and customize the system prompt while keeping critical headers. The \"Reply To User\" tool sends Telegram messages. Memory uses a 5-message buffer (upgrade to database for production).\n\n**Data Tables**: Ensure column names match exactly: `user`, `type`, `topic`, `status`.\n\n### 3. How It Works\n\nOperator messages in topics forward to users (\"exit\" closes topics). User DMs route based on status: new/AI users go to the AI agent, human status users forward to operator topics.\n\nHandover flow: AI detects need → asks user confirmation → emails operator → operator confirms → creates topic → updates status → notifies user.\n\n### 4. Production Checklist\n\n- Replace memory buffer with proper database\n- Customize AI system prompt for your use case\n- Test handover scenarios thoroughly\n- Set up monitoring and rate limiting\n\n**Note**: Currently text-only. File processing is blocked to save tokens but can be modified if needed."
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"ce4fd19f-1ee3-4932-a43c-0838e5f95a4e": {
"main": [
[
{
"node": "420d646c-8db9-4c61-9517-42ec946bd4e8",
"type": "main",
"index": 0
}
],
[
{
"node": "e64ca366-4c82-4693-90b0-75e36f2775a3",
"type": "main",
"index": 0
}
]
]
},
"e48beba6-5267-489a-a929-0f8b019f5919": {
"main": [
[
{
"node": "a8033517-b6e8-44f9-87d2-2a228f396245",
"type": "main",
"index": 0
}
]
]
},
"420d646c-8db9-4c61-9517-42ec946bd4e8": {
"main": [
[
{
"node": "ada57ab7-782d-4bcf-8c24-3e68afd8aa37",
"type": "main",
"index": 0
}
]
]
},
"befed495-26fc-45d4-a8d6-66d6b314b201": {
"main": [
[
{
"node": "0055bb76-2c3c-49ad-8381-21b951bfa3a0",
"type": "main",
"index": 0
}
]
]
},
"a27e8718-7b93-4460-9183-c80453158b54": {
"main": [
[
{
"node": "539e9e73-006b-4ef0-8dc3-ee3c2bcaf27e",
"type": "main",
"index": 0
}
],
[
{
"node": "6dca4f2a-7f5a-49e3-93a2-e3ed0b21b14a",
"type": "main",
"index": 0
}
]
]
},
"72ce66dd-e1b0-4d97-9b69-1337f8c2d01a": {
"main": [
[
{
"node": "b952c1e1-1377-4205-9c92-0702cac12708",
"type": "main",
"index": 0
}
],
[
{
"node": "13e7a069-6cdd-485e-bdf9-48e3fd55e19e",
"type": "main",
"index": 0
}
]
]
},
"b952c1e1-1377-4205-9c92-0702cac12708": {
"main": [
[
{
"node": "491171e9-75d7-429b-a280-2d099d9d6ab3",
"type": "main",
"index": 0
}
]
]
},
"4016ffe6-e825-4f92-95b2-082dec181696": {
"ai_tool": [
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "ai_tool",
"index": 0
}
]
]
},
"8cfdfc0a-893c-4b6c-99df-b3254ad809a4": {
"ai_memory": [
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "ai_memory",
"index": 0
}
]
]
},
"a90da098-55c7-4d79-8cd9-438cdaff33ff": {
"main": [
[
{
"node": "ce4fd19f-1ee3-4932-a43c-0838e5f95a4e",
"type": "main",
"index": 0
}
],
[
{
"node": "72ce66dd-e1b0-4d97-9b69-1337f8c2d01a",
"type": "main",
"index": 0
}
]
]
},
"d82fb377-0efe-43a7-ae6f-73d577b0e3c9": {
"main": [
[
{
"node": "4e9e61ed-ba5c-4450-8ee7-f9ea832ba16d",
"type": "main",
"index": 0
}
],
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "main",
"index": 0
}
]
]
},
"4e9e61ed-ba5c-4450-8ee7-f9ea832ba16d": {
"main": [
[
{
"node": "3e5cf322-3f81-460e-8d69-8814c518d504",
"type": "main",
"index": 0
}
]
]
},
"ba334b52-a555-4d95-9eae-a840f5dbfd84": {
"main": [
[
{
"node": "b5a3d335-b762-4331-a051-3d75e5258788",
"type": "main",
"index": 0
}
],
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "main",
"index": 0
}
],
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "main",
"index": 0
}
]
]
},
"a8033517-b6e8-44f9-87d2-2a228f396245": {
"main": [
[
{
"node": "894b9666-fa3f-485c-8330-4890542c65e2",
"type": "main",
"index": 0
}
],
[
{
"node": "84786a93-07fe-47ac-96f5-54f4a2c76e83",
"type": "main",
"index": 0
}
]
]
},
"894b9666-fa3f-485c-8330-4890542c65e2": {
"main": [
[
{
"node": "d82fb377-0efe-43a7-ae6f-73d577b0e3c9",
"type": "main",
"index": 0
}
]
]
},
"b5f03bf1-d898-4b3b-bbaf-bf7092100420": {
"main": [
[
{
"node": "4183f326-c94f-46ad-a86f-30aee2edcd7e",
"type": "main",
"index": 0
}
]
]
},
"2dabfa67-8f0b-4662-a929-df1e5bb7037e": {
"main": [
[
{
"node": "a90da098-55c7-4d79-8cd9-438cdaff33ff",
"type": "main",
"index": 0
}
]
]
},
"3e5cf322-3f81-460e-8d69-8814c518d504": {
"main": [
[
{
"node": "4bfcbf4e-1b16-4993-8b9a-1711fcda85f1",
"type": "main",
"index": 0
}
],
[
{
"node": "111c38e7-f287-4414-9e8c-6040f322ad1a",
"type": "main",
"index": 0
}
]
]
},
"84786a93-07fe-47ac-96f5-54f4a2c76e83": {
"main": [
[
{
"node": "a27e8718-7b93-4460-9183-c80453158b54",
"type": "main",
"index": 0
}
]
]
},
"4bfcbf4e-1b16-4993-8b9a-1711fcda85f1": {
"main": [
[
{
"node": "befed495-26fc-45d4-a8d6-66d6b314b201",
"type": "main",
"index": 0
}
]
]
},
"491171e9-75d7-429b-a280-2d099d9d6ab3": {
"main": [
[
{
"node": "ba334b52-a555-4d95-9eae-a840f5dbfd84",
"type": "main",
"index": 0
}
]
]
},
"ba253ae3-9c3f-49b9-be17-38c039cf75b6": {
"ai_languageModel": [
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"bfe3aa80-2b10-4dd2-8544-e9456a37d0a0": {
"ai_languageModel": [
[
{
"node": "e48beba6-5267-489a-a929-0f8b019f5919",
"type": "ai_languageModel",
"index": 1
}
]
]
}
}
}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é - Chatbot de support, Chatbot IA
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
Partager ce workflow