This workflow follows the OpenAI → Telegram 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 →
{
"name": "Zenius Telegram Assistant",
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {
"useWebhook": true
}
},
"id": "Telegram Trigger",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1,
"position": [
200,
300
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"functionCode": "// Normalizar entrada de Telegram\nconst upd = items[0].json;\nconst msg = upd.message || {};\nconst chatId = msg.chat?.id;\nconst text = (msg.text || '').trim().slice(0, 2000);\nconst name = msg.from?.first_name || '';\n\n// Comandos b\u00e1sicos\nif (text === '/start') {\n return [{ json: { kind: 'command', reply: `\u00a1Hola ${name}! Soy el asistente de Zenius Automations. Preg\u00fantame sobre automatizaci\u00f3n, agentes de IA o integraci\u00f3n con WhatsApp. Escribe /ayuda para ver opciones.`, chatId } }];\n}\nif (text === '/ayuda') {\n return [{ json: { kind: 'command', reply: 'Comandos:\\n/start \u2013 iniciar\\n/ayuda \u2013 ver ayuda\\n/demo \u2013 solicitar una demo\\n/contacto \u2013 dejar tus datos', chatId } }];\n}\nif (text === '/demo') {\n return [{ json: { kind: 'command', reply: 'Genial. P\u00e1same en un solo mensaje: Nombre, email y empresa. Ejemplo:\\nNombre: Ana P\u00e9rez\\nEmail: ana@empresa.com\\nEmpresa: ACME S.L.', chatId } }];\n}\nif (text === '/contacto') {\n return [{ json: { kind: 'command', reply: 'D\u00e9jame tus datos de contacto en un solo mensaje: Nombre, email y empresa. Te escribimos pronto.', chatId } }];\n}\n\n// Anti-spam sencillo (1 msg/2s por chat)\nconst now = Date.now();\nconst key = `rate_${chatId}`;\nconst last = $flow.get(key) || 0;\nif (now - last < 2000) {\n return [{ json: { kind: 'rate', reply: 'Voy un poco lento, dame un segundo\u2026', chatId } }];\n}\n$flow.set(key, now);\n\nreturn [{ json: { kind: 'chat', chatId, userText: text, name } }];"
},
"name": "Prepare Input",
"type": "n8n-nodes-base.function",
"typeVersion": 2,
"position": [
460,
300
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{$json.kind}}",
"operation": "equals",
"value2": "chat"
}
]
}
},
"name": "If Chat",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
700,
280
]
},
{
"parameters": {
"functionCode": "// Prompt del sistema + usuario\nconst sys = `Eres el asistente de Zenius Automations. Ayudas en espa\u00f1ol de Espa\u00f1a, tono claro y cercano. Si detectas intenci\u00f3n de compra, pide en una sola pregunta: Nombre, email y empresa. Ofrece demo breve si procede.`;\nconst user = $json.userText || '';\nreturn [{ json: { messages: [ {role: 'system', content: sys}, {role: 'user', content: user} ], chatId: $json.chatId } }];"
},
"name": "Build Prompt",
"type": "n8n-nodes-base.function",
"typeVersion": 2,
"position": [
940,
220
]
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-4o-mini",
"messages": "={{$json.messages}}",
"responseFormat": "{\"mode\":\"text\"}"
},
"name": "OpenAI Chat",
"type": "n8n-nodes-base.openAi",
"typeVersion": 4,
"position": [
1180,
220
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"functionCode": "// Extraer texto del LLM\nconst text = $json.choices?.[0]?.message?.content || 'No he podido generar respuesta.';\nreturn [{ json: { reply: text, chatId: $json.chatId } }];"
},
"name": "Format Reply",
"type": "n8n-nodes-base.function",
"typeVersion": 2,
"position": [
1420,
220
]
},
{
"parameters": {
"chatId": "={{$json.chatId}}",
"text": "={{$json.reply}}"
},
"name": "Telegram Reply (LLM)",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [
1660,
220
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{$json.kind}}",
"operation": "notEqual",
"value2": "chat"
}
]
}
},
"name": "If Command/Rate",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
940,
420
]
},
{
"parameters": {
"chatId": "={{$json.chatId}}",
"text": "={{$json.reply}}"
},
"name": "Telegram Reply (Cmd)",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [
1180,
520
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
}
],
"connections": {
"Prepare Input": {
"main": [
[
{
"node": "If Chat",
"type": "main",
"index": 0
},
{
"node": "If Command/Rate",
"type": "main",
"index": 0
}
]
]
},
"If Chat": {
"main": [
[
{
"node": "Build Prompt",
"type": "main",
"index": 0
}
]
]
},
"Build Prompt": {
"main": [
[
{
"node": "OpenAI Chat",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat": {
"main": [
[
{
"node": "Format Reply",
"type": "main",
"index": 0
}
]
]
},
"Format Reply": {
"main": [
[
{
"node": "Telegram Reply (LLM)",
"type": "main",
"index": 0
}
]
]
},
"If Command/Rate": {
"main": [
[
{
"node": "Telegram Reply (Cmd)",
"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.
openAiApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Zenius Telegram Assistant. Uses telegramTrigger, openAi, telegram. Event-driven trigger; 9 nodes.
Source: https://gist.github.com/andreswraage-coder/2be4b263fe73424af326222db985fe50 — 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.
Personal Assistant with Long-Term Memory (StudioMeyer). Uses stickyNote, telegramTrigger, n8n-nodes-studiomeyer-memory, telegram. Event-driven trigger; 26 nodes.
The workflow starts by listening for messages from Telegram users. The message is then processed, and based on its content, different actions are taken. If it's a regular chat message, the workflow ge
24-simple-telegram-ai-chatbot. Uses telegramTrigger, openAi, telegram. Event-driven trigger; 16 nodes.
This workflow connects a Telegram bot to OpenAi/Google Gemini (PaLM API) so the bot can reply to users with AI-generated answers. Useful for FAQs, assistants, classroom helpers, or bots that fetch doc
This workflow acts as your personal inbox assistant. It automatically filters, classifies, and responds to incoming emails using AI, saving you from manually sorting through leads or inquiries 24/7.