8
n8n 中文网amn8n.com

OctoPrint 管理器

高级

这是一个Engineering, AI, IT Ops领域的自动化工作流,包含 16 个节点。主要使用 Discord, HttpRequest, ManualTrigger, Agent, HttpRequestTool 等节点,结合人工智能技术实现智能自动化。 通过 GPT-4o 和 OctoPrint API 对话控制 3D 打印机

前置要求
  • Discord Bot Token 或 Webhook
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "YyMOJKUM7DmZpySf",
  "meta": {
    "instanceId": "b4fa5e208d17098379f0d875b3ffa037e21f16d6e20850aa3447c9f571e6dce5",
    "templateCredsSetupCompleted": true
  },
  "name": "OctoPrint 管理器",
  "tags": [],
  "nodes": [
    {
      "id": "17588807-7232-48f2-9746-9e5ebfb4370f",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -360,
        100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "338329b4-f691-4fac-bdab-ea5cd74add80",
      "name": "准备 OctoPrint 任务",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -80,
        100
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/job",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"command\": \"start\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "Content-Type: application/json"
            },
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c909da95-6a3e-4647-9da7-fcc375bcc517",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        372,
        460
      ],
      "parameters": {
        "options": {}
      },
      "retryOnFail": true,
      "typeVersion": 1.9
    },
    {
      "id": "9579f327-f2ec-456f-96aa-72693a0b2619",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -140,
        680
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "OPENAI-ID",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6ce7ede9-b95e-4e6a-ae54-84336956fc53",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -20,
        680
      ],
      "parameters": {
        "sessionKey": "Test",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "9cd904a0-90c7-42b6-be12-38d5be921881",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -360,
        460
      ],
      "webhookId": "WEBHOOK-ID",
      "parameters": {
        "public": true,
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "99e83e4f-5528-4fa4-9680-3f3126da6d26",
      "name": "列出 OctoPrint 任务",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        100,
        740
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/files",
        "options": {},
        "sendHeaders": true,
        "toolDescription": "Makes an HTTP request and returns the list of OctoPrint jobs available for print",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fc7e5787-2045-4fed-888b-9abed6705706",
      "name": "获取 OctoPrint 打印机状态",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        220,
        680
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/printer",
        "options": {},
        "sendHeaders": true,
        "toolDescription": "Makes an HTTP request and returns the OctoPrint Printer Status",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f113838d-08db-4f2c-a9da-03abf6274db0",
      "name": "暂停 OctoPrint 任务",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        340,
        740
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/job",
        "method": "POST",
        "options": {},
        "jsonBody": "{ \"command\": \"pause\", \"action\": \"pause\" }",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "toolDescription": "Makes an HTTP request and pauses the current print job",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "63ffabe8-85df-45a7-a643-8ee73515805c",
      "name": "取消 OctoPrint 任务",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        460,
        680
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/job",
        "method": "POST",
        "options": {},
        "jsonBody": "{ \"command\": \"cancel\" }",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "toolDescription": "Makes an HTTP request and cancel the current print job",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7b9c3760-a078-4215-88be-83f66d262aaa",
      "name": "恢复 OctoPrint 任务",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        580,
        740
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/job",
        "method": "POST",
        "options": {},
        "jsonBody": "{ \"command\": \"pause\", \"action\": \"resume\" }",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "toolDescription": "Makes an HTTP request and resume the current print job",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a78d26d9-dd3c-4282-9c2b-e09abbbe2a3a",
      "name": "连接 OctoPrint 到打印机",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        700,
        680
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/connection",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"command\": \"connect\",\n  \"port\": \"/dev/ttyUSB0\",\n  \"baudrate\": 115200,\n  \"printerProfile\": \"_default\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "toolDescription": "Makes an HTTP request and returns the OctoPrint Printer Status",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b998d0d3-1263-4ddd-929d-e2c22df66b0e",
      "name": "获取 OctoPrint 打印机连接状态",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        820,
        760
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/connection",
        "options": {},
        "sendHeaders": true,
        "toolDescription": "Makes an HTTP request and returns the OctoPrint Printer Status",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "26d5c411-efeb-484a-a81a-3139d8d44f54",
      "name": "开始 OctoPrint 任务",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        940,
        680
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/job",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"command\": \"start\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "toolDescription": "Makes an HTTP request and start the next print job.",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "22aa2ad2-0401-45a5-b718-c33c86825d6a",
      "name": "获取当前打印任务详情",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        200,
        880
      ],
      "parameters": {
        "url": "http://OctoPrint-IP/api/job",
        "options": {},
        "sendHeaders": true,
        "toolDescription": "Makes an HTTP request and returns the current job details from the 3d printer",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "OctoPrint-API-Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d207658e-eef2-4b17-b886-e80e5d81620f",
      "name": "Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        840,
        380
      ],
      "webhookId": "WEBHOOK-ID",
      "parameters": {
        "content": "={{ $json.output }}",
        "options": {},
        "authentication": "webhook"
      },
      "credentials": {
        "discordWebhookApi": {
          "id": "CuTjcFpLDBJufNt9",
          "name": "OctoPrint Manager"
        }
      },
      "typeVersion": 2
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "520b7a27-8a5a-4df1-b21d-f0e8bb36b1fc",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "List OctoPrint Jobs": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Pause OctoPrint Job": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Start OctoPrint Job": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Cancel OctoPrint Job": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Resume OctoPrint Job": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Connect OctoPrint to Printer": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get OctoPrint Printer Status": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Current Print Job Details": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Stage OctoPrint Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get OctoPrint Printer Connection Status": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 工程, 人工智能, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类3
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流