This workflow corresponds to n8n.io template #13394 — we link there as the canonical source.
This workflow follows the Agent → OpenAI Chat 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 →
{
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Telegram AI Chatbot with Human Takeover using Trilox",
"tags": [],
"nodes": [
{
"id": "bd8c533c-7405-47a0-a6d9-47671fea6e7f",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
2016,
400
],
"parameters": {
"text": "={{ $('Merge Text Input').item.json.text }}",
"options": {
"systemMessage": "You are a friendly AI assistant for \"TechHub\" \u2014 an online electronics store.\n\nAlways respond in **valid JSON** following this exact schema:\n{\n \"message\": \"your reply to the customer\",\n \"is_human_required\": false\n}\n\nKeep your tone friendly and concise (1\u20133 sentences).\n\n---\n\n**Business Info:**\n- Hours: Monday\u2013Friday 9 AM\u20136 PM, Saturday 10 AM\u20134 PM (EST)\n- Shipping: Free over $50 (5\u20137 days), Express $15 (2\u20133 days)\n- Products: smartphones, laptops, headphones, chargers, cases\n- Warranty: 1-year manufacturer warranty\n- Support email: user@example.com\n\n---\n\n**Escalation Rules (when is_human_required = true):**\n- Customer requests a refund or return\n- Customer has a complaint about an order\n- Customer asks about order status (you don't have access to orders)\n- Any topic you're unsure about \u2014 better to escalate than guess wrong\n\n**Never escalate for:**\n- General questions about hours, shipping, products, warranty\n\n---\n\n**Examples:**\n\nUser: \"What are your hours?\"\n{\"message\": \"We're open Monday\u2013Friday 9 AM\u20136 PM and Saturday 10 AM\u20134 PM EST!\", \"is_human_required\": false}\n\nUser: \"I want a refund\"\n{\"message\": \"I'll connect you with a team member who can help with your refund right away.\", \"is_human_required\": true}\n\n---\n\n\u26a0\ufe0f TEMPLATE NOTE: Replace this entire prompt with your own business info and escalation rules.\nThe structured JSON output format must stay the same \u2014 the workflow depends on it."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "719418b0-451a-4537-b9cd-b3afc2471108",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1968,
592
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "c63dc94b-c610-4f1c-b673-a38baf8bd2de",
"name": "Conversation Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
2064,
704
],
"parameters": {
"sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"sessionIdType": "customKey",
"contextWindowLength": 10
},
"typeVersion": 1.3
},
{
"id": "9d8884d3-4af5-4318-b232-803bc0607cf0",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
2208,
592
],
"parameters": {
"jsonSchemaExample": "{\n \"message\": \"Your response to the customer here\",\n \"is_human_required\": false\n}"
},
"typeVersion": 1.3
},
{
"id": "cd70daab-da7d-4b77-aca6-8f986553177c",
"name": "Handler Status Router",
"type": "n8n-nodes-base.switch",
"position": [
1632,
1072
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "bot",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "0c15b5a4-72f9-4fe7-9cb7-cb1f36d5dbea",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.handlerType }}",
"rightValue": "bot"
}
]
},
"renameOutput": true
},
{
"outputKey": "awaiting_human",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8e90caf8-443a-4731-b4b4-a35a23382437",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.handlerType }}",
"rightValue": "awaiting_human"
}
]
},
"renameOutput": true
},
{
"outputKey": "assigned_human",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2253ad21-ce46-432d-9c15-7d9ec4c95a73",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.handlerType }}",
"rightValue": "assigned_human"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "aca159b5-cb45-4012-aa19-5660470e9638",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-16,
1120
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "61779a6a-67dd-46b1-a7ec-560d79f9dd43",
"name": "Message Type Router",
"type": "n8n-nodes-base.switch",
"position": [
224,
1104
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "adc0d36c-aa57-4286-add2-1fb1fc3f8fd6",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Voice",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "acc4bc95-1dad-4b0a-b564-b431131fab39",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice.mime_type }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.2
},
{
"id": "1b49da3d-f949-453f-bf19-51b5fd0232b8",
"name": "Download Voice File",
"type": "n8n-nodes-base.telegram",
"position": [
512,
1168
],
"parameters": {
"fileId": "={{ $json.message.voice.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "3c3df40a-9fa6-4fda-8f35-b48ecb77d8f9",
"name": "Transcribe Voice Message",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
672,
1168
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.8
},
{
"id": "54e91bc6-6af2-4e2d-811e-3e9f7e57612e",
"name": "Merge Text Input",
"type": "n8n-nodes-base.merge",
"position": [
928,
1088
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "f8fcc53a-65e2-4ae1-9cb3-3d93545a169f",
"name": "Extract Text",
"type": "n8n-nodes-base.set",
"position": [
512,
1008
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "869d344f-19dc-4d34-9a8b-0d6e752a2efd",
"name": "text",
"type": "string",
"value": "={{ $json.message.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f50a4fba-a745-4164-a068-e338e42f1326",
"name": "Needs Human?",
"type": "n8n-nodes-base.if",
"position": [
3216,
256
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "18a21c48-81d4-446d-bd5b-72542ee68c3e",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $('AI Agent').item.json.output.is_human_required }}",
"rightValue": "false"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "0c8688c3-be15-46c8-bfb3-ffb8bbdc6725",
"name": "Send Bot Reply",
"type": "n8n-nodes-base.telegram",
"position": [
2800,
256
],
"parameters": {
"text": "={{ $('AI Agent').item.json.output.message }}",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "7621466b-526e-4edc-b53f-552f0f2b0b5e",
"name": "Handler Status Router 2",
"type": "n8n-nodes-base.switch",
"position": [
2592,
384
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "bot",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "0c15b5a4-72f9-4fe7-9cb7-cb1f36d5dbea",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.handlerType }}",
"rightValue": "bot"
}
]
},
"renameOutput": true
},
{
"outputKey": "awaiting_human",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8e90caf8-443a-4731-b4b4-a35a23382437",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.handlerType }}",
"rightValue": "awaiting_human"
}
]
},
"renameOutput": true
},
{
"outputKey": "assigned_human",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2253ad21-ce46-432d-9c15-7d9ec4c95a73",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.handlerType }}",
"rightValue": "assigned_human"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "7a6f54af-15de-457e-a56e-8deadae21809",
"name": "Done (No Escalation)",
"type": "n8n-nodes-base.noOp",
"position": [
3456,
352
],
"parameters": {},
"typeVersion": 1
},
{
"id": "37c6b17d-06e3-48c7-afb8-591e80aeffdc",
"name": "Suppress Bot Reply",
"type": "n8n-nodes-base.noOp",
"position": [
2800,
448
],
"parameters": {},
"typeVersion": 1
},
{
"id": "38667d28-efad-4464-9c41-75bcafce7d47",
"name": "Send Awaiting Message",
"type": "n8n-nodes-base.telegram",
"position": [
1984,
1088
],
"parameters": {
"text": "Thank you for your patience! A team member will be with you shortly.\n\u2014 System Message",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "2295314f-28be-40dd-9f57-638f88f714f4",
"name": "Bot Stays Silent",
"type": "n8n-nodes-base.noOp",
"position": [
2016,
1536
],
"parameters": {},
"typeVersion": 1
},
{
"id": "aecb50a8-8e05-4351-ac2e-77c63fa43e5d",
"name": "Forward to Telegram",
"type": "n8n-nodes-base.telegram",
"position": [
2480,
1536
],
"parameters": {
"text": "={{ $json.message }}",
"chatId": "={{ $json.chat_id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "712871d0-0f10-4b82-8acd-167052b103f4",
"name": "Record Visitor Message",
"type": "n8n-nodes-trilox.trilox",
"position": [
1168,
1088
],
"parameters": {
"appId": "",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"channel": "telegram",
"message": "={{ $json.text }}",
"senderType": "visitor"
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "3cfa9b44-671a-48cd-9a3f-09adfaa750fc",
"name": "Record Bot Response",
"type": "n8n-nodes-trilox.trilox",
"position": [
3008,
256
],
"parameters": {
"appId": "",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"channel": "telegram",
"message": "={{ $('AI Agent').item.json.output.message }}"
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "fb5b7df5-14e2-46ed-b005-9afb46442c4a",
"name": "Record Awaiting Message",
"type": "n8n-nodes-trilox.trilox",
"position": [
2192,
1088
],
"parameters": {
"appId": "",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"channel": "telegram",
"message": "={{ $json.result.text }}"
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "5fc27776-9ea9-4dbd-869f-7cee23b8eb48",
"name": "Check Handler (Pre-Bot)",
"type": "n8n-nodes-trilox.trilox",
"position": [
1392,
1088
],
"parameters": {
"appId": "",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"operation": "checkHandler"
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "05aed161-d1d9-426d-a891-bb9c3c04e833",
"name": "Check Handler (Post-Bot)",
"type": "n8n-nodes-trilox.trilox",
"position": [
2304,
400
],
"parameters": {
"appId": "",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"operation": "checkHandler"
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "7302b50e-557c-4e4c-90a9-a489360751e0",
"name": "Trilox Trigger (Agent Reply)",
"type": "n8n-nodes-trilox.triloxTrigger",
"position": [
2000,
1712
],
"parameters": {
"appId": ""
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "4e7cf467-50ac-4066-a8fd-d78be8950db9",
"name": "Escalate to Human",
"type": "n8n-nodes-trilox.trilox",
"position": [
3456,
208
],
"parameters": {
"appId": "",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"operation": "escalate"
},
"credentials": {
"triloxApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "28d84020-78d1-48a4-9870-749eb4a7c9d1",
"name": "Channel Router",
"type": "n8n-nodes-base.switch",
"position": [
2176,
1648
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "telegram",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "0c15b5a4-72f9-4fe7-9cb7-cb1f36d5dbea",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.channel }}",
"rightValue": "telegram"
}
]
},
"renameOutput": true
},
{
"outputKey": "whatsapp",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1575c9b1-8363-4e6d-a469-d56f44fbfbf2",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.channel }}",
"rightValue": "whatsapp"
}
]
},
"renameOutput": true
},
{
"outputKey": "messenger",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "53fa0520-44d0-4100-aaa1-682cf7f42198",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.channel }}",
"rightValue": "messenger"
}
]
},
"renameOutput": true
},
{
"outputKey": "instagram",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9290202c-9b0e-4f08-9f86-64cfcf340cd5",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.channel }}",
"rightValue": "instagram"
}
]
},
"renameOutput": true
},
{
"outputKey": "widget",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b18696bd-face-49bf-bd83-15a42026e69e",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.channel }}",
"rightValue": "widget"
}
]
},
"renameOutput": true
},
{
"outputKey": "API",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f3dae358-4eb8-4bca-bad2-f274490184d1",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.channel }}",
"rightValue": "api"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "aead1ed1-f034-41c7-b4fb-c1c6097d7402",
"name": "Other Channels (Placeholder)",
"type": "n8n-nodes-base.noOp",
"position": [
2496,
1728
],
"parameters": {},
"typeVersion": 1
},
{
"id": "2af0e5fa-e8f1-4eae-876c-1f19a13a644f",
"name": "Ignore Unsupported",
"type": "n8n-nodes-base.noOp",
"position": [
512,
1328
],
"parameters": {},
"typeVersion": 1
},
{
"id": "186d4e64-2163-477c-8d5f-36e0d8eed4a7",
"name": "Sticky Note - Setup Guide",
"type": "n8n-nodes-base.stickyNote",
"position": [
-784,
464
],
"parameters": {
"width": 680,
"height": 1200,
"content": "## \ud83e\udd16 Telegram AI Chatbot with Human Takeover\n\nA complete Telegram chatbot with AI responses, real-time monitoring, and human takeover \u2014 powered by **Trilox**.\n\nWhen the bot can't help (or says something wrong), a human can take over from the **Trilox inbox**. The bot goes silent. The human replies. When done, the bot takes back control.\n\nNo double replies. No embarrassing bot messages while you're trying to help a customer.\n\n### How it works\n1. Customer sends a message on Telegram (text or voice)\n2. Message is recorded to **Trilox** and the handler is checked\n3. If bot is in control \u2192 AI Agent responds using structured output\n4. After AI responds, handler is checked **again** (catches race conditions)\n5. If the AI decides a human is needed \u2192 conversation is escalated in **Trilox**\n6. Human takes over from the Trilox inbox \u2192 bot goes completely silent\n7. Human replies from Trilox \u2192 message is forwarded to customer via Telegram\n8. Human hands back to bot \u2192 bot resumes responding\n\n### \u26a0\ufe0f How to set up\n- [ ] Install the **Trilox community node** before importing (`n8n-nodes-trilox`)\n- [ ] Create a free account at [trilox.io](https://trilox.io)\n- [ ] Create a Project \u2192 App (inbox) \u2192 API Key in Trilox\n- [ ] Create a Telegram bot via [@BotFather](https://t.me/botfather)\n- [ ] In n8n, set up credentials for Trilox and Telegram\n- [ ] In all Trilox nodes, select your App (inbox) from the dropdown\n- [ ] Connect your LLM (OpenAI, OpenRouter, Anthropic, etc.)\n- [ ] Update the AI Agent system prompt for your business\n- [ ] **Test it:** Message your bot \u2192 check the Trilox inbox \u2192 take over \u2192 reply\n\n### Requirements\n- Trilox account ([trilox.io](https://trilox.io)) \u2014 free plan available\n- Telegram Bot (via @BotFather)\n- OpenAI or any LLM provider\n\n### How to customize\n- **Your business:** Change the system prompt with your FAQ, products, and escalation rules\n- **Escalation rules:** Edit the prompt to define when `is_human_required` should be true (refunds, complaints, complex questions)\n- **Other channels:** Replace Telegram trigger with WhatsApp/Messenger \u2014 update the channel field in Trilox nodes\n- **Remove voice support:** Delete the voice branch if you don't need it\n- **Multi-channel:** The agent reply router already has placeholders for WhatsApp, Messenger, Instagram, Widget, and API\n\n**Need help?** Join our Discord: [discord.gg/g9e6YTqmUs](https://discord.gg/g9e6YTqmUs)"
},
"typeVersion": 1
},
{
"id": "c6be7413-cb54-4dc8-bb3c-f7e34a3b9770",
"name": "Sticky Note - Message Intake",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
880
],
"parameters": {
"color": 7,
"width": 520,
"height": 360,
"content": "## 1\ufe0f\u20e3 Message Intake\nReceive Telegram messages and normalize them into a single text field.\n\n**Text messages** \u2192 extracted directly\n**Voice messages** \u2192 downloaded and transcribed via OpenAI Whisper (requires OpenAI API key)\n**Other types** \u2192 ignored (fallback)\n\n\ud83d\udca1 Don't need voice support? Delete the voice branch and connect Text \u2192 Merge directly."
},
"typeVersion": 1
},
{
"id": "84e8e26f-d970-4a09-a60a-22f6decd2d3c",
"name": "Sticky Note - Record & Check",
"type": "n8n-nodes-base.stickyNote",
"position": [
1088,
880
],
"parameters": {
"color": 7,
"width": 488,
"height": 368,
"content": "## 2\ufe0f\u20e3 Record & Check Handler\nLog the visitor message to **Trilox**, then check who's handling this conversation.\n\n**Check Handler** returns `handlerType`:\n- `bot` \u2192 AI Agent responds\n- `awaiting_human` \u2192 Send \"someone will reply soon\"\n- `assigned_human` \u2192 Bot stays completely silent"
},
"typeVersion": 1
},
{
"id": "d89259ca-7365-4f8d-9f83-d5cbcc995c8a",
"name": "Sticky Note - Bot Handler",
"type": "n8n-nodes-base.stickyNote",
"position": [
1920,
32
],
"parameters": {
"color": 4,
"width": 596,
"height": 876,
"content": "## 3\ufe0f\u20e3 Bot Handler\nAI Agent generates a response with structured output:\n```json\n{\n \"message\": \"reply text\",\n \"is_human_required\": true/false\n}\n```\n\n**Critical:** After AI responds, we check the handler **again**.\nWhy? The AI may take 5-30 seconds to think. If a human took over during that time, we suppress the bot reply. This prevents the **double-reply problem**.\n\nIf `is_human_required` is true \u2192 **Escalate to Human** in Trilox."
},
"typeVersion": 1
},
{
"id": "68ea2ee3-8184-4b78-8964-abb16adf6ff3",
"name": "Sticky Note - Awaiting Human",
"type": "n8n-nodes-base.stickyNote",
"position": [
1920,
944
],
"parameters": {
"color": 3,
"width": 600,
"height": 328,
"content": "## 4\ufe0f\u20e3 Awaiting Human\nConversation has been escalated but no human has picked it up yet.\n\nSend the customer a courtesy message and log it to Trilox."
},
"typeVersion": 1
},
{
"id": "7a404979-7bd6-4006-b514-0ff97247c5d1",
"name": "Sticky Note - Human Agent Reply",
"type": "n8n-nodes-base.stickyNote",
"position": [
1904,
1312
],
"parameters": {
"color": 6,
"width": 624,
"height": 748,
"content": "## 5\ufe0f\u20e3 Human Agent Reply\n**Trilox Trigger** fires when a human replies from the Trilox inbox.\n\nThe **Channel Router** checks which platform the conversation is on and forwards the human's reply to the correct channel.\n\nAll supported channels have placeholder outputs \u2014 connect your WhatsApp, Messenger, Instagram, or Widget nodes as needed."
},
"typeVersion": 1
},
{
"id": "1e74811d-db50-4f79-af01-61cc7596dc44",
"name": "Sticky Note - Quick Test",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
1280
],
"parameters": {
"color": 5,
"width": 440,
"height": 380,
"content": "## \ud83e\uddea Quick Test\n\n1. Activate this workflow\n2. Message your Telegram bot: **\"Hi, what are your hours?\"**\n3. Open Trilox inbox \u2192 you should see the conversation\n4. Message: **\"I need a refund\"** \u2192 bot escalates to human\n5. In Trilox inbox, click **Take Over**\n6. Reply from Trilox \u2192 customer receives your message on Telegram\n7. Click **Hand Back to Bot** \u2192 bot resumes\n\nCongratulations \u2014 you have a production-ready chatbot with human takeover! \ud83c\udf89"
},
"typeVersion": 1
},
{
"id": "04a89a53-f512-411c-b7a3-41e073097a54",
"name": "Sticky Note - Channel Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
2352,
1888
],
"parameters": {
"color": 3,
"width": 400,
"height": 140,
"content": "\ud83d\udca1 **Other channels** are not connected in this template. The placeholder outputs are here so you can quickly add WhatsApp, Messenger, Instagram, or Widget support by connecting the appropriate send nodes."
},
"typeVersion": 1
}
],
"active": true,
"settings": {
"binaryMode": "separate",
"availableInMCP": false,
"executionOrder": "v1"
},
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Check Handler (Post-Bot)",
"type": "main",
"index": 0
}
]
]
},
"Extract Text": {
"main": [
[
{
"node": "Merge Text Input",
"type": "main",
"index": 0
}
]
]
},
"Needs Human?": {
"main": [
[
{
"node": "Escalate to Human",
"type": "main",
"index": 0
}
],
[
{
"node": "Done (No Escalation)",
"type": "main",
"index": 0
}
]
]
},
"Channel Router": {
"main": [
[
{
"node": "Forward to Telegram",
"type": "main",
"index": 0
}
],
[
{
"node": "Other Channels (Placeholder)",
"type": "main",
"index": 0
}
],
[
{
"node": "Other Channels (Placeholder)",
"type": "main",
"index": 0
}
],
[
{
"node": "Other Channels (Placeholder)",
"type": "main",
"index": 0
}
],
[
{
"node": "Other Channels (Placeholder)",
"type": "main",
"index": 0
}
],
[
{
"node": "Other Channels (Placeholder)",
"type": "main",
"index": 0
}
]
]
},
"Send Bot Reply": {
"main": [
[
{
"node": "Record Bot Response",
"type": "main",
"index": 0
}
]
]
},
"Merge Text Input": {
"main": [
[
{
"node": "Record Visitor Message",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Message Type Router",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Conversation Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Download Voice File": {
"main": [
[
{
"node": "Transcribe Voice Message",
"type": "main",
"index": 0
}
]
]
},
"Message Type Router": {
"main": [
[
{
"node": "Extract Text",
"type": "main",
"index": 0
}
],
[
{
"node": "Download Voice File",
"type": "main",
"index": 0
}
],
[
{
"node": "Ignore Unsupported",
"type": "main",
"index": 0
}
]
]
},
"Record Bot Response": {
"main": [
[
{
"node": "Needs Human?",
"type": "main",
"index": 0
}
]
]
},
"Handler Status Router": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Awaiting Message",
"type": "main",
"index": 0
}
],
[
{
"node": "Bot Stays Silent",
"type": "main",
"index": 0
}
]
]
},
"Send Awaiting Message": {
"main": [
[
{
"node": "Record Awaiting Message",
"type": "main",
"index": 0
}
]
]
},
"Record Visitor Message": {
"main": [
[
{
"node": "Check Handler (Pre-Bot)",
"type": "main",
"index": 0
}
]
]
},
"Check Handler (Pre-Bot)": {
"main": [
[
{
"node": "Handler Status Router",
"type": "main",
"index": 0
}
]
]
},
"Handler Status Router 2": {
"main": [
[
{
"node": "Send Bot Reply",
"type": "main",
"index": 0
}
],
[
{
"node": "Suppress Bot Reply",
"type": "main",
"index": 0
}
],
[
{
"node": "Suppress Bot Reply",
"type": "main",
"index": 0
}
]
]
},
"Check Handler (Post-Bot)": {
"main": [
[
{
"node": "Handler Status Router 2",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Transcribe Voice Message": {
"main": [
[
{
"node": "Merge Text Input",
"type": "main",
"index": 1
}
]
]
},
"Trilox Trigger (Agent Reply)": {
"main": [
[
{
"node": "Channel Router",
"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.
openAiApitelegramApitriloxApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
> ⚠️ This template uses the Trilox community node (n8n-nodes-trilox) and requires self-hosted n8n.
Source: https://n8n.io/workflows/13394/ — 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.
BoomerBobBot.TP. Uses agent, telegramTrigger, telegram, memoryBufferWindow. Event-driven trigger; 95 nodes.
Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.
Digital marketers, content creators, social media managers, and businesses who want to use AI marketing automation for YouTube Shorts without spending hours on production. This AI workflow helps anyon
Jarvis is a powerful multi-agent productivity assistant built in n8n. It works directly from Telegram and can understand both text messages and voice notes.
This template is designed for marketers, content creators, and e-commerce brands who want to automate the creation of professional ad videos at scale. It’s ideal for teams looking to generate consiste