YNAB自动预算
高级
这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 29 个节点。主要使用 If, Set, Merge, Filter, Discord 等节点。 使用GPT-5-Mini自动分类YNAB交易并发送Discord通知
前置要求
- •Discord Bot Token 或 Webhook
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
使用的节点 (29)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "gJVUOpQW1iQO8hDK",
"meta": {
"instanceId": "ae3a7d69e340d9eec0196c03fd00e81b6e376d3084103c5850dd2cee1ac033f6",
"templateCredsSetupCompleted": true
},
"name": "YNAB 自动预算",
"tags": [],
"nodes": [
{
"id": "219be639-7a8b-4cf3-8b8d-54cfa084fedb",
"name": "当点击“执行工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-80,
608
],
"parameters": {},
"typeVersion": 1
},
{
"id": "e320e200-279d-4d7b-8f9a-dbc90ce127ff",
"name": "变量",
"type": "n8n-nodes-base.set",
"position": [
144,
608
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5a1da0c7-e664-4662-b3b6-3a19cf54da36",
"name": "budget_id",
"type": "string",
"value": "CHANGEME"
},
{
"id": "7f849d4b-72ba-4d4a-82e0-485e5fdde1ba",
"name": "account_id",
"type": "string",
"value": "CHANGEME"
},
{
"id": "ae5133fe-f370-4d13-8be7-8c9cfe607574",
"name": "api_key",
"type": "string",
"value": "CHANGEME"
},
{
"id": "b5476fcc-763e-4a8d-97ca-2447cc8984d1",
"name": "previous_days",
"type": "string",
"value": "30"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "fded027b-70ed-44e4-88fc-2b9ae9a73d21",
"name": "获取分类",
"type": "n8n-nodes-base.httpRequest",
"position": [
368,
488
],
"parameters": {
"url": "=https://api.ynab.com/v1/budgets/{{ $json.budget_id }}/categories",
"options": {},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "accept",
"value": "application/json"
},
{
"name": "Authorization",
"value": "=Bearer {{ $json.api_key }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "71e6736f-f3ff-438a-86d1-9cf9120e4ed4",
"name": "获取分类组",
"type": "n8n-nodes-base.splitOut",
"position": [
592,
488
],
"parameters": {
"options": {},
"fieldToSplitOut": "data.category_groups"
},
"typeVersion": 1
},
{
"id": "1c082196-26a7-40fe-995c-43b2c17c45fa",
"name": "移除无效分类组",
"type": "n8n-nodes-base.filter",
"position": [
816,
488
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9dcb56d5-a68f-4fa1-9957-414c4b31673a",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
},
"leftValue": "={{ $json.hidden }}",
"rightValue": "true"
},
{
"id": "0fdf4d82-5ab2-4e93-85dc-9941fb13f3b2",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
},
"leftValue": "={{ $json.deleted }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "5d3bce98-2d5f-4bd4-8d1e-7f6686e1e73b",
"name": "隐藏内部分类",
"type": "n8n-nodes-base.filter",
"position": [
1264,
488
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "5ac0ef28-11d5-4a89-9a03-a807540a9c19",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
},
"leftValue": "={{ $json.hidden }}",
"rightValue": ""
},
{
"id": "96a8c890-a08b-4841-a14e-aa7d8f9a6d9e",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
},
"leftValue": "={{ $json.deleted }}",
"rightValue": ""
},
{
"id": "4984c1bb-a80b-4c30-8818-d614f2c3bf55",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.category_group_name }}",
"rightValue": "=\"Internal Master Category\""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "19132f05-a6d1-4e16-a8b9-eaaf93ad25f9",
"name": "将分类组扁平化为分类",
"type": "n8n-nodes-base.splitOut",
"position": [
1040,
488
],
"parameters": {
"options": {},
"fieldToSplitOut": "=categories"
},
"typeVersion": 1
},
{
"id": "dc74b4ed-a5e7-4a9e-b721-8f501261d716",
"name": "仅分类",
"type": "n8n-nodes-base.set",
"position": [
1488,
488
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "4a6fb057-55ab-4b67-bad6-77c505bea0f7",
"name": "id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "f132fcc8-a3cd-4f78-b9f0-c0f6965f1e97",
"name": "name",
"type": "string",
"value": "={{ $json.name }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "b98fa812-d775-46c2-ab4c-631de78b8069",
"name": "获取交易记录",
"type": "n8n-nodes-base.httpRequest",
"position": [
1040,
680
],
"parameters": {
"url": "=https://api.ynab.com/v1/budgets/{{ $json.budget_id }}/accounts/{{ $json.account_id }}/transactions",
"options": {},
"sendQuery": true,
"sendHeaders": true,
"queryParameters": {
"parameters": [
{
"name": "since_date",
"value": "={{ $today.minus({ days: $json.previous_days }).format('yyyy-MM-dd') }}"
},
{
"name": "type",
"value": "uncategorized"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "accept",
"value": "application/json"
},
{
"name": "Authorization",
"value": "=Bearer {{ $json.api_key }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "427d33a0-f867-49ec-9ed9-57a64e9f1969",
"name": "拆分交易记录",
"type": "n8n-nodes-base.splitOut",
"position": [
1264,
680
],
"parameters": {
"options": {},
"fieldToSplitOut": "data.transactions"
},
"typeVersion": 1
},
{
"id": "20d062e0-3197-4935-8566-bfae13e5caf6",
"name": "筛选出转账和无效交易",
"type": "n8n-nodes-base.filter",
"position": [
1488,
680
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "abf0b4b4-ac98-4a9c-bd5d-2d09a7bd7942",
"operator": {
"type": "boolean",
"operation": "notExists",
"singleValue": true
},
"leftValue": "={{ $json.category_id }}",
"rightValue": ""
},
{
"id": "f1549604-56eb-48eb-892e-7896c65c206d",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
},
"leftValue": "={{ $json.deleted }}",
"rightValue": ""
},
{
"id": "abd3c4bf-7f6c-41a9-8142-47ccf3086244",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.category_name }}",
"rightValue": "Uncategorized"
},
{
"id": "8e2bf6e6-3f70-4d19-9c4b-efa5ab246a70",
"operator": {
"type": "boolean",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.transfer_account_id?.toBoolean() }}",
"rightValue": ""
},
{
"id": "f51eff3f-68ea-4695-816d-f1a346385be0",
"operator": {
"type": "boolean",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.transfer_transaction_id?.toBoolean() }}",
"rightValue": ""
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "6c763ed4-e51e-4d29-93f5-4610478d0c30",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
1936,
608
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "934c3ccd-94d6-4567-8a30-044d7e9dcd5c",
"name": "分类分组",
"type": "n8n-nodes-base.aggregate",
"position": [
1712,
488
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData",
"destinationFieldName": "categories"
},
"typeVersion": 1
},
{
"id": "63ef450d-8c10-452f-aaf7-39dddeb52436",
"name": "交易分组",
"type": "n8n-nodes-base.aggregate",
"position": [
1712,
680
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData",
"destinationFieldName": "transactions"
},
"typeVersion": 1
},
{
"id": "13ad851d-e43f-46e8-a90b-b2e9eed9931d",
"name": "AI 代理1",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
2608,
608
],
"parameters": {
"text": "=Given the following list of budget categories\n\n{{ JSON.stringify($('Categories Only').all(),null,2) }}\n\nAnalyze this json and come up with the most likely best fit for budget category, if you do not know or there is no good match then ignore it. \n\nIf you come up with a good match then change the output fields\noutput.category_id = budget.id\noutput.category_name = budget.name\noutput.flag_color = 'yellow'\noutput.flag_name = 'n8n'\n\nLeave all other fields alone and return them exactly as they were provided for the input. \n\nHere is the input data: \n{{ JSON.stringify($json,null,2) }}\n\n\n\n",
"options": {
"systemMessage": "You are a helpful assistant who is tasked with categorizing budget items. "
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "a7e6d5de-86f6-4341-a033-86fcdeada5e0",
"name": "OpenAI 聊天模型2",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
2616,
832
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-5-mini",
"cachedResultName": "gpt-5-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "hgh87ytGnFXvL4mw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "5c7d87fe-7ee3-4a8b-bb1c-90cd39966f99",
"name": "结构化输出解析器 1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
2744,
832
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"id\": { \"type\": \"string\" },\n \"date\": { \"type\": \"string\" },\n \"amount\": { \"type\": \"number\" },\n \"memo\": { \"type\": [\"string\", \"null\"] },\n \"cleared\": { \"type\": \"string\" },\n \"approved\": { \"type\": \"boolean\" },\n \"flag_color\": { \"type\": [\"string\", \"null\"] },\n \"flag_name\": { \"type\": [\"string\", \"null\"] },\n \"account_id\": { \"type\": \"string\" },\n \"account_name\": { \"type\": \"string\" },\n \"payee_id\": { \"type\": [\"string\", \"null\"] },\n \"payee_name\": { \"type\": [\"string\", \"null\"] },\n \"category_id\": { \"type\": [\"string\", \"null\"] },\n \"category_name\": { \"type\": [\"string\", \"null\"] },\n \"transfer_account_id\": { \"type\": [\"string\", \"null\"] },\n \"transfer_transaction_id\": { \"type\": [\"string\", \"null\"] },\n \"matched_transaction_id\": { \"type\": [\"string\", \"null\"] },\n \"import_id\": { \"type\": [\"string\", \"null\"] },\n \"import_payee_name\": { \"type\": [\"string\", \"null\"] },\n \"import_payee_name_original\": { \"type\": [\"string\", \"null\"] },\n \"debt_transaction_type\": { \"type\": [\"string\", \"null\"] },\n \"deleted\": { \"type\": \"boolean\" },\n \"subtransactions\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\" },\n \"transaction_id\": { \"type\": [\"string\", \"null\"] },\n \"amount\": { \"type\": \"number\" },\n \"memo\": { \"type\": [\"string\", \"null\"] },\n \"payee_id\": { \"type\": [\"string\", \"null\"] },\n \"payee_name\": { \"type\": [\"string\", \"null\"] },\n \"category_id\": { \"type\": [\"string\", \"null\"] },\n \"category_name\": { \"type\": [\"string\", \"null\"] },\n \"transfer_account_id\": { \"type\": [\"string\", \"null\"] },\n \"transfer_transaction_id\": { \"type\": [\"string\", \"null\"] },\n \"deleted\": { \"type\": [\"boolean\", \"null\"] }\n },\n \"required\": [\"id\", \"amount\"]\n },\n \"minItems\": 0\n }\n}"
},
"typeVersion": 1.3
},
{
"id": "fa5c461b-40a1-413a-82cd-8be3098d18ea",
"name": "循环交易",
"type": "n8n-nodes-base.splitOut",
"position": [
2384,
608
],
"parameters": {
"options": {},
"fieldToSplitOut": "transactions"
},
"typeVersion": 1
},
{
"id": "ccee6170-02b5-4e88-93c1-acbbf2b8bb91",
"name": "跳过分类,循环交易",
"type": "n8n-nodes-base.if",
"position": [
2160,
608
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "02774f04-b665-4fe5-9e64-ba067c8bc5f9",
"operator": {
"type": "array",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.transactions }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f8798e8d-0219-437a-8397-c5328f892127",
"name": "Discord",
"type": "n8n-nodes-base.discord",
"position": [
3408,
416
],
"webhookId": "ff2f3f9e-8d88-49c4-bf61-cc3b507764ba",
"parameters": {
"content": "=Auto budgeted {{ $json.transactions[0].length }} transactions.\n\n{{ $json.transactions[0].map(transaction => '- ' + transaction.payee_name + ' | ' + transaction.category_name + ' | $' + (transaction.amount / 1000)).join('\\n') }}\n\nhttps://app.ynab.com/{{$('Variables').item.json.budget_id}}/accounts/{{ $('Variables').item.json.account_id }}",
"options": {
"username": "YNAB Budget Bot",
"avatar_url": "https://images.icon-icons.com/401/PNG/512/YNAB_40408.png"
},
"authentication": "webhook"
},
"credentials": {
"discordWebhookApi": {
"id": "jtusjd0AfNR35Ocl",
"name": "Discord Webhook Budget Items"
}
},
"typeVersion": 2
},
{
"id": "2230670b-f75d-44f7-80d1-25c88efa4472",
"name": "YNAB 修改交易",
"type": "n8n-nodes-base.httpRequest",
"position": [
3408,
680
],
"parameters": {
"url": "=https://api.ynab.com/v1/budgets/{{$('Variables').item.json.budget_id}}/transactions",
"method": "PATCH",
"options": {},
"jsonBody": "={\n \"transactions\": {{ JSON.stringify($json.transactions, null, 2) }}\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "accept",
"value": "application/json"
},
{
"name": "Authorization",
"value": "=Bearer {{ $('Variables').item.json.api_key }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "960d9537-f042-4e55-b9f4-49aecff6dfab",
"name": "Loop Over Items1",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2960,
608
],
"parameters": {
"options": {},
"batchSize": 10
},
"typeVersion": 3
},
{
"id": "98cd53d7-5f74-410c-a84a-93e80da98b81",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"position": [
3184,
608
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"renameField": true,
"outputFieldName": "transactions",
"fieldToAggregate": "output"
}
]
}
},
"typeVersion": 1
},
{
"id": "2925d200-77ee-4ac9-bf62-5eebc1e6ae47",
"name": "聚合1",
"type": "n8n-nodes-base.aggregate",
"position": [
3184,
416
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "data.transactions"
}
]
}
},
"typeVersion": 1
},
{
"id": "c2347fc5-7fca-48fd-a7dc-9b962e573f16",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
336,
368
],
"parameters": {
"width": 1520,
"height": 272,
"content": "## YNAB 获取分类"
},
"typeVersion": 1
},
{
"id": "59ddf065-cafc-492a-a498-80a12c7a5413",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
336,
656
],
"parameters": {
"width": 1520,
"height": 272,
"content": "## YNAB 获取未分类交易"
},
"typeVersion": 1
},
{
"id": "e778a2e5-8301-464a-b226-83c27321576b",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
2528,
416
],
"parameters": {
"width": 384,
"height": 560,
"content": "## 分类匹配"
},
"typeVersion": 1
},
{
"id": "8a15011b-7673-42a9-94e1-da27464ef4da",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
3344,
576
],
"parameters": {
"width": 512,
"height": 304,
"content": "## 批量上传"
},
"typeVersion": 1
},
{
"id": "5c84c01f-7d83-41ce-8792-a104e4014f84",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1920,
448
],
"parameters": {
"width": 384,
"height": 448,
"content": "## 等待"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "a93d427b-07b3-4bce-a077-ee45dbd24d2f",
"connections": {
"Merge": {
"main": [
[
{
"node": "Skip Categories, Loop Transactions",
"type": "main",
"index": 0
}
]
]
},
"Discord": {
"main": [
[]
]
},
"AI Agent1": {
"main": [
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "YNAB modify transactions",
"type": "main",
"index": 0
}
]
]
},
"Variables": {
"main": [
[
{
"node": "Get Categories",
"type": "main",
"index": 0
},
{
"node": "Get Transactions",
"type": "main",
"index": 0
}
]
]
},
"Aggregate1": {
"main": [
[
{
"node": "Discord",
"type": "main",
"index": 0
}
]
]
},
"Get Categories": {
"main": [
[
{
"node": "Get Category Groups",
"type": "main",
"index": 0
}
]
]
},
"Categories Only": {
"main": [
[
{
"node": "Group Categories",
"type": "main",
"index": 0
}
]
]
},
"Get Transactions": {
"main": [
[
{
"node": "Break out Transactions",
"type": "main",
"index": 0
}
]
]
},
"Group Categories": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items1": {
"main": [
[
{
"node": "Aggregate1",
"type": "main",
"index": 0
}
],
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Loop Transactions": {
"main": [
[
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
]
]
},
"Group Transactions": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"OpenAI Chat Model2": {
"ai_languageModel": [
[
{
"node": "AI Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Get Category Groups": {
"main": [
[
{
"node": "Remove Invalid Category Groups",
"type": "main",
"index": 0
}
]
]
},
"Break out Transactions": {
"main": [
[
{
"node": "Filter out transfers and invalid transactions",
"type": "main",
"index": 0
}
]
]
},
"Hide Internal Categories": {
"main": [
[
{
"node": "Categories Only",
"type": "main",
"index": 0
}
]
]
},
"YNAB modify transactions": {
"main": [
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "AI Agent1",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Remove Invalid Category Groups": {
"main": [
[
{
"node": "Flatten Category Groups to Categories",
"type": "main",
"index": 0
}
]
]
},
"Skip Categories, Loop Transactions": {
"main": [
[
{
"node": "Loop Transactions",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Variables",
"type": "main",
"index": 0
}
]
]
},
"Flatten Category Groups to Categories": {
"main": [
[
{
"node": "Hide Internal Categories",
"type": "main",
"index": 0
}
]
]
},
"Filter out transfers and invalid transactions": {
"main": [
[
{
"node": "Group Transactions",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - AI 摘要总结, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
内容生成器 v3
AI驱动博客自动化:使用GPT-4生成并发布SEO文章至WordPress和Twitter
If
Set
Code
+25
144 节点Jay Emp0
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
灵活新闻聚合器 - 多源集成、AI分析和可设置频道
多源新闻策展系统,集成Mistral AI分析、摘要和自定义频道
If
Set
Xml
+32
120 节点Hybroht
内容创作
AIAuto - 带深度研究的终极人机回环内容v2
WordPress博客自动化,集成Airtable界面、人工审核和AI研究v2
If
Set
Xml
+23
228 节点Daniel Ng
内容创作
自动化会议准备
使用 GPT-5 和 Gemini 研究从日历到 Slack 通过 Attio CRM 自动准备会议
If
Set
Code
+16
39 节点Harry Siggins
AI 摘要总结
每日 WhatsApp 群组智能分析:GPT-4.1 分析与语音消息转录
每日 WhatsApp 群组智能分析:GPT-4.1 分析与语音消息转录
If
Set
Code
+20
52 节点Daniel Lianes
杂项