Notion to Linkedin
工作流概述
这是一个包含13个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "0pVPSW4PzJZLLqSf",
"meta": {
"instanceId": "8e47d02981c11ba904b56e6bd77877c35ef5c9aa1cdc4076bcb72bbb235efa38"
},
"name": "Notion to Linkedin",
"tags": [],
"nodes": [
{
"id": "d922cf0c-f1c2-40ff-927c-d0d3e2fb7f27",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
2140,
460
],
"parameters": {
"mode": "combine",
"options": {},
"combinationMode": "mergeByPosition"
},
"typeVersion": 2.1
},
{
"id": "8c5f68d8-f11d-4b37-b0d8-3abd1b681b56",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
780,
440
],
"parameters": {
"color": 4,
"height": 141.4092845296238,
"content": "## Start the flow every day at the same time"
},
"typeVersion": 1
},
{
"id": "d10de4f3-6e90-474f-bd68-25aae2037b7b",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1240,
312.5835468325357
],
"parameters": {
"color": 6,
"width": 367.12018536439575,
"height": 382.294335406698,
"content": "## Fetch the day's post from my Notion database"
},
"typeVersion": 1
},
{
"id": "a63bcc85-ec8b-424f-a53c-e4c07db3c7c8",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1642.6949426092506,
313.81962236044654
],
"parameters": {
"color": 6,
"width": 627.4768047417825,
"height": 380.3367219655605,
"content": "## Process and format the post"
},
"typeVersion": 1
},
{
"id": "d7c0f13c-ebbe-4000-bd8f-d1180d65d02a",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
1060,
460
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 15
}
]
}
},
"typeVersion": 1.2
},
{
"id": "7bebcb2d-1642-48ce-a511-bb0f561ca5cf",
"name": "Filter the table for the day's post",
"type": "n8n-nodes-base.notion",
"position": [
1280,
460
],
"parameters": {
"filters": {
"conditions": [
{
"key": "Date|date",
"date": "={{ $today.format(\"yyyy/mM/dd\") }}",
"condition": "equals"
}
]
},
"options": {},
"resource": "databasePage",
"operation": "getAll",
"databaseId": {
"__rl": true,
"mode": "list",
"value": "f09dc21b-1070-4d5a-bf7f-a9ab3dbb69fb",
"cachedResultUrl": "https://www.notion.so/f09dc21b10704d5abf7fa9ab3dbb69fb",
"cachedResultName": "Postagens"
},
"filterType": "manual"
},
"credentials": {
"notionApi": {
"id": "faERNMuBrkAfVaJR",
"name": "Notion Weck"
}
},
"typeVersion": 2.2
},
{
"id": "ee61bc59-164b-45b4-8b49-57cdba7d298b",
"name": "Fetch the content on the page",
"type": "n8n-nodes-base.notion",
"position": [
1480,
460
],
"parameters": {
"blockId": {
"__rl": true,
"mode": "url",
"value": "={{ $json.url }}"
},
"resource": "block",
"operation": "getAll",
"returnAll": true
},
"credentials": {
"notionApi": {
"id": "faERNMuBrkAfVaJR",
"name": "Notion Weck"
}
},
"typeVersion": 2.2
},
{
"id": "52d1ffef-11e8-4635-bbb8-05e915034379",
"name": "Aggregate the Notion blocks",
"type": "n8n-nodes-base.aggregate",
"position": [
1680,
460
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "content"
},
{
"fieldToAggregate": "image.file.url"
}
]
}
},
"typeVersion": 1
},
{
"id": "8617c530-382b-402b-9c0b-aeb4df2bb920",
"name": "Format the post",
"type": "n8n-nodes-base.code",
"position": [
1900,
360
],
"parameters": {
"jsCode": "const notionData = items[0].json.content;
let formattedText = notionData[0]
for (let i = 1; i < notionData.length; i++) {
if (notionData[i].startsWith('-')) {
formattedText += '\n\n' + notionData[i];
} else {
formattedText += '\n' + notionData[i];
}
}
return [{ formattedText: formattedText }];
"
},
"typeVersion": 2
},
{
"id": "0f226cfe-eb31-469a-8e7c-a21192adbd4c",
"name": "Download image",
"type": "n8n-nodes-base.httpRequest",
"position": [
1900,
560
],
"parameters": {
"url": "={{ $json.url[0] }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "81a1e39c-c7ea-4635-84fc-a8ae05cfd8f3",
"name": "Publish on LinkedIn",
"type": "n8n-nodes-base.linkedIn",
"position": [
2360,
460
],
"parameters": {
"text": "={{ $json.formattedText }}",
"person": "CcS-_lLyzG",
"additionalFields": {},
"shareMediaCategory": "IMAGE"
},
"credentials": {
"linkedInOAuth2Api": {
"id": "HZbihVPNwXzWRzgU",
"name": "LinkedIn account"
}
},
"typeVersion": 1
},
{
"id": "61b92eb8-1bf8-4e57-9e07-1a39e457ecfb",
"name": "Update post status in notion database",
"type": "n8n-nodes-base.notion",
"position": [
2620,
460
],
"parameters": {
"pageId": {
"__rl": true,
"mode": "url",
"value": "={{ $('Filter the table for the day\'s post').item.json.url }}"
},
"options": {},
"resource": "databasePage",
"operation": "update",
"propertiesUi": {
"propertyValues": [
{
"key": "Status|select",
"selectValue": "Published"
}
]
}
},
"credentials": {
"notionApi": {
"id": "faERNMuBrkAfVaJR",
"name": "Notion Weck"
}
},
"typeVersion": 2.2
},
{
"id": "397f3772-bb2b-4e58-99f8-2b62cc514b7a",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
760,
120
],
"parameters": {
"color": 3,
"width": 567.6073693795047,
"height": 137.6834217043934,
"content": "## 1. Setup
Set up your Notion and LinkedIn credentials.
Attention to the LinkedIn credential: to post on your personal or company profile, you need to have a company page assigned to your profile. After that, you can choose where you want to post."
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1",
"executionTimeout": 30,
"saveManualExecutions": true
},
"versionId": "d6f51bb9-7320-4984-a009-b0f49073349a",
"connections": {
"Merge": {
"main": [
[
{
"node": "Publish on LinkedIn",
"type": "main",
"index": 0
}
]
]
},
"Download image": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Format the post": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Filter the table for the day's post",
"type": "main",
"index": 0
}
]
]
},
"Publish on LinkedIn": {
"main": [
[
{
"node": "Update post status in notion database",
"type": "main",
"index": 0
}
]
]
},
"Aggregate the Notion blocks": {
"main": [
[
{
"node": "Format the post",
"type": "main",
"index": 0
},
{
"node": "Download image",
"type": "main",
"index": 0
}
]
]
},
"Fetch the content on the page": {
"main": [
[
{
"node": "Aggregate the Notion blocks",
"type": "main",
"index": 0
}
]
]
},
"Filter the table for the day's post": {
"main": [
[
{
"node": "Fetch the content on the page",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Merge
- Stickynote
- Scheduletrigger
- Notion
- Aggregate
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的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错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作