不確定要將哪些資料傳送至 PDF Node

大家好

在過去的幾天裡,我一直被這個工作流程卡住了。我的目標是將試算表數據發送到 PDF 節點,以便它可以建立自訂報價。

但是,每當我嘗試使用試算表數據建立報價時,模板就會顯示為空白。我昨天已經詢問過這個主題:Can't create PDF Template to send to workflow - #2 by kjooleng

一個解決方案是將我的模板中的變數對映到 JSON,即 {“customer.name” {{ $(“Edit Fields”).item.json[“What’s your name?”] }}}。我嘗試過,但仍然得到了空白模板

提供的另一個解決方案是將 PDF 產生器節點中的「資料」部分變更為:

{
“quote_content”: “{{ $json.output }}”
}

並更新 PDF 模板以包含此變數。我試過這種方法,也將「quote_content」新增到 PDF 產生器 API 模板中的個別 JSON 陣列。但我仍然得到空白模板。

我也切換為使用自訂範本而不包含任何新變數,以便我可以在不擔心任何外部變數的情況下傳遞數據。

我遺漏了什麼步驟?

任何幫助將不勝感激

{
“nodes”: [
{
“parameters”: {
“formTitle”: “Get a Quote for a Function”,
“formDescription”: “Hey there!\n\nMy name’s Quotebot, your friendly quoting assistant for every function you need.\n\nJust answer the questions below, and we’ll get back to you ASAP”,
“formFields”: {
“values”: [
{
“fieldLabel”: “What function are you hosting?”
},
{
“fieldLabel”: “How many people are expected to attend?”,
“fieldType”: “number”
},
{
“fieldLabel”: “Do any guests have Dietary Requirements?”
},
{
“fieldLabel”: “When will your function be held?”,
“fieldType”: “date”
},
{
“fieldLabel”: “What’s your name?”
},
{
“fieldLabel”: “What’s your email address?”,
“fieldType”: “email”
},
{
“fieldLabel”: “What is the event name?”
},
{
“fieldLabel”: “What is the venue address?”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.formTrigger”,
“typeVersion”: 2.5,
“position”: [
-64,
64
],
“id”: “f097eb29-0b1f-4d29-9e1f-67a3674f68f6”,
“name”: “On form submission”,
“webhookId”: “388b123e-f115-4213-9bd7-b4ad56bea13a”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “=Hi There\n\nCould you please write a full quote for {{ $(“Edit Fields”).item.json[“What’s your name?”] }} and send it to {{ $(“Edit Fields”).item.json[“What’s your email address?”] }}?\n\nClient Details:\n- Function Type: {{ $(“Edit Fields”).item.json[“What function are you hosting?”] }}\n- Expected Attendees: {{ $(“Edit Fields”).item.json[“How many people are expected to attend?”] }}\n- Dietary Requirements: {{ $(“Edit Fields”).item.json[“Do any guests have Dietary Requirements?”] }}\n- Function Date: {{ $(“Edit Fields”).item.json[“When will your function be held?”] }}\n- Event Name: {{ $json[‘What is the event name?’] }}\n- Venue Address {{ $json[‘What is the venue address?’] }}\n\n”,
“options”: {
“systemMessage”: “=You are a Catering Business Quoting Expert.\n\nYou’re given access to an MCP Client Server\n\nI need you to use it to create a Quote for a client and send it to them as an email \n\n{{ $today }}”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 3.1,
“position”: [
384,
64
],
“id”: “982cc05d-25be-4b87-a048-d6f39591c952”,
“name”: “AI Agent”,
“alwaysOutputData”: true,
“onError”: “continueRegularOutput”
},
{
“parameters”: {
“modelName”: “models/gemini-2.5-flash-lite”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatGoogleGemini”,
“typeVersion”: 1.1,
“position”: [
400,
288
],
“id”: “76de3829-d663-44b0-a562-1b7ea31e98c1”,
“name”: “Google Gemini Chat Model”,
“credentials”: {
“googlePalmApi”: {
“id”: “r5K1AFY1c2dmiqsE”,
“name”: “Google Gemini(PaLM) Api account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “1fb0c0f2-eff7-4900-9ca9-15950c133260”,
“name”: “What function are you hosting?”,
“value”: “={{ $json[“What function are you hosting?”] }}”,
“type”: “string”
},
{
“id”: “c4171ed1-c773-4dec-9126-57d400eb9bbd”,
“name”: “How many people are expected to attend?”,
“value”: “={{ $json[“How many people are expected to attend?”] }}”,
“type”: “number”
},
{
“id”: “feeaa131-f6c7-47d0-b16a-a107e56c5d8d”,
“name”: “Do any guests have Dietary Requirements?”,
“value”: “={{ $json[“Do any guests have Dietary Requirements?”] }}”,
“type”: “string”
},
{
“id”: “c5318dd3-dbcc-4a18-ab72-90c2eda07fb2”,
“name”: “When will your function be held?”,
“value”: “={{ $json[“When will your function be held?”] }}”,
“type”: “string”
},
{
“id”: “754d4f71-338b-4b3e-ba87-c66852b76799”,
“name”: “What’s your name?”,
“value”: “={{ $json[“What’s your name?”] }}”,
“type”: “string”
},
{
“id”: “5432c27a-958f-4f76-9fa0-3663ab7b8f19”,
“name”: “What’s your email address?”,
“value”: “={{ $json[“What’s your email address?”] }}”,
“type”: “string”
},
{
“id”: “3644948e-b74b-42fe-8456-0261a87e81a2”,
“name”: “What is the event name?”,
“value”: “={{ $json[‘What is the event name?’] }}”,
“type”: “string”
},
{
“id”: “19d462d9-c51e-421e-8e7e-f900742ffd99”,
“name”: “What is the venue address?”,
“value”: “={{ $json[‘What is the venue address?’] }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
160,
64
],
“id”: “400a62c7-dab9-4924-88cc-5cab0a0e14ac”,
“name”: “Edit Fields”
},
{
“parameters”: {
“endpointUrl”: “https://timb.app.n8n.cloud/mcp/8d44ab8f-e11c-492a-9b68-b3fbafec81f5”,
“include”: “selected”,
“includeTools”: [
“furniture_Rentals”,
“Payment”,
“Additional_Service”,
“Pricing”,
“Menu_Drinks”,
“Staffing”,
“Venue_Logistics”,
“Ingredients”
],
“options”: {}
},
“id”: “22441ba6-367a-48ca-9f76-938338ecb6c3”,
“name”: “MCP Client Tool”,
“type”: “@n8n/n8n-nodes-langchain.mcpClientTool”,
“typeVersion”: 1.3,
“position”: [
528,
288
]
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “acf6fc3f-89fd-4c14-865f-c9bb597e4b62”,
“name”: “output”,
“value”: “={{ $json.output }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
736,
64
],
“id”: “15f99c2a-3831-4241-94f2-574c4f794f5f”,
“name”: “Edit Fields1”
},
{
“parameters”: {
“sendTo”: “barrtimm@gmail.com”,
“subject”: “Job’s wedding Quote”,
“emailType”: “text”,
“message”: “=Hey there here’s your quote”,
“options”: {
“appendAttribution”: false,
“attachmentsUi”: {
“attachmentsBinary”: [
{
“property”: “={{ $json.filename }}”
}
]
}
}
},
“type”: “n8n-nodes-base.gmail”,
“typeVersion”: 2.2,
“position”: [
1408,
64
],
“id”: “e0df1045-382b-47b2-bb57-8120a7554cbb”,
“name”: “Send a message”,
“webhookId”: “528a735e-f777-4a86-9115-82bab5906ab7”
},
{
“parameters”: {
“templateId”: {
“__rl”: true,
“value”: “1650471”,
“mode”: “list”,
“cachedResultName”: “Job Blob Quote (ID: 1650471)”
},
“data”: “={“quote_content”: “{{ $json.output }}” }”,
“documentOutput”: “file”,
“additionalFields”: {}
},
“type”: “@pdfgeneratorapi/n8n-nodes-pdf-generator-api.pdfGeneratorApi”,
“typeVersion”: 1,
“position”: [
944,
64
],
“id”: “ea60f1cf-803e-4b97-b2fa-bc03045c7394”,
“name”: “Generate a PDF document”,
“credentials”: {
“pdfGeneratorApi”: {
“id”: “XUfVEGWx0Q45fr5L”,
“name”: “PDF Generator account”
}
}
}
],
“connections”: {
“On form submission”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
},
“AI Agent”: {
“main”: [
[
{
“node”: “Edit Fields1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Gemini Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Edit Fields”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“MCP Client Tool”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Edit Fields1”: {
“main”: [
[
{
“node”: “Generate a PDF document”,
“type”: “main”,
“index”: 0
}
]
]
},
“Generate a PDF document”: {
“main”: [
[
{
“node”: “Send a message”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {
“On form submission”: [
{
“What function are you hosting?”: “wedding”,
“How many people are expected to attend?”: 69,
“Do any guests have Dietary Requirements?”: “yes - Jack Pescatarian”,
“When will your function be held?”: “2026-09-23”,
“What’s your name?”: “Skoot”,
“What’s your email address?”: “barrtimm@gmail.com”,
“What is the event name?”: “Skkoot and toots wedding”,
“What is the venue address?”: “10 Stanley La”,
“submittedAt”: “2026-06-17T07:48:32.786+10:00”,
“formMode”: “test”
}
]
},
“meta”: {
“instanceId”: “845031bfdb8f607d8c7ae907fb5de28c6fb4d0a8d0cd06c1a605d7c42f4018a9”
}
}

嘿 Tim,

空白 PDF 幾乎總是歸結為以下兩個原因之一:你傳送到 PDF Generator API 節點的資料不是有效的 JSON,或是樣板變數名稱與你傳送的金鑰不符。看你的工作流程,我相當確定是第一個原因。

**最可能的原因是你的 data 欄位。**現在它是 ={ "quote_content": "{{ $json.output }}" }。問題在於:$json.output 是 AI 生成的文字,所以它包含換行符、引號和撇號。當 n8n 把這個原始文字放入你手寫的 JSON 字串時,這些字元會破壞 JSON(字串值內有未轉義的引號或換行符 = 無效的 JSON),所以 PDF Generator API 會收到無法解析的內容,進而用沒有資料的方式渲染樣板,也就是空白。

**解決方法:**讓 n8n 為你建立 JSON,這樣才能始終正確轉義。將 Data 欄位設為 ={{ JSON.stringify({ quote_content: $json.output }) }}。這樣 quote_content 就會始終以乾淨、有效的值形式抵達。

**接著驗證兩件事。**首先,確認 output 確實已填入:開啟 AI Agent 的最後一次執行,確認 output 包含完整的引言文字。你的代理設有 onError: continueRegularOutput,所以如果 Gemini/MCP 步驟無聲地失敗,它會將空的 output 往下游傳遞,即使對應已修正,你也會得到空白 PDF。其次,確認樣板中的確切變數名稱:在 Job Blob Quote (1650471) 中,預留位置必須完全是 {{quote_content}},拼寫相同且沒有多餘空格,否則值無法送入。

先做 JSON.stringify 的變更並重新執行;這在絕大多數「我傳送了資料但它是空白」的情況下都能修好。如果在做了這個之後 output 仍然是空的,貼上代理傳回的內容,我們再從那邊追蹤。

1 個讚