创建具有多级导航的动态Telegram机器人菜单系统
高级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 28 个节点。主要使用 If, Set, Merge, Switch, Function 等节点。 创建具有多级导航的动态Telegram机器人菜单系统
前置要求
- •可能需要目标 API 的认证凭证
- •Telegram Bot Token
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "82ee17baaf8f0713e544083c37cbe259962ad0fcd85204d3262a7dfafc166630"
},
"nodes": [
{
"id": "34f248f6-ef2c-4aee-a328-03b92aa39ff1",
"name": "📚 真实示例",
"type": "n8n-nodes-base.stickyNote",
"position": [
5536,
752
],
"parameters": {
"color": 5,
"width": 660,
"height": 1796,
"content": "# 📚 可复制的真实示例"
},
"typeVersion": 1
},
{
"id": "90319918-ce1a-4e45-9be5-d33552518205",
"name": "Telegram 触发器4",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
4816,
448
],
"webhookId": "telegram-webhook",
"parameters": {
"updates": [
"message",
"callback_query"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "Z8AAUw0IVPUMfdnC",
"name": "Telegram - LifeAiToolsBot"
}
},
"typeVersion": 1
},
{
"id": "0b08989c-6516-4df1-8566-640dc5ed8f92",
"name": "加载菜单配置2",
"type": "n8n-nodes-base.function",
"position": [
5104,
352
],
"parameters": {
"functionCode": "// ========================================\n// 📋 MENU CONFIGURATION - PURE NAVIGATION\n// ========================================\n// This is the ONLY place where menus are defined\n// Structure: Simple navigation tree with no business logic\n// \n// HOW TO ADD A NEW MENU:\n// 1. Add menu key to MENU_CONFIG object\n// 2. Define 'text' - what user sees (supports HTML)\n// 3. Define 'keyboard' - array of button rows\n// 4. Each button needs 'text' (label) and 'callback_data' (routing key)\n// 5. Use callback_data for navigation or action routing\n// ========================================\n\nconst data = items[0].json;\n\nconsole.log('📋 Loading menu structure...');\n\n// ========================================\n// MENU_CONFIG: Central menu definition\n// - Key = routing identifier (used in callback_data)\n// - Value = menu object with text and keyboard\n// ========================================\nconst MENU_CONFIG = {\n \n // ==================\n // MAIN MENU - Entry point (Level 0)\n // ==================\n // This is where users land on /start\n main: {\n text: '🏠 <b>MAIN MENU</b>\\n\\nSelect an option:',\n keyboard: [\n // Row 1: Feature menus\n [\n { text: '📁 Menu 1', callback_data: 'menu1' }, // Navigate to menu1\n { text: '📁 Menu 2', callback_data: 'menu2' } // Navigate to menu2\n ],\n // Row 2: More features\n [\n { text: '📁 Menu 3', callback_data: 'menu3' }, // Navigate to menu3\n { text: '📁 Menu 4', callback_data: 'menu4' } // Navigate to menu4\n ],\n // Row 3: System menus\n [\n { text: '⚙️ Settings', callback_data: 'settings' }, // Settings menu\n { text: '❓ Help', callback_data: 'help' } // Help menu\n ]\n ]\n },\n \n // ==================\n // MENU 1 - Submenu example (Level 1)\n // ==================\n // Shows how to create actions and nested submenus\n menu1: {\n text: '📁 <b>MENU 1</b>\\n\\nChoose action:',\n keyboard: [\n // Individual action buttons\n [{ text: '🔸 Action 1.1', callback_data: 'action_1_1' }], // Triggers action\n [{ text: '🔸 Action 1.2', callback_data: 'action_1_2' }], // Triggers action\n // Navigate to deeper submenu\n [{ text: '📂 Submenu 1.3', callback_data: 'submenu_1_3' }], // Goes deeper\n // IMPORTANT: Always include navigation back\n [{ text: '🔙 Back', callback_data: 'main' }] // Returns to main menu\n ]\n },\n \n // Action endpoints - These trigger business logic in handlers\n // callback_data will be routed to appropriate handler\n action_1_1: {\n text: '✅ Action 1.1 Selected',\n keyboard: [[{ text: '🔙 Back to Menu 1', callback_data: 'menu1' }]]\n },\n \n action_1_2: {\n text: '✅ Action 1.2 Selected',\n keyboard: [[{ text: '🔙 Back to Menu 1', callback_data: 'menu1' }]]\n },\n \n // Submenu example (Level 2) - Can go infinitely deep\n submenu_1_3: {\n text: '📂 <b>SUBMENU 1.3</b>\\n\\nDeeper level:',\n keyboard: [\n [{ text: '▫️ Option A', callback_data: 'option_a' }], // Action\n [{ text: '▫️ Option B', callback_data: 'option_b' }], // Action\n [{ text: '🔙 Back to Menu 1', callback_data: 'menu1' }] // Navigate up\n ]\n },\n \n option_a: {\n text: '✅ Option A Selected',\n keyboard: [[{ text: '🔙 Back', callback_data: 'submenu_1_3' }]]\n },\n \n option_b: {\n text: '✅ Option B Selected',\n keyboard: [[{ text: '🔙 Back', callback_data: 'submenu_1_3' }]]\n },\n \n // ==================\n // MENU 2 - Level 1\n // ==================\n menu2: {\n text: '📁 <b>MENU 2</b>\\n\\nSelect option:',\n keyboard: [\n [{ text: '🔹 Action 2.1', callback_data: 'action_2_1' }],\n [{ text: '🔹 Action 2.2', callback_data: 'action_2_2' }],\n [{ text: '🔹 Action 2.3', callback_data: 'action_2_3' }],\n [{ text: '🔙 Main Menu', callback_data: 'main' }]\n ]\n },\n \n action_2_1: {\n text: '✅ Action 2.1 Triggered',\n keyboard: [[{ text: '🔙 Back', callback_data: 'menu2' }]]\n },\n \n action_2_2: {\n text: '✅ Action 2.2 Triggered',\n keyboard: [[{ text: '🔙 Back', callback_data: 'menu2' }]]\n },\n \n action_2_3: {\n text: '✅ Action 2.3 Triggered',\n keyboard: [[{ text: '🔙 Back', callback_data: 'menu2' }]]\n },\n \n // ==================\n // MENU 3 - Level 1\n // ==================\n menu3: {\n text: '📁 <b>MENU 3</b>\\n\\nPick one:',\n keyboard: [\n [\n { text: '1️⃣', callback_data: 'opt_1' },\n { text: '2️⃣', callback_data: 'opt_2' },\n { text: '3️⃣', callback_data: 'opt_3' },\n { text: '4️⃣', callback_data: 'opt_4' },\n { text: '5️⃣', callback_data: 'opt_5' }\n ],\n [{ text: '🔙 Main', callback_data: 'main' }]\n ]\n },\n \n opt_1: { text: '✅ Option 1 Selected', keyboard: [[{ text: '🔙', callback_data: 'menu3' }]] },\n opt_2: { text: '✅ Option 2 Selected', keyboard: [[{ text: '🔙', callback_data: 'menu3' }]] },\n opt_3: { text: '✅ Option 3 Selected', keyboard: [[{ text: '🔙', callback_data: 'menu3' }]] },\n opt_4: { text: '✅ Option 4 Selected', keyboard: [[{ text: '🔙', callback_data: 'menu3' }]] },\n opt_5: { text: '✅ Option 5 Selected', keyboard: [[{ text: '🔙', callback_data: 'menu3' }]] },\n \n // ==================\n // MENU 4 - Level 1\n // ==================\n menu4: {\n text: '📁 <b>MENU 4</b>',\n keyboard: [\n [{ text: '📋 List Items', callback_data: 'list' }],\n [{ text: '➕ Add Item', callback_data: 'add' }],\n [{ text: '✏️ Edit Item', callback_data: 'edit' }],\n [{ text: '🗑 Delete Item', callback_data: 'delete' }],\n [{ text: '🔙 Main', callback_data: 'main' }]\n ]\n },\n \n list: { text: '📋 Listing items...', keyboard: [[{ text: '🔙', callback_data: 'menu4' }]] },\n add: { text: '➕ Adding item...', keyboard: [[{ text: '🔙', callback_data: 'menu4' }]] },\n edit: { text: '✏️ Editing item...', keyboard: [[{ text: '🔙', callback_data: 'menu4' }]] },\n delete: { text: '🗑 Deleting item...', keyboard: [[{ text: '🔙', callback_data: 'menu4' }]] },\n \n // ==================\n // SETTINGS - Level 1\n // ==================\n settings: {\n text: '⚙️ <b>SETTINGS</b>',\n keyboard: [\n [{ text: '🔔 Notifications', callback_data: 'notif' }],\n [{ text: '🌍 Language', callback_data: 'lang' }],\n [{ text: '👤 Profile', callback_data: 'profile' }],\n [{ text: '🔐 Privacy', callback_data: 'privacy' }],\n [{ text: '🔙 Main', callback_data: 'main' }]\n ]\n },\n \n notif: {\n text: '🔔 Notification Settings',\n keyboard: [\n [{ text: 'Enable All', callback_data: 'notif_on' }],\n [{ text: 'Disable All', callback_data: 'notif_off' }],\n [{ text: '🔙 Settings', callback_data: 'settings' }]\n ]\n },\n \n notif_on: { text: '✅ Notifications Enabled', keyboard: [[{ text: '🔙', callback_data: 'notif' }]] },\n notif_off: { text: '❌ Notifications Disabled', keyboard: [[{ text: '🔙', callback_data: 'notif' }]] },\n \n lang: {\n text: '🌍 Select Language',\n keyboard: [\n [{ text: '🇬🇧 English', callback_data: 'lang_en' }],\n [{ text: '🇪🇸 Español', callback_data: 'lang_es' }],\n [{ text: '🇫🇷 Français', callback_data: 'lang_fr' }],\n [{ text: '🔙 Settings', callback_data: 'settings' }]\n ]\n },\n \n lang_en: { text: '✅ English Selected', keyboard: [[{ text: '🔙', callback_data: 'lang' }]] },\n lang_es: { text: '✅ Español Seleccionado', keyboard: [[{ text: '🔙', callback_data: 'lang' }]] },\n lang_fr: { text: '✅ Français Sélectionné', keyboard: [[{ text: '🔙', callback_data: 'lang' }]] },\n \n profile: { text: '👤 Profile Settings', keyboard: [[{ text: '🔙', callback_data: 'settings' }]] },\n privacy: { text: '🔐 Privacy Settings', keyboard: [[{ text: '🔙', callback_data: 'settings' }]] },\n \n // ==================\n // HELP - Level 1\n // ==================\n help: {\n text: '❓ <b>HELP</b>',\n keyboard: [\n [{ text: '📖 Guide', callback_data: 'guide' }],\n [{ text: '❓ FAQ', callback_data: 'faq' }],\n [{ text: '📞 Contact', callback_data: 'contact' }],\n [{ text: '🔙 Main', callback_data: 'main' }]\n ]\n },\n \n guide: { text: '📖 User Guide', keyboard: [[{ text: '🔙', callback_data: 'help' }]] },\n faq: { text: '❓ FAQ', keyboard: [[{ text: '🔙', callback_data: 'help' }]] },\n contact: { text: '📞 Contact Support', keyboard: [[{ text: '🔙', callback_data: 'help' }]] },\n \n // ==================\n // DEFAULT FALLBACK - IMPORTANT!\n // ==================\n // This menu is shown when callback_data doesn't match any menu key\n default: {\n text: '❓ Unknown selection',\n keyboard: [[{ text: '🏠 Main Menu', callback_data: 'main' }]]\n }\n};\n\n// ========================================\n// MENU STRUCTURE RULES:\n// 1. Each menu MUST have 'text' and 'keyboard'\n// 2. Text supports HTML: <b>bold</b>, <i>italic</i>, <code>code</code>\n// 3. Use \\n for line breaks in text\n// 4. Keyboard is array of arrays (rows of buttons)\n// 5. Each button MUST have 'text' (display) and 'callback_data' (routing)\n// 6. callback_data should match a menu key or be handled by router\n// 7. Always provide navigation back to parent menu\n// ========================================\n\nconsole.log(`✅ Menu structure loaded: ${Object.keys(MENU_CONFIG).length} menus`);\n\n// Pass menu config with original data\nreturn [{\n json: {\n ...data,\n menuConfig: MENU_CONFIG\n }\n}];"
},
"typeVersion": 1
},
{
"id": "bf40de58-d392-4d6c-9401-1e96a0a13780",
"name": "提取命令4",
"type": "n8n-nodes-base.function",
"position": [
5104,
560
],
"parameters": {
"functionCode": "// Extract command and user data\n\nconst data = items[0].json;\nlet command = '';\nlet userName = '';\nlet userId = '';\nlet chatId = '';\nlet messageId = '';\nlet isCallback = false;\n\n// Extract data\nif (data.message) {\n const message = data.message;\n chatId = message.chat.id;\n userId = message.from.id;\n userName = message.from.first_name || 'User';\n \n const text = (message.text || '').toLowerCase();\n if (text.startsWith('/start')) command = 'main';\n else if (text.includes('help')) command = 'help';\n else if (text.includes('settings')) command = 'settings';\n else if (text.includes('stats')) command = 'stats';\n else if (text.includes('feedback')) command = 'feedback';\n else command = 'main';\n \n} else if (data.callback_query) {\n const callback = data.callback_query;\n chatId = callback.message.chat.id;\n messageId = callback.message.message_id;\n userId = callback.from.id;\n userName = callback.from.first_name || 'User';\n isCallback = true;\n command = callback.data;\n}\n\nconsole.log(`Command: '${command}', User: ${userName}`);\n\nreturn [{\n json: {\n ...data,\n command: command,\n userName: userName,\n userId: userId,\n chatId: chatId,\n messageId: messageId,\n isCallback: isCallback,\n callbackQueryId: data.callback_query ? data.callback_query.id : null\n }\n}];"
},
"typeVersion": 1
},
{
"id": "0f33970c-1585-4655-8344-67a38eb1d942",
"name": "合并配置与命令2",
"type": "n8n-nodes-base.merge",
"position": [
5344,
448
],
"parameters": {
"mode": "combine",
"options": {},
"combinationMode": "mergeByPosition"
},
"typeVersion": 2.1
},
{
"id": "e01e3ca1-f83a-4233-9d25-721d584e8e6c",
"name": "处理命令2",
"type": "n8n-nodes-base.function",
"position": [
5552,
448
],
"parameters": {
"functionCode": "// Process command and check if action needed\n\nconst input = items[0].json;\n\n// Get menu\nlet menu = input.menuConfig[input.command] || input.menuConfig.default;\n\n// Commands that need actions\nconst actionCommands = [\n 'rate_1', 'rate_2', 'rate_3', 'rate_4', 'rate_5',\n 'lang_en', 'lang_es',\n 'analytics', 'report',\n 'stats', 'achievements',\n 'bug_report', 'feature_request',\n 'notif', 'profile'\n];\n\nconst requiresAction = actionCommands.includes(input.command);\n\nconsole.log(`Processing: ${input.command}, Action needed: ${requiresAction}`);\n\nreturn [{\n json: {\n ...input,\n menu: menu,\n requiresAction: requiresAction\n }\n}];"
},
"typeVersion": 1
},
{
"id": "e1434658-5196-46e8-a026-b7781593207b",
"name": "需要操作?2",
"type": "n8n-nodes-base.if",
"position": [
5744,
448
],
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.requiresAction }}",
"value2": true
}
]
}
},
"typeVersion": 1
},
{
"id": "04d837da-226a-47b2-b91b-e68dae10cb26",
"name": "操作路由器2",
"type": "n8n-nodes-base.switch",
"position": [
5952,
352
],
"parameters": {
"mode": "expression",
"output": "={{ $json.command.startsWith('rate_') ? 0 : $json.command.startsWith('lang_') ? 1 : $json.command === 'analytics' || $json.command === 'report' ? 2 : $json.command === 'stats' || $json.command === 'achievements' ? 3 : $json.command === 'bug_report' || $json.command === 'feature_request' ? 4 : $json.command === 'notif' || $json.command === 'profile' ? 5 : 6 }}",
"numberOutputs": 7
},
"typeVersion": 3.2
},
{
"id": "edb6a6d4-6e8f-4136-81ff-ccfc34fc041d",
"name": "评分处理器2",
"type": "n8n-nodes-base.function",
"position": [
6304,
112
],
"parameters": {
"functionCode": "// Rating Handler - Process ratings\n\nconst input = items[0].json;\nconst rating = parseInt(input.command.split('_')[1]);\n\nconst messages = {\n 1: 'We\\'re sorry to hear that. We\\'ll improve!',\n 2: 'Thank you for the feedback. We\\'ll do better!',\n 3: 'Good to know! We\\'re always improving.',\n 4: 'Great! We\\'re glad you liked it!',\n 5: 'Awesome! Thank you so much!'\n};\n\nconsole.log(`⭐ Rating saved: ${rating}`);\n\nreturn [{\n json: {\n ...input,\n customData: {\n ratingMessage: messages[rating]\n },\n actionExecuted: 'rating_saved'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "99d8f666-efc1-499b-b397-52646ee38874",
"name": "语言处理器2",
"type": "n8n-nodes-base.function",
"position": [
6304,
240
],
"parameters": {
"functionCode": "// Language Handler - Change language\n\nconst input = items[0].json;\nconst lang = input.command.split('_')[1];\n\nconsole.log(`🌍 Language changed to: ${lang}`);\n\nreturn [{\n json: {\n ...input,\n customData: {},\n actionExecuted: 'language_changed'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "cb801cf0-aa7e-43cf-9d1c-eb7eb42f97bc",
"name": "分析处理器2",
"type": "n8n-nodes-base.function",
"position": [
6304,
368
],
"parameters": {
"functionCode": "// Analytics Handler - Generate analytics/reports\n\nconst input = items[0].json;\nlet customData = {};\n\nif (input.command === 'analytics') {\n const views = Math.floor(Math.random() * 1000) + 100;\n const clicks = Math.floor(Math.random() * 500) + 50;\n customData.analyticsData = `Views: ${views}\\nClicks: ${clicks}\\nCTR: ${(clicks/views*100).toFixed(2)}%`;\n console.log('📈 Analytics generated');\n} else if (input.command === 'report') {\n customData.reportData = `Report ID: RPT-${Date.now()}\\nPeriod: Last 30 days\\nStatus: Ready`;\n console.log('📄 Report generated');\n}\n\nreturn [{\n json: {\n ...input,\n customData: customData,\n actionExecuted: 'analytics_generated'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "67c86bcd-bf2c-466a-b1f5-a2459561808e",
"name": "统计处理器3",
"type": "n8n-nodes-base.function",
"position": [
6304,
496
],
"parameters": {
"functionCode": "// Statistics Handler - Load stats/achievements\n\nconst input = items[0].json;\nlet customData = {};\n\nif (input.command === 'stats') {\n customData.statsData = `Total actions: ${Math.floor(Math.random() * 100)}\\nActive days: ${Math.floor(Math.random() * 30)}\\nRatings given: ${Math.floor(Math.random() * 10)}`;\n console.log('📊 Stats loaded');\n} else if (input.command === 'achievements') {\n customData.achievementData = '🥇 Early Adopter\\n🥈 Active User\\n🥉 Feedback Champion';\n console.log('🏆 Achievements loaded');\n}\n\nreturn [{\n json: {\n ...input,\n customData: customData,\n actionExecuted: 'stats_loaded'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "957c06c4-221e-4ecd-83af-ff84c44c6b00",
"name": "反馈处理器3",
"type": "n8n-nodes-base.function",
"position": [
6304,
624
],
"parameters": {
"functionCode": "// Feedback Handler - Create tickets\n\nconst input = items[0].json;\nconst ticketType = input.command === 'bug_report' ? 'BUG' : 'REQ';\nconst ticketId = `${ticketType}-${Date.now()}`;\n\nconst customData = {\n ticketInfo: `Ticket created: ${ticketId}\\nStatus: Open\\nPriority: Medium`\n};\n\nconsole.log(`🎫 Ticket created: ${ticketId}`);\n\nreturn [{\n json: {\n ...input,\n customData: customData,\n actionExecuted: 'ticket_created'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "c54a9d75-aec8-4ed5-b970-7d2482678125",
"name": "设置处理器3",
"type": "n8n-nodes-base.function",
"position": [
6304,
752
],
"parameters": {
"functionCode": "// Settings Handler - Load settings data\n\nconst input = items[0].json;\nlet customData = {};\n\nif (input.command === 'notif') {\n customData.notificationStatus = '✅ Push: ON\\n✅ Email: ON\\n❌ SMS: OFF';\n console.log('🔔 Notifications loaded');\n} else if (input.command === 'profile') {\n customData.userStatus = 'Active';\n console.log('👤 Profile loaded');\n}\n\nreturn [{\n json: {\n ...input,\n customData: customData,\n actionExecuted: 'settings_loaded'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "801f73ff-be99-40da-bd01-93e8b29579c7",
"name": "默认处理器2",
"type": "n8n-nodes-base.function",
"position": [
6304,
880
],
"parameters": {
"functionCode": "// Default Handler - No specific action\n\nconst input = items[0].json;\n\nconsole.log(`ℹ️ No action for: ${input.command}`);\n\nreturn [{\n json: {\n ...input,\n customData: {},\n actionExecuted: 'none'\n }\n}];"
},
"typeVersion": 1
},
{
"id": "0286be0c-4f86-410c-9544-acd50ebfe998",
"name": "构建响应2",
"type": "n8n-nodes-base.function",
"position": [
6624,
1232
],
"parameters": {
"functionCode": "// Build final response with data\n\nconst input = items[0].json;\nconst menu = input.menu;\n\n// Replace placeholders\nlet responseText = menu.text\n .replace(/{userName}/g, input.userName)\n .replace(/{userId}/g, input.userId);\n\n// Replace custom data\nif (input.customData) {\n for (const [key, value] of Object.entries(input.customData)) {\n responseText = responseText.replace(new RegExp(`{${key}}`, 'g'), value);\n }\n}\n\n// Clean remaining placeholders\nresponseText = responseText.replace(/{\\w+}/g, '');\n\nconsole.log(`📤 Sending: ${input.command}`);\nif (input.actionExecuted) {\n console.log(`Action: ${input.actionExecuted}`);\n}\n\nreturn [{\n json: {\n ...input,\n responseText: responseText,\n keyboard: menu.keyboard\n }\n}];"
},
"typeVersion": 1
},
{
"id": "0bd5c651-f87a-4f11-aa6a-8767db73b75c",
"name": "准备 Telegram2",
"type": "n8n-nodes-base.function",
"position": [
6816,
1232
],
"parameters": {
"functionCode": "// Prepare Telegram request\n\nconst input = items[0].json;\n\nconst apiMethod = input.isCallback ? 'editMessageText' : 'sendMessage';\n\nlet requestBody = {\n chat_id: input.chatId,\n text: input.responseText,\n parse_mode: 'HTML',\n reply_markup: {\n inline_keyboard: input.keyboard\n }\n};\n\nif (input.isCallback && input.messageId) {\n requestBody.message_id = input.messageId;\n}\n\nreturn [{\n json: {\n apiMethod: apiMethod,\n requestBody: requestBody,\n isCallback: input.isCallback,\n callbackQueryId: input.callbackQueryId\n }\n}];"
},
"typeVersion": 1
},
{
"id": "3a6785fa-53b8-495a-991c-d05fc05c6ed5",
"name": "设置机器人令牌4",
"type": "n8n-nodes-base.set",
"position": [
7024,
1232
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "bot-token",
"name": "botToken",
"type": "string",
"value": "[!!! PALCE YOUR BOT TOKEN HERE !!!] "
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "838dd900-a6b3-4a81-96cb-b222b0b787de",
"name": "是回调吗?4",
"type": "n8n-nodes-base.if",
"position": [
7216,
1232
],
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.isCallback }}",
"value2": true
}
]
}
},
"typeVersion": 1
},
{
"id": "885941fd-fcb2-4c99-883b-95b942d5ec53",
"name": "发送到 Telegram4",
"type": "n8n-nodes-base.httpRequest",
"position": [
7424,
1152
],
"parameters": {
"url": "={{ 'https://api.telegram.org/bot' + $json.botToken + '/' + $json.apiMethod }}",
"method": "POST",
"options": {},
"jsonBody": "={{ $json.requestBody }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "d8d18120-1c1d-44db-8d18-6429c0f651aa",
"name": "回答回调4",
"type": "n8n-nodes-base.httpRequest",
"position": [
7424,
1312
],
"parameters": {
"url": "={{ 'https://api.telegram.org/bot' + $('Set Bot Token4').item.json.botToken + '/answerCallbackQuery' }}",
"method": "POST",
"options": {},
"jsonBody": "={{ { \"callback_query_id\": $('Prepare Telegram2').item.json.callbackQueryId, \"text\": \"✅\" } }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "e9445b8e-cc2c-479b-be11-e90988424122",
"name": "🔀 路由器逻辑2",
"type": "n8n-nodes-base.stickyNote",
"position": [
6240,
-336
],
"parameters": {
"color": 4,
"width": 298,
"height": 424,
"content": "## 🔀 路由器输出"
},
"typeVersion": 1
},
{
"id": "36fd73cd-6e54-4815-89c3-fc720e641de5",
"name": "🚀 快速入门指南1",
"type": "n8n-nodes-base.stickyNote",
"position": [
4096,
592
],
"parameters": {
"width": 592,
"height": 664,
"content": "# 🚀 快速入门指南"
},
"typeVersion": 1
},
{
"id": "5949ce06-9acc-427d-ae01-a7cd9a08df0f",
"name": "📚 工作流架构1",
"type": "n8n-nodes-base.stickyNote",
"position": [
4096,
-336
],
"parameters": {
"color": 5,
"width": 592,
"height": 904,
"content": "# 📚 工作流架构"
},
"typeVersion": 1
},
{
"id": "94d1d1ff-ca68-40fb-94d1-f254385631df",
"name": "💡 添加处理器1",
"type": "n8n-nodes-base.stickyNote",
"position": [
6592,
-336
],
"parameters": {
"color": 3,
"width": 464,
"height": 1468,
"content": "# 🔧 高级:创建自定义处理器"
},
"typeVersion": 1
},
{
"id": "31fd910a-aed4-4f1b-8f23-da619a868704",
"name": "📋 菜单代码1",
"type": "n8n-nodes-base.stickyNote",
"position": [
4864,
-336
],
"parameters": {
"color": 6,
"width": 636,
"height": 618,
"content": "# 📋 查看代码注释!"
},
"typeVersion": 1
},
{
"id": "6513c9ec-a1aa-4fd2-92ec-5b77e5cb19a1",
"name": "⚙️ 菜单设置指南1",
"type": "n8n-nodes-base.stickyNote",
"position": [
4848,
752
],
"parameters": {
"color": 6,
"width": 660,
"height": 2560,
"content": "# 📖 完整指南:添加菜单和操作"
},
"typeVersion": 1
},
{
"id": "4e45ea08-9db3-4f5b-a694-5b22bbf3e65f",
"name": "🐛 故障排除与提示1",
"type": "n8n-nodes-base.stickyNote",
"position": [
7104,
-336
],
"parameters": {
"width": 568,
"height": 856,
"content": "# 🐛 故障排除与提示"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Is Callback?4": {
"main": [
[
{
"node": "Send to Telegram4",
"type": "main",
"index": 0
},
{
"node": "Answer Callback4",
"type": "main",
"index": 0
}
],
[
{
"node": "Send to Telegram4",
"type": "main",
"index": 0
}
]
]
},
"Action Router2": {
"main": [
[
{
"node": "Rating Handler2",
"type": "main",
"index": 0
}
],
[
{
"node": "Language Handler2",
"type": "main",
"index": 0
}
],
[
{
"node": "Analytics Handler2",
"type": "main",
"index": 0
}
],
[
{
"node": "Statistics Handler3",
"type": "main",
"index": 0
}
],
[
{
"node": "Feedback Handler3",
"type": "main",
"index": 0
}
],
[
{
"node": "Settings Handler3",
"type": "main",
"index": 0
}
],
[
{
"node": "Default Handler2",
"type": "main",
"index": 0
}
]
]
},
"Needs Action?2": {
"main": [
[
{
"node": "Action Router2",
"type": "main",
"index": 0
}
],
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Set Bot Token4": {
"main": [
[
{
"node": "Is Callback?4",
"type": "main",
"index": 0
}
]
]
},
"Build Response2": {
"main": [
[
{
"node": "Prepare Telegram2",
"type": "main",
"index": 0
}
]
]
},
"Rating Handler2": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Default Handler2": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Extract Command4": {
"main": [
[
{
"node": "Merge Config & Command2",
"type": "main",
"index": 1
}
]
]
},
"Process Command2": {
"main": [
[
{
"node": "Needs Action?2",
"type": "main",
"index": 0
}
]
]
},
"Feedback Handler3": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Language Handler2": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Load Menu Config2": {
"main": [
[
{
"node": "Merge Config & Command2",
"type": "main",
"index": 0
}
]
]
},
"Prepare Telegram2": {
"main": [
[
{
"node": "Set Bot Token4",
"type": "main",
"index": 0
}
]
]
},
"Settings Handler3": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger4": {
"main": [
[
{
"node": "Load Menu Config2",
"type": "main",
"index": 0
},
{
"node": "Extract Command4",
"type": "main",
"index": 0
}
]
]
},
"Analytics Handler2": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Statistics Handler3": {
"main": [
[
{
"node": "Build Response2",
"type": "main",
"index": 0
}
]
]
},
"Merge Config & Command2": {
"main": [
[
{
"node": "Process Command2",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于URL使用AI、Telegram和多平台发布自动生成社交媒体帖子
基于URL使用AI、Telegram和多平台发布自动生成社交媒体帖子
If
Set
Code
+11
42 节点Karol
内容创作
Telegram 机器人内联键盘与动态菜单及评分系统
Telegram 机器人内联键盘:动态菜单与评分系统
If
Set
Function
+3
12 节点Ruslan Elishev
客服机器人
家居装饰AI(Google Nano Banana)- Santhej Kallada
基于Google Gemini的AI图像生成与编辑及Telegram机器人
If
Set
Code
+9
28 节点Santhej Kallada
内容创作
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
基于动态系统提示和GPT-4o的AI驱动多平台社交媒体内容工厂
If
Set
Code
+20
100 节点Amit Mehta
内容创作
从趋势电子表格生成SEO内容到存储(SharePoint/Drive/Dropbox)
使用GPT-4o、FAL AI和多存储支持从趋势自动生成SEO内容
If
Set
Code
+13
47 节点plemeo
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
工作流信息
难度等级
高级
节点数量28
分类2
节点类型8
作者
Ruslan Elishev
@relishevProfessional Product Director that cought vibe of Automaion and Solo Programming and Context Aware AI Vibe coding.
外部链接
在 n8n.io 查看 →
分享此工作流