Workflow Results to Markdown Notes in Your Obsidian Vault, via Google Drive
工作流概述
这是一个包含15个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "3wbxkdT6hilhq0Na",
"meta": {
"instanceId": "d47f3738b860eed937a1b18d7345fa2c65cf4b4957554e29477cb064a7039870"
},
"name": "Workflow Results to Markdown Notes in Your Obsidian Vault, via Google Drive",
"tags": [],
"nodes": [
{
"id": "be787ece-4118-4063-98b0-41672dd570c0",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
-480
],
"parameters": {
"width": 440,
"height": 680,
"content": "## Connect folder to Obsidian Vault
**Setup Instructions:**
- Create a folder in your Google Drive that syncs with your desktop.
- Configure the Google Drive node as follows:
- Assign the newly created folder as the parent-folder.
- Specify the filename, appending .md (e.g., `{{ $json.title }}.md`).
- Add Markdown content, including optional YAML Frontmatter, in the File Content field.
- Establish a Symlink between the Google Drive folder and a new folder in your Obsidian Vault."
},
"typeVersion": 1
},
{
"id": "a30f3fdc-95a1-44ff-844a-58353dc7e177",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-800,
-480
],
"parameters": {
"width": 440,
"height": 680,
"content": "## Workflow results to Obsidian Vault
This template automatically creates and updates notes in your Obsidian Vault in real-time from n8n workflow results. Markdown files and attachments saved in Google Drive instantly appear in your Obsidian Vault.
**Send the output of any workflow to the Execute Workflow Trigger beow**"
},
"typeVersion": 1
},
{
"id": "d9527913-dad1-4abc-8c86-8c76f53dd513",
"name": "Save Markdown file",
"type": "n8n-nodes-base.googleDrive",
"position": [
740,
0
],
"parameters": {
"name": "={{ $json.title }}.md",
"content": "=---
{{ $json.frontmatter }}
---
{{ $json.content }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "15dvUtfSjaCCXmnOVeIUfeyRd_raI3PnQ",
"cachedResultUrl": "https://drive.google.com/drive/folders/15dvUtfSjaCCXmnOVeIUfeyRd_raI3PnQ",
"cachedResultName": "clippings-attachments"
},
"operation": "createFromText"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "Vpmg4nRArCy8DHiE",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "6484937e-17fd-444c-916b-1527382927d4",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1020,
-380
],
"parameters": {
"color": 3,
"width": 460,
"height": 540,
"content": "## Create Symlink
Create a symlink to integrate your Google Drive Desktop folder with your Obsidian Vault, ensuring that workflow-generated notes stored in Google Drive instantly appear and update in Obsidian.
- **Open an Administrator Command Prompt:**
Press `Win + S`, type `cmd`, right-click on Command Prompt, and select `Run as Administrator`.
- **Get Folder Paths:**
Identify the source path: This is the existing Google Drive folder you want to link to.
Decide on the target path: This is the folder in your Obsidian Vault where the symlink will be created.
Ensure the Target Path Does Not Already Exist
- **Run the mklink Command:**
Use the following syntax to create a directory symbolic link:
`mklink /D \"Target Path\" \"Source Path\"`
The target path is the location in your Vault where the symlink will be created. The source path is the Google Drive folder.
- **Example Command:**
`mklink /D \"C:\Users\YourName\Vault\OtherFolder\" \"C:\Users\YourName\Google Drive\MyFolder\"`"
},
"typeVersion": 1
},
{
"id": "fe21a7c2-e8db-46be-87e7-63888bf6e9e7",
"name": "Receive results from any workflow",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-660,
0
],
"parameters": {},
"typeVersion": 1
},
{
"id": "8f2399ba-0bda-4a2e-b773-7e28df16e7c2",
"name": "If the input has binary attachment",
"type": "n8n-nodes-base.if",
"position": [
20,
-160
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9f56b367-2313-4a92-9572-b2d2687aba71",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{$json[\"binary\"]}}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "d7cae1d6-5bfe-4e69-8257-0f7947b51c96",
"name": "Write Zettlekasten note from input1",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-280,
240
],
"parameters": {
"text": "={{ JSON.stringify($json) }}",
"options": {
"systemMessage": "You are an expert knowledge management assistant creating a Zettlekasten note from raw input data. Follow these precise steps:
1. Extract key insights and meaningful connections from the provided JSON input.
2. Structure the note using these Zettlekasten principles:
- Create a clear, atomic central idea
- Use precise, concise language
- Link potential connections to other knowledge domains
- Ensure the note can stand alone as a meaningful knowledge unit
3. Note format:
- Unique ID: Generate a unique identifier
- Title: Concise, descriptive headline capturing core insight
- Content: Synthesized information with clear reasoning
- Tags: Relevant conceptual tags for future retrieval
- References: Source of original data (optional)
4. Prioritize intellectual clarity, semantic depth, and potential for future knowledge expansion.
Respond ONLY with the completed Zettlekasten note in JSON format. Do not include any additional commentary or explanation."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.7
},
{
"id": "303d6633-8e98-4fbc-8ee1-9f1075bcaa3e",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-100,
420
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{
\"title\": \"Concise, Descriptive Title\",
\"content\": \"Synthesized insights and key information\"
}"
},
"typeVersion": 1.2
},
{
"id": "62800f09-8659-47b8-9a85-7d3d2c07ec1a",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-300,
420
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "q8L9oWVM7QyzYEE5",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "df11dfcb-fb38-4796-9b28-eb1876f68261",
"name": "Restructure JSON",
"type": "n8n-nodes-base.set",
"position": [
400,
240
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c9061623-d0d0-4b63-a166-4766d88992aa",
"name": "title",
"type": "string",
"value": "={{ $('Write Zettlekasten note from input1').item.json.output.title }}"
},
{
"id": "9f870307-3cbf-41b3-ba69-309610b2d020",
"name": "content",
"type": "string",
"value": "={{ $('Write Zettlekasten note from input1').item.json.output.content }}"
},
{
"id": "1f40b120-00e4-479f-85b0-3fd903e629cb",
"name": "frontmatter",
"type": "string",
"value": "={{ $json.output.frontmatter }}"
},
{
"id": "5b845683-5a25-486b-92b0-98990fcbf7af",
"name": "references",
"type": "string",
"value": "={{ $('Write Zettlekasten note from input1').item.json.output.references }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "2a701cf8-e59d-47ae-83c6-9ac7148bd2c8",
"name": "Structured Output Parser1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
240,
420
],
"parameters": {
"jsonSchemaExample": "{
\"frontmatter\": \"frontmatter here\"
}"
},
"typeVersion": 1.2
},
{
"id": "1e4da42e-e945-4be8-88ac-2579857ff3fa",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
60,
420
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "q8L9oWVM7QyzYEE5",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "af5494d8-a53f-48b1-b939-210c882485be",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-340,
100
],
"parameters": {
"color": 4,
"width": 880,
"height": 460,
"content": "## Optional - Use AI Agents for Note Composition
Instead of directly using JSON parameters for the note's title, YAML frontmatter, and content, you can utilize AI agents to compose these elements. This approach involves inserting the AI-assisted workflow between the webhook and the Google Drive note, instead of the direct connection.
"
},
"typeVersion": 1
},
{
"id": "5d184ea4-88d0-4658-ab94-55246f3507fc",
"name": "Write YAML Frontmatter",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
60,
240
],
"parameters": {
"text": "={{ $json.output.content }}",
"options": {
"systemMessage": "=Generate comprehensive YAML frontmatter for an Obsidian note, focusing on metadata extraction and organization.
Output Format:
```yaml
title: \"{Extract a clear, concise title from input data}\"
date: {{ $now.toFormat('yyyy-MM-dd') }}
tags:
- {Derive 3-4 most relevant conceptual tags}
aliases:
- {Alternative titles or key phrases}
status: \"draft\"
source: \"{Infer original data source if possible}\""
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.7
},
{
"id": "d2b291be-97af-4bcb-8cc6-b21439bdcfb9",
"name": "Save attachment",
"type": "n8n-nodes-base.googleDrive",
"position": [
740,
-180
],
"parameters": {
"name": "=",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "15dvUtfSjaCCXmnOVeIUfeyRd_raI3PnQ",
"cachedResultUrl": "https://drive.google.com/drive/folders/15dvUtfSjaCCXmnOVeIUfeyRd_raI3PnQ",
"cachedResultName": "clippings-attachments"
},
"inputDataFieldName": "=data"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "Vpmg4nRArCy8DHiE",
"name": "Google Drive account"
}
},
"typeVersion": 3
}
],
"active": false,
"pinData": {
"Write Zettlekasten note from input1": [
{
"json": {
"output": {
"id": "note-0235",
"tags": [
"Freelance",
"Employment Trends",
"Media Industry",
"Permanent Contracts"
],
"title": "Shift from Freelancers to Permanent Contracts in Media",
"content": "Recent developments in the media sector indicate a notable trend where freelancers are increasingly being offered permanent contracts, reflecting a shift in employment practices within the industry. This transition aligns with new leadership changes at prominent companies such as WPG Uitgevers and Mybusinessmedia, which may further influence operational dynamics. Additionally, the appointment of Marc Veeningen as the new editor-in-chief of Talpa Networks signifies fresh perspectives in media management, potentially impacting staffing strategies. This trend not only addresses the job security concerns of freelancers but also suggests a recalibration of talent acquisition by media organizations. Such evolutions warrant closer examination of the balance between flexibility and stability in the workforce.",
"references": "Source: https://www.villamedia.nl/artikel/transfer-thursday-freelancers-naar-vast-contract-een-mooie-klus-bij-de-volkskrant-en-een-nieuwe-directeur-bij-wpg"
}
}
}
]
},
"settings": {
"executionOrder": "v1"
},
"versionId": "c87bbecc-453d-4b8c-8b86-dcf7e1d6907b",
"connections": {
"Restructure JSON": {
"main": [
[]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Write Zettlekasten note from input1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Write YAML Frontmatter",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Save Markdown file": {
"main": [
[]
]
},
"Write YAML Frontmatter": {
"main": [
[
{
"node": "Restructure JSON",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Write Zettlekasten note from input1",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "Write YAML Frontmatter",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Receive results from any workflow": {
"main": [
[
{
"node": "If the input has binary attachment",
"type": "main",
"index": 0
},
{
"node": "Save Markdown file",
"type": "main",
"index": 0
}
]
]
},
"If the input has binary attachment": {
"main": [
[
{
"node": "Save attachment",
"type": "main",
"index": 0
}
]
]
},
"Write Zettlekasten note from input1": {
"main": [
[
{
"node": "Write YAML Frontmatter",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Stickynote
- Googledrive
- Executeworkflowtrigger
- If
- @N8N/N8N Nodes Langchain.Agent
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作