跳到內容
AggregaAggregaAggregaAggrega
選擇語言: 繁體中文
本頁為機器翻譯。閱讀英文原文。

匯入 n8n 工作流程

本逐步說明會匯入從 n8n 匯出的工作流程——一個以 OpenAI 聊天模型與記憶體回答聊天訊息的 AI 代理程式——轉成一個 Aggregate、一個 Release 與一個 Manifest,它們會建置出為 Docker Compose 承載該工作流程的 n8n,並照原樣寫出,然後建置它們並執行結果。下方的每個檔案與每一段輸出都來自實際執行;工作流程與逐步說明的每個階段都在 import-n8n 範例中,其中的檢查指令碼會再次執行匯入,把它寫出的內容、它印出的內容,以及本頁所引用的區塊,與該處保留的檔案比對,並驗證與建置匯入所寫出的內容。

草擬範例

你可以用本頁的命令執行這個匯入,或是讓你的 AI 助理替你執行。

把範例寫入一個以它命名的新資料夾:

Terminal window
aggrega draft --example import-n8n

接著它會印出下一步要執行的命令。第一個切換到新資料夾;其後的那一個(見下方)切換到它的 source 資料夾,其中存放本頁所匯入的內容,也是匯入執行的位置:

Terminal window
cd import-n8n

在 Visual Studio Code 中開啟的草擬範例 source 資料夾,顯示一個支援代理程式的 n8n 工作流程匯出檔,開頭是它的聊天觸發器與 AI Agent 節點。

工作流程

support-agent.json 是為本逐步說明以 n8n 匯出工作流程的形式所寫,包含四個節點:一個聊天觸發器、一個帶有簡短系統訊息的 AI Agent、一個選取 gpt-4o-mini 的 OpenAI Chat Model 節點,以及一個 Simple Memory 節點,由 n8n 以各連線離開之節點名稱所列出的連線相連。聊天觸發器是公開的,所以送到其 URL 的聊天訊息會啟動工作流程,而且它會向傳送者要求使用者與密碼,並對照 n8n 所儲存的基本驗證認證進行檢查:

