{ "name": "🎯 ULTIMATE Telegram CMS", "nodes": [ { "parameters": { "updates": ["message"], "additionalFields": {} }, "type": "n8n-nodes-base.telegramTrigger", "typeVersion": 1.2, "position": [0, 0], "id": "telegram-trigger", "name": "Telegram Trigger" }, { "parameters": { "jsCode": "const text = $input.first().json.message?.text ?? '';\nconst chatId = $input.first().json.message?.chat?.id;\nlet match;\n\n// /start - Dashboard\nif (text === '/start') {\n return [{ json: { action: 'start', chatId } }];\n}\n\n// /list projects|books\nmatch = text.match(/^\\/list\\s+(projects|books)/);\nif (match) {\n return [{ json: { action: 'list', type: match[1], chatId } }];\n}\n\n// /search \nmatch = text.match(/^\\/search\\s+(.+)/);\nif (match) {\n return [{ json: { action: 'search', query: match[1], chatId } }];\n}\n\n// /stats\nif (text === '/stats') {\n return [{ json: { action: 'stats', chatId } }];\n}\n\n// /preview \nmatch = text.match(/^\\/preview\\s+(\\d+)/);\nif (match) {\n return [{ json: { action: 'preview', id: match[1], chatId } }];\n}\n\n// /publish or /publishproject or /publishbook\nmatch = text.match(/^\\/publish(?:project|book)?(\\d+)/);\nif (match) {\n return [{ json: { action: 'publish', id: match[1], chatId } }];\n}\n\n// /delete or /deleteproject or /deletebook\nmatch = text.match(/^\\/delete(?:project|book)?(\\d+)/);\nif (match) {\n return [{ json: { action: 'delete', id: match[1], chatId } }];\n}\n\n// /deletereview\nmatch = text.match(/^\\/deletereview(\\d+)/);\nif (match) {\n return [{ json: { action: 'delete_review', id: match[1], chatId } }];\n}\n\n// .review \nif (text.startsWith('.review') || text.startsWith('/review')) {\n const rest = text.replace(/^[\\.\/]review/, '').trim();\n match = rest.match(/^([0-9]+)\\s+([0-9]+)\\s+(.+)/);\n if (match) {\n return [{ json: { action: 'create_review', hardcoverId: match[1], rating: parseInt(match[2]), answers: match[3], chatId } }];\n }\n}\n\n// Unknown\nreturn [{ json: { action: 'unknown', chatId, text } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [220, 0], "id": "parse-command", "name": "Parse Command" }, { "parameters": { "rules": { "values": [ { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "start", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "start" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "list", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "list" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "search", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "search" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "stats", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "stats" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "preview", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "preview" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "publish", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "publish" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "delete", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "delete" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "delete_review", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "delete_review" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "create_review", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "create_review" }, { "conditions": { "conditions": [ { "leftValue": "={{ $json.action }}", "rightValue": "unknown", "operator": { "type": "string", "operation": "equals" } } ] }, "renameOutput": true, "outputKey": "unknown" } ] } }, "type": "n8n-nodes-base.switch", "typeVersion": 3.2, "position": [440, 0], "id": "switch-action", "name": "Switch Action" } ], "connections": { "Telegram Trigger": { "main": [[{ "node": "Parse Command", "type": "main", "index": 0 }]] }, "Parse Command": { "main": [[{ "node": "Switch Action", "type": "main", "index": 0 }]] } }, "active": true, "settings": { "executionOrder": "v1" } }