{ "name": "每週業績摘要", "nodes": [ { "parameters": { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 9 * * 1" }] } }, "id": "schedule", "name": "每週一 9:00", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1, "position": [0, 0] }, { "parameters": { "url": "http://192.168.0.110:5001/api/weekly_summary", "options": { "timeout": 30000 } }, "id": "http-sales", "name": "取得週業績", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [220, 0] }, { "parameters": { "jsCode": "const data = $input.first().json;\nconst summary = data.summary || data;\n\nconst weekStart = summary.week_start || 'N/A';\nconst weekEnd = summary.week_end || 'N/A';\nconst totalSales = summary.total_sales || 0;\nconst orderCount = summary.order_count || 0;\nconst growthRate = summary.growth_rate || 0;\n\n// 格式化金額\nconst formattedSales = totalSales.toLocaleString('zh-TW');\n\nconst text = '📊 *每週業績摘要*\\n\\n' +\n '📅 週期: ' + weekStart + ' ~ ' + weekEnd + '\\n' +\n '💰 總業績: $' + formattedSales + '\\n' +\n '📦 訂單數: ' + orderCount + '\\n' +\n '📈 成長率: ' + growthRate + '%\\n\\n' +\n '詳細報表請登入系統查看';\n\nreturn [{ json: { telegramBody: { chat_id: '5619078117', text: text, parse_mode: 'Markdown' } } }];" }, "id": "code", "name": "整理資料", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [440, 0] }, { "parameters": { "method": "POST", "url": "https://api.telegram.org/bot/sendMessage", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify($json.telegramBody) }}" }, "id": "telegram", "name": "發送摘要", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [660, 0] } ], "connections": { "每週一 9:00": { "main": [[{ "node": "取得週業績", "type": "main", "index": 0 }]] }, "取得週業績": { "main": [[{ "node": "整理資料", "type": "main", "index": 0 }]] }, "整理資料": { "main": [[{ "node": "發送摘要", "type": "main", "index": 0 }]] } }, "settings": { "executionOrder": "v1" } }