"parameters": {
"public": true,
"authentication": "basicAuth",
"options": {}
},
[… omitted: the node's identifier, name, type, version, position and webhook identifier]
"credentials": {
"httpBasicAuth": {
"id": "Vx3mQ8rLb2Nk7Tz5",
"name": "Chat basic auth"
}
}

模型節點以同樣的方式選取它的認證,也就是以參照——匯出檔帶有每個認證的識別碼與名稱,絕不含使用者、密碼或金鑰:

"parameters": {
"model": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"id": "6f1d2c3a-7b4e-4a8f-9c21-0d3e5f6a7b03",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [120, 220],
"credentials": {
"openAiApi": {
"id": "Rb7nW2xQ9kT4mZ1c",
"name": "OpenAI account"
}
}

在工作流程旁,.aggrega-config.yaml 使該資料夾成為工作區:

# The workspace key marks this directory as the workspace root, so an import run
# here writes its drafts beside support-agent.json.
workspace: {}
# The registry the importer is fetched from the first time an import needs it.
default_registry: hub.aggrega.ai

而 import-answers.yaml 存放任何工作流程都無法持有的內容的答案。為 Docker Compose 的匯入不需要任何答案:它以 Docker Compose 從你的 shell 填入的變數參照來附加 OpenAI 金鑰。為 Kubernetes 的匯入則以 Kubernetes Secret 的名稱來附加它,而只有你能為它命名,所以檔案會指名該 Secret(見 在 Kubernetes 上):

# Values the import could not draft from the source, keyed by the drafted file and the key path inside
# it. Write each one beside its key; an import of the same source, and a sync, read them from here and
# ask nothing. A secret is never written here: its key asks where the secret comes from — a variable
# name, ${NAME}, or the name of a Kubernetes Secret.
release.yaml:
# The origin of the secret value, written by the operator in the Release. Read exactly as
# values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes
# from, never the value.
spec.components.n8n.uses.model.openai-chat-model.features.credential.infra.origin: "openai-api-key"

匯入答案檔 完整說明該檔案。

匯入會將每個節點與工作區目錄的 Components 比對,而 --target 會從其 Recipes 草擬 Manifest。工作區沒有指定目錄資料夾,所以匯入會從它取得匯入器的登錄庫讀取標準程式庫目錄:那是已發布目錄的簽署快照,由第一次匯入取得、驗證並保存在工作區的內容快取中,並以其摘要記載於匯入寫在草稿旁的記錄中。若工作區在 AGGREGA_CATALOG_DIRS 或 workspace.catalog_dirs 之下指定了自己的目錄資料夾,則改為針對那些目錄匯入。切換到 source:

Terminal window
cd source

執行匯入

Terminal window
aggrega import support-agent.json --target compose

在標準輸出上,它會列出所寫出的內容:

wrote aggregate.yaml
wrote release.yaml
wrote manifest.yaml
wrote .aggrega-import.json

在標準錯誤上,其中 <workspace> 代表你執行它所在的資料夾:

[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]
read as the n8n format, with drafted paths relative to <workspace>
warn: the value of credentials.httpBasicAuth.id of node When chat message received is carried as written in the flow the draft carries: its format marks the field as a credential, and setting empty_credentials to marked or all writes it empty
warn: the value of credentials.openAiApi.id of node OpenAI Chat Model is carried as written in the flow the draft carries: its format marks the field as a credential, and setting empty_credentials to marked or all writes it empty
warn: node OpenAI Chat Model reaches openai-chat-model, wired to the model socket of core/ai-agent/n8n as openai-chat-model, other than through that connection: an n8n @n8n/n8n-nodes-langchain.lmChatOpenAi node reaches the part at the address the stored credential it selects, or its own parameters, give; the platform delivers this connection as OPENAI_BASE_URL and OPENAI_API_KEY, but an n8n workflow reads a variable of the platform's environment only through an expression reading $env, which the platform refuses while values.allow_env_access_in_nodes is false, the value the draft leaves it at; setting it true lets every workflow, and every user who can edit one, read every variable of the platform's environment, the delivered credentials included
made no choice for When chat message received (@n8n/n8n-nodes-langchain.chatTrigger)
made no choice for AI Agent (@n8n/n8n-nodes-langchain.agent)
mapped OpenAI Chat Model (@n8n/n8n-nodes-langchain.lmChatOpenAi) to core/ai-model/openai as a reference, HIGH at 0.9143
made no choice for Simple Memory (@n8n/n8n-nodes-langchain.memoryBufferWindow)
warning: node "n8n" (provider "compose"): artifact "n8n-flow.compose-fragment.yaml": skipped provenance label injection — the fragment declares no compose service. Compose carries build provenance as service labels, so a fragment contributing only top-level networks, volumes or configs carries none; the services this component emits elsewhere carry the full set.
Pull complete: <workspace>/release.lock (entities=8, source_artifacts=0, external_inputs=0)

從編輯器執行匯入:草擬的 Aggregate、Release 與 Manifest 出現在工作流程匯出檔旁,Aggrega 輸出列出每個節點如何對應以及寫出的檔案,通知則說明匯入草擬了 3 個檔案,辨識為 n8n。

  • mapped 行 指出 OpenAI Chat Model 節點成為標準程式庫的 OpenAI 模型 core/ai-model/openai,採參照而非草擬,因為它在高層級以 0.9143 相符:一個自成一體的元件,連接到平台的 model 插槽。
  • made no choice 行 指出觸發器、代理程式與記憶體留在工作流程之內,由 n8n 自行執行。
  • 前兩個 warn 行 指名觸發器與模型節點所選取之已儲存認證的識別碼,n8n 將它們標記為認證。它們是參照而不是機密,並照原樣帶入。
  • 第三個 warn 行 是需要仔細閱讀的一行:模型節點是以它所選取的已儲存認證連到 OpenAI,而不是透過草稿所連接的連線。平台把連線交付到 n8n 的環境,而在 Aggregate 讓 values.allow_env_access_in_nodes 保持為 false(如草稿所做)時,n8n 會拒絕工作流程讀取其環境。把它設為 true 會讓每個工作流程,以及每位能編輯工作流程的人,讀取平台的每個變數,包括交付的金鑰。所以工作流程使用的金鑰是 n8n 所儲存的那一把,如 執行它 所示。
  • 最後兩行是拉取。沒有任何內容需要回答,所以匯入像 aggrega pull 一樣拉取了草稿 Release 的相依項目,並寫出 release.lock;下方的建置不需要更多內容。warning 行是建置也會印出的一行,Validate and build 會加以說明。

答案檔指名了一個此匯入不會詢問的 Secret:它沒有為它留下任何空白,所以不套用任何答案,並讓檔案保持原樣。

它寫出什麼

Aggregate、Release 與 Manifest 的名稱為 imported/support-agent,取自工作流程本身的名稱 Support agent,簡化為 support-agent——沒有名稱的工作流程則以其檔案命名——位於匯入器的 target_namespace 設定所指定的命名空間之下,除非你另行設定,否則為 imported(設定)。

aggregate.yaml——標準程式庫 n8n 平台 core/ai-agent/n8n 的一個實例,帶有照原樣匯出的工作流程(此處大部分省略),以及連到其 model 插槽的模型:

apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
name: imported/support-agent
version: 0.1.0
description: Draft Aggregate imported from a source in the n8n format.
spec:
components:
n8n:
type: core/ai-agent/n8n
values:
workflow_id: 'sQ4vT8nKp2LmX7bR'
flow_definition: |
{
"id": "sQ4vT8nKp2LmX7bR",
"name": "Support agent",
[… omitted: the rest of the workflow, as exported]
}
uses:
model:
openai-chat-model:
target: openai-chat-model
# For the compose target, the lines below declare credential on openai-chat-model: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none.
features:
credential:
type: core/secret-value
values:
key: OPENAI_API_KEY
# swap to core/ai-model/azure-openai (score 0.4125) by setting type: core/ai-model/azure-openai
openai-chat-model:
type: core/ai-model/openai
values:
model: |-
gpt-4o-mini

workflow_id 是匯出檔賦予工作流程的識別碼。模型是 core/ai-model/openai,帶有節點所選取的模型 gpt-4o-mini;其上方的註解指名該節點相似的目錄中另一個 Component,並附上其分數。平台呈現給模型的 OpenAI 金鑰,宣告在連線上,使用它在 n8n 環境中送達時的變數 OPENAI_API_KEY;Release 說明它來自何處。

release.yaml——Release,它以 Manifest 部署該 Aggregate:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
name: imported/support-agent
# environment is a drafted default, since no source names the environment this Release deploys to; change it to name the one it deploys to.
environment: development
version: 0.1.0
description: Draft Release imported from a source in the n8n format.
spec:
aggregate: imported/support-agent
manifest: imported/support-agent
components:
n8n:
infra:
# The image running core/ai-agent/n8n, at the version this importer drafts, which the catalog's Recipes for it are known to run; the import does not raise or lower it to follow the source.
image: "n8nio/n8n:1.110.1"
# Published on this machine's loopback address, 127.0.0.1: reachable from this machine only, by any process running on it. Delete this line to keep the service internal.
published_port: 5678
uses:
model:
openai-chat-model:
features:
credential:
type: core/secret-value
infra:
# Attached by reference, never as a value: the credential n8n presents to openai-chat-model on its model connection, read from the variable OPENAI_API_KEY, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value.
origin: "${OPENAI_API_KEY}"
openai-chat-model: {}
  • environment 是 development,這是預設值,其上方的註解說明要將它改為該 Release 部署的環境。
  • 映像檔 是 n8n 1.110.1,即目錄中 n8n 的 Recipes 所執行的版本。
  • published_port 是 5678,即 n8n 提供服務的連接埠,所以編輯器在你的機器上於 http://127.0.0.1:5678 回應。如其註解所述,這部機器上的任何處理程序都能在那裡連到它,其他任何東西都不能;刪除該行可讓 n8n 只留在堆疊的網路上。published_port 若不是 5678,則需要在它旁邊加上 infra.external_base_url: http://127.0.0.1:<published_port>,否則 n8n 會以 localhost:5678 回報其編輯器與 webhook 位址。
  • 金鑰 是變數參照 ${OPENAI_API_KEY},Docker Compose 會在堆疊啟動時從你的 shell 填入。標準程式庫的 OpenAI 模型是託管服務,而到它的連線必須帶有認證,所以 Release 附加了一個,即使工作流程是從 n8n 的儲存區讀取它的金鑰。

manifest.yaml——平台與模型的 Compose Recipes,以及把金鑰的變數參照原樣寫入 Compose 檔案的實現:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: imported/support-agent
version: 0.1.0
spec:
mappings:
components:
type:
core/ai-agent/n8n: compose/n8n
core/ai-model/openai: compose/openai
features:
type:
core/secret-value: compose/dotenv-secret

.aggrega-import.json 是匯入所寫內容的記錄,之後的 aggrega import --sync 會讀取它,而 release.lock 以版本與摘要鎖定該 Release 所解析到的每個目錄實體。

驗證並建置

Terminal window
aggrega validate --release release.yaml
aggrega build --release release.yaml

在驗證之後於編輯器中開啟的草擬 Release,Aggrega 輸出與通知都回報沒有發現問題。

草擬 Release 的建置:Explorer 中出現 dist 資料夾,Aggrega 輸出列出寫出的 Docker Compose 檔案,通知說明已寫出 1 個檔案。

驗證會印出:

notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)

以及建置,其中 <workspace> 代表保存草稿的資料夾:

warning: node "n8n" (provider "compose"): artifact "n8n-flow.compose-fragment.yaml": skipped provenance label injection — the fragment declares no compose service. Compose carries build provenance as service labels, so a fragment contributing only top-level networks, volumes or configs carries none; the services this component emits elsewhere carry the full set.
notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
[… omitted: a total build time, which differs per run]
Build completed: 1 file written to <workspace>/dist

warning 行是關於 Compose 檔案中承載工作流程的部分,即最上層的 configs 項目,它沒有可讓建置放置標籤的服務。notice 行僅供參考:機密 Feature 接受來自 Aggregate 的 values 或 Release 的 infra 的 origin,而此通知回報有一個葉節點在兩處都有宣告。兩者都不改變判定。

dist/compose/docker-compose.yaml 含有 n8n,以及一個在 n8n 啟動之前匯入工作流程的服務:

services:
n8n:
image: n8nio/n8n:1.110.1
environment:
OPENAI_BASE_URL: https://api.openai.com/v1
OPENAI_API_KEY: ${OPENAI_API_KEY}
N8N_BLOCK_ENV_ACCESS_IN_NODE: "true"
ports:
- 127.0.0.1:5678:5678
[… omitted: the labels the build writes on every service, naming the Aggregate, the component, the environment and the compiler's version]
volumes:
- type: volume
source: n8n--data
target: /home/node/.n8n
networks:
- compose
depends_on:
n8n--import-flow:
condition: service_completed_successfully
[… omitted: the service's health check]
n8n--import-flow:
image: n8nio/n8n:1.110.1
command:
- import:workflow
- --input=/flows/workflow.json
entrypoint:
- n8n
[… omitted: the labels the build writes on every service]
volumes:
- type: volume
source: n8n--data
target: /home/node/.n8n
networks:
- compose
restart: "no"
configs:
- source: n8n-flow
target: /flows/workflow.json

工作流程透過 n8n import:workflow 抵達 n8n,每次堆疊啟動時在相同的資料磁碟區上、於 n8n 本身之前執行。N8N_BLOCK_ENV_ACCESS_IN_NODE 為 "true",這是 n8n 對工作流程讀取其環境的封鎖,因為 Aggregate 讓 allow_env_access_in_nodes 保持為 false。所以 OpenAI Chat Model 節點從 n8n 自己的認證儲存區讀取它的金鑰,如同聊天觸發器讀取它的使用者與密碼,而下方的執行把兩者都儲存了。n8n 的 Compose Recipe 只在 Release 於 n8n 的 infra 中設定 published_port 時,才在你的機器上發布連接埠,而且只在回送位址 127.0.0.1 上;沒有它,服務就只能在堆疊的網路上連到。

搭配 AI 助理

設定了 Aggrega 工具的 AI 助理也能做同樣的事:把這段提示貼給它。

請只使用 Aggrega 工具,且不要自行建立任何資料夾。如果工作區資料夾中還沒有 `import-n8n` 資料夾,請呼叫 `draft` 工具一次,將 `example` 設為 `import-n8n`,且不帶 `dir`:它會把範例寫入新的 `import-n8n` 資料夾,其 `source` 資料夾存放本頁所匯入的內容。接著呼叫 `import` 工具,將 `workspace_root` 設為 `import-n8n/source`、`source` 設為 `support-agent.json`、`target` 設為 `compose`:它會從 `support-agent.json` 旁的 `import-answers.yaml` 讀取所需的答案,把草稿寫入 `import-n8n/source`,並拉取它們所需的內容。接著呼叫 `validate` 工具,將 `workspace_root` 設為 `import-n8n/source`、`release` 設為 `release.yaml`,再呼叫 `build` 工具,將 `workspace_root` 設為 `import-n8n/source`、`release` 設為 `release.yaml`、`write` 設為 true。告訴我建置寫出了哪些檔案;它們位於 `import-n8n/source/dist/`。

在 VS Code 中開啟

安裝 Visual Studio Code 的 Aggrega 擴充功能之後,在 VS Code 中開啟資料夾 import-n8n/source,也就是匯入寫出草稿的地方。資料夾中有一個 Release,即草擬的 release.yaml,所以編輯器會替你選取它,並在你編輯時對照該 Release 檢查草稿,把發現的問題標示在檔案與 Problems 面板中。Command Palette 中的 Aggrega: Show topology graph 會繪出 Release 的元件與它們之間的連線。Aggrega: Build、Aggrega: Preview build 與 Aggrega: Pull 作用於同一個 Release,且每一個也都是活動列中 Aggrega 檢視的 Commands 面板上的按鈕;Build 會把檔案寫入資料夾的 dist/。在 Visual Studio Code 中使用 Aggrega 涵蓋其餘部分。

執行

n8n 從自己的儲存區,依識別碼讀取工作流程所選取的兩個認證:OpenAI 金鑰在 Rb7nW2xQ9kT4mZ1c 之下,聊天的使用者與密碼在 Vx3mQ8rLb2Nk7Tz5 之下。n8n 自己的命令列會從檔案,以那些識別碼儲存它們。用你自己的值把它們寫入 credentials.json:

[
{"id": "Rb7nW2xQ9kT4mZ1c", "name": "OpenAI account", "type": "openAiApi", "data": {"apiKey": "your OpenAI key"}},
{"id": "Vx3mQ8rLb2Nk7Tz5", "name": "Chat basic auth", "type": "httpBasicAuth", "data": {"user": "a user of your own", "password": "a password of your own"}}
]

在你的 shell 中設定金鑰,如草擬的 Release 所讀取的那樣,並啟動堆疊:

Terminal window
export OPENAI_API_KEY='your OpenAI key'
docker compose -p support-agent -f dist/compose/docker-compose.yaml up -d --wait

-p 指定專案名稱,如 匯入如何執行 的執行步驟所說明。--wait 會在 n8n 回報健康後返回,此時匯入工作流程的服務已經執行並結束。把認證複製到 n8n 的容器中,匯入它們,並移除該副本:

Terminal window
docker compose -p support-agent -f dist/compose/docker-compose.yaml exec -T n8n sh -c 'umask 077; cat > /tmp/credentials.json' < credentials.json
docker compose -p support-agent -f dist/compose/docker-compose.yaml exec n8n n8n import:credentials --input=/tmp/credentials.json
docker compose -p support-agent -f dist/compose/docker-compose.yaml exec n8n rm /tmp/credentials.json
[… omitted: n8n's notices about its settings file's permissions, error tracking and deprecated settings]
Successfully imported 2 credentials.

n8n 現在持有這兩個認證,所以刪除 credentials.json:

Terminal window
rm credentials.json

接著啟用工作流程,並重新啟動 n8n 讓啟用生效:

Terminal window
docker compose -p support-agent -f dist/compose/docker-compose.yaml exec n8n n8n update:workflow --id=sQ4vT8nKp2LmX7bR --active=true
docker compose -p support-agent -f dist/compose/docker-compose.yaml restart n8n

當 docker compose -p support-agent -f dist/compose/docker-compose.yaml ps n8n 再次顯示 n8n 為 (healthy) 時,docker compose -p support-agent -f dist/compose/docker-compose.yaml logs n8n 會讀到 Activated workflow "Support agent" (ID: sQ4vT8nKp2LmX7bR)。

測試

開啟 http://127.0.0.1:5678,也就是 published_port 所發布的位址:n8n 的編輯器在第一次造訪時會要求建立擁有者帳戶,然後顯示 Support agent。

聊天觸發器只在提供上面儲存的使用者與密碼時才接受訊息;沒有它們時,它回應 HTTP/1.1 401 Unauthorized 與 Authorization is required!,密碼錯誤時則回應 HTTP/1.1 403 Forbidden。把兩者放在 CHAT_USER 與 CHAT_PASSWORD 中,curl 從它的標準輸入讀取它們,所以它們不會出現在任何命令列上:

Terminal window
printf 'user = "%s:%s"\n' "$CHAT_USER" "$CHAT_PASSWORD" | curl --config - -sS -i -X POST \
http://127.0.0.1:5678/webhook/a3c9e1f2-4b5d-4e6f-8a7b-9c0d1e2f3a04/chat -H 'Content-Type: application/json' \
-d '{"action": "sendMessage", "sessionId": "s1", "chatInput": "In one short sentence: what does a support plan cover?"}'
HTTP/1.1 500 Internal Server Error
[… omitted: the response's other headers]
{"message":"Error in workflow"}

這次執行為 OpenAI 金鑰儲存了預留位置,所以工作流程在呼叫模型時停止。n8n 保留該次執行紀錄,編輯器會在工作流程的執行項目下列出它,並附上 OpenAI 的拒絕訊息:Incorrect API key provided: sk-place*****************-key. 使用你的金鑰時,回覆是 HTTP/1.1 200 OK 與代理程式的答案,形式為 {"output": "…"}。

在 Kubernetes 上,套用 在 Kubernetes 上 所述的建置結果之後,n8n 把資料保存在一個與其 pod 同生命週期的磁碟區中,所以新的 pod 啟動時不會有你所儲存的內容;請改在執行中的實例上儲存認證並啟用工作流程。如 執行它 那樣寫出 credentials.json,透過 kubectl exec 從它的標準輸入,在你套用的命名空間中匯入它,之後再刪除它:

Terminal window
kubectl exec -i -n <namespace> deploy/n8n -- n8n import:credentials --input=/dev/stdin < credentials.json
Defaulted container "main" out of: main, import-flow (init)
[… omitted: n8n's notices about its settings file's permissions, error tracking and deprecated settings]
Successfully imported 2 credentials.

把本機連接埠轉送到 n8n 的 Service n8n-default,並讓命令持續執行:

Terminal window
kubectl port-forward -n <namespace> svc/n8n-default 5678:5678

從另一個終端機,透過 n8n 的 API 設定擁有者帳戶,它會讓你登入並把工作階段保存在 cookies.txt 中,然後啟用工作流程:

Terminal window
curl -sS -c cookies.txt -X POST http://127.0.0.1:5678/rest/owner/setup -H 'Content-Type: application/json' \
-d '{"email": "owner@example.com", "firstName": "Your", "lastName": "Name", "password": "a password of your own"}'
curl -sS -b cookies.txt -X PATCH http://127.0.0.1:5678/rest/workflows/sQ4vT8nKp2LmX7bR \
-H 'Content-Type: application/json' -d '{"active": true}'

第二個回覆就是工作流程,帶有 "active":true。上面的聊天訊息接著在同一個位址到達它,沒有變化;該次執行得到相同的 {"message":"Error in workflow"} 與執行中相同的拒絕訊息。

以下方的命令停止堆疊。-v 也會移除 n8n 的資料磁碟區,連同儲存的認證與啟用狀態:

Terminal window
docker compose -p support-agent -f dist/compose/docker-compose.yaml down -v

在 Kubernetes 上

同一個工作流程可以用 helm 目標匯入到 Kubernetes。Docker Compose 的草稿已經放在 source 中,而匯入從不覆寫那裡的 Aggregate,所以請用 --output-dir 把這些草稿放進它們自己的資料夾,然後從那裡驗證並建置:

Terminal window
aggrega import support-agent.json --target helm --output-dir helm
cd helm
aggrega validate --release release.yaml
aggrega build --release release.yaml

草稿在目標不同之處有所差異。Manifest 把平台對應到 helm/n8n,把模型對應到 helm/openai,把金鑰對應到 helm/k8s-existing-secret,它從命名空間中已存在的 Secret 讀取金鑰。Release 以 core/referenced-secret 附加金鑰,並從答案檔指名該 Secret,即 openai-api-key。

建置會在工作區根目錄 source 的 dist/helm/ 之下寫出純 Kubernetes 資訊清單,從 helm 看來即 ../dist/helm/。在你套用的命名空間中建立 Secret,把金鑰放在資料鍵 value 之下,然後如 匯入如何執行 的執行步驟所說明的那樣套用該資料夾。工作流程仍從 n8n 自己的儲存區讀取它的認證,測試 會在 Kubernetes 上填入它。