Linear Project Status and End Date to Productboard feature Sync
工作流概述
这是一个包含17个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"meta": {
"instanceId": "21b41c2deb1c9e3f543253a0aa6a6e2c7bd7ef6bab90ffd478aa947c17d3b352",
"templateCredsSetupCompleted": true
},
"name": "Linear Project Status and End Date to Productboard feature Sync",
"tags": [
{
"id": "6Ek7V8f4xbM9vWLj",
"name": "linear",
"createdAt": "2024-11-08T12:12:15.330Z",
"updatedAt": "2024-11-08T12:12:15.330Z"
},
{
"id": "XpcIJ8IHNenz3bWz",
"name": "productboard",
"createdAt": "2024-11-08T12:12:17.249Z",
"updatedAt": "2024-11-08T12:12:17.249Z"
}
],
"nodes": [
{
"id": "5cf79e5e-6a69-49b5-865f-6ca8009dbf75",
"name": "linear project id",
"type": "n8n-nodes-base.set",
"position": [
3180,
220
],
"parameters": {
"fields": {
"values": [
{
"name": "linear_project_url",
"stringValue": "={{ $json.url }}"
},
{
"name": "linear_project_id",
"stringValue": "={{ $json.url.split('https://linear.app/<your company>/project/')[1] }}"
},
{
"name": "linear_project_status",
"stringValue": "={{ $json.data.status.name }}"
},
{
"name": "startDate",
"stringValue": "={{ $json.data.startDate }}"
},
{
"name": "targetDate",
"stringValue": "={{ $json.data.targetDate }}"
}
]
},
"include": "none",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "642e73fc-8904-4631-9e97-1ccff6dbb559",
"name": "get productboard feature id",
"type": "n8n-nodes-base.httpRequest",
"position": [
3180,
400
],
"parameters": {
"url": "https://api.productboard.com/hierarchy-entities/custom-fields-values",
"options": {},
"sendQuery": true,
"sendHeaders": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"queryParameters": {
"parameters": [
{
"name": "customField.id",
"value": "<productboard_customfield_uuid>"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "X-Version",
"value": "1"
}
]
}
},
"stickyNote": "Fetches the Productboard feature ID using a custom field value.",
"credentials": {
"httpHeaderAuth": {
"id": "Z0ptr85smbBZBIYx",
"name": "Product Board"
}
},
"notesInFlow": false,
"typeVersion": 4.1
},
{
"id": "3c328300-ff68-4958-8ac3-5b8fca122bbd",
"name": "update productboard status & timeframe",
"type": "n8n-nodes-base.httpRequest",
"position": [
5560,
380
],
"parameters": {
"url": "=https://api.productboard.com/features/{{ $json.feature_id }}",
"method": "PATCH",
"options": {
"batching": {
"batch": {
"batchSize": 1,
"batchInterval": 2000
}
}
},
"jsonBody": "={
\"data\": {
\"status\": {
\"name\": \"{{ $json[\"productboard_status\"] }}\"
},
\"timeframe\": {
{{ $json[\"targetDate\"] ? '\"granularity\": \"month\",': '\"granularity\": \"none\",'}}
{{ $json[\"targetDate\"] ? '\"startDate\": \"' + $json['targetDate'].substring(0, 7) + '-01' +'\",': '\"startDate\": \"none\",'}}
{{ $json[\"targetDate\"]
? (() => {
const date = new Date($json['targetDate']);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const lastDay = new Date(year, month, 0).getDate();
return `\"endDate\": \"${year}-${month.toString().padStart(2, '0')}-${lastDay}\"`;
})()
: '\"endDate\": \"none\"'}}
}
}
}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "X-Version",
"value": "1"
},
{
"name": "accept",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "Z0ptr85smbBZBIYx",
"name": "Product Board"
}
},
"typeVersion": 4.1
},
{
"id": "ec57bdeb-413b-4f71-b8c4-82b966fd4caf",
"name": "map linear to productboard status",
"type": "n8n-nodes-base.set",
"position": [
4300,
280
],
"parameters": {
"fields": {
"values": [
{
"name": "linear_status",
"stringValue": "={{ $json.linear_project_status }}"
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "052dcbb4-c113-4e1a-8469-e460a9bfefaf",
"name": "mapping",
"type": "n8n-nodes-base.code",
"position": [
4560,
280
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const linearStatus = $json.linear_status;
let productboardStatus;
switch(linearStatus) {
case 'Backlog':
productboardStatus = 'Candidate';
break;
case 'Planned':
productboardStatus = 'Planned';
break;
case 'Paused':
productboardStatus = 'Planned';
break;
case 'In Progress':
productboardStatus = 'In progress';
break;
case 'Completed':
productboardStatus = 'Released';
break;
case 'Canceled':
productboardStatus = 'Won\'t do';
break;
default:
productboardStatus = 'Candidate'; // Default or handle unknown status
}
return { productboard_status: productboardStatus };
"
},
"typeVersion": 2
},
{
"id": "4fee2a41-4e20-4642-badd-164c6d0b1232",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
4780,
300
],
"parameters": {
"mode": "combine",
"options": {},
"combinationMode": "mergeByPosition"
},
"typeVersion": 2.1
},
{
"id": "49289417-ca21-4b03-b558-61a04b6eb7dd",
"name": "Split Out",
"type": "n8n-nodes-base.splitOut",
"position": [
3400,
400
],
"parameters": {
"options": {},
"fieldToSplitOut": "data"
},
"typeVersion": 1
},
{
"id": "b89135b5-3c72-44a9-9d8e-b0190385cf65",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"position": [
3920,
280
],
"parameters": {
"mode": "combine",
"options": {},
"mergeByFields": {
"values": [
{
"field1": "linear_project_url",
"field2": "linear_url_productboard"
}
]
}
},
"typeVersion": 2.1
},
{
"id": "cf533225-7507-471e-9d45-4a490b30a01d",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"position": [
3740,
400
],
"parameters": {
"fields": {
"values": [
{
"name": "linear_url_productboard",
"stringValue": "={{ $json['value'].match('^(https:\/\/linear\.app\/[^\/]+\/project\/[^\/]+)')[0] }}"
},
{
"name": "feature_id",
"stringValue": "={{ $json['hierarchyEntity'].id }}"
}
]
},
"include": "none",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "ee7f8ef5-f5a9-4a39-9621-ccf908036eeb",
"name": "Slack",
"type": "n8n-nodes-base.slack",
"position": [
5820,
380
],
"parameters": {
"text": "=:linear: {{ $json.data.name }} with status {{ $json.data.status.name }} and dates {{ $json.data.timeframe.startDate }} - {{ $json.data.timeframe.endDate }} updated :productboard: {{ $json.data.links.html }}.",
"select": "channel",
"blocksUi": "={
\"blocks\": [
{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \":linear: to :productboard: update\n\n*{{ $json.data.name }}*\n\n*Status:* {{ $json.data.status.name }}\n*:dart: date:* {{ $json[\"data\"][\"timeframe\"][\"endDate\"] && $json[\"data\"][\"timeframe\"][\"endDate\"] !== \"none\" ? new Date($json[\"data\"][\"timeframe\"][\"endDate\"]).toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" }) : \"none\" }}\"
}
},
{
\"type\": \"divider\"
},
{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \"You can view the update in Productboard using the link below:\"
},
\"accessory\": {
\"type\": \"button\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"Open Productboard\"
},
\"url\": \"{{ $json.data.links.html }}\"
}
}
]
}
",
"channelId": {
"__rl": true,
"mode": "name",
"value": "#product-notifications"
},
"messageType": "block",
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "SG3oDwwLGpxwoJSO",
"name": "Slack"
}
},
"typeVersion": 2.1
},
{
"id": "4ab5c298-5947-47d1-ac10-db502a0b4b60",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
5280,
400
],
"parameters": {
"options": {
"looseTypeValidation": true
},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "or",
"conditions": [
{
"id": "f53c6eb9-61cc-4cf9-bbb6-03cc9f78b6b1",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.productboard_status }}",
"rightValue": "={{ $json.data.status.name }}"
},
{
"id": "a61b4bca-47b0-48bb-b93f-ba9a419740d0",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json[\"targetDate\"]
? (() => {
const date = new Date($json['targetDate']);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const lastDay = new Date(year, month, 0).getDate();
return `${year}-${month.toString().padStart(2, '0')}-${lastDay}`;
})()
: '\"endDate\": \"none\"'}}",
"rightValue": "={{ $json.data.timeframe.endDate }}"
}
]
}
},
"typeVersion": 2
},
{
"id": "3efe9d27-7983-419d-8ac1-9efde3751952",
"name": "get productboard feature details",
"type": "n8n-nodes-base.httpRequest",
"position": [
4300,
540
],
"parameters": {
"url": "=https://api.productboard.com/features/{{ $json.feature_id }}",
"options": {},
"sendHeaders": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "X-Version",
"value": "1"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "Z0ptr85smbBZBIYx",
"name": "Product Board"
}
},
"typeVersion": 4.1
},
{
"id": "265b3359-c63d-4188-ad1b-a33ce5e081f5",
"name": "Merge2",
"type": "n8n-nodes-base.merge",
"position": [
5040,
400
],
"parameters": {
"mode": "combine",
"options": {},
"joinMode": "keepEverything",
"mergeByFields": {
"values": [
{
"field1": "feature_id",
"field2": "data.id"
}
]
}
},
"typeVersion": 2.1
},
{
"id": "5dc1c2f5-a92d-49f4-acb9-8084bf878b05",
"name": "Your Linear Project 2",
"type": "n8n-nodes-base.linearTrigger",
"position": [
2840,
260
],
"webhookId": "180ebe54-3ab2-439f-b44b-40be97a62b87",
"parameters": {
"teamId": "8434c5f8-1ce0-4733-949d-ef6a095c27fd",
"resources": [
"project"
]
},
"credentials": {
"linearApi": {
"id": "hhmsOxH2jUEvGbvN",
"name": "Linear"
}
},
"typeVersion": 1
},
{
"id": "6f70d103-cf98-4ab8-9550-a5749a40f7e3",
"name": "Your Linear Project 1",
"type": "n8n-nodes-base.linearTrigger",
"position": [
2840,
60
],
"webhookId": "5b10cdb4-85a6-41de-a0de-ce50c75dcc6f",
"parameters": {
"teamId": "e7c75e79-fbcf-45cc-95bd-110efb6cb555",
"resources": [
"project"
]
},
"credentials": {
"linearApi": {
"id": "hhmsOxH2jUEvGbvN",
"name": "Linear"
}
},
"typeVersion": 1
},
{
"id": "65abdb10-dba2-4535-a155-957106ae6cdd",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
2960,
680
],
"parameters": {
"width": 487.89456119016046,
"height": 156.00544089827184,
"content": "## Tips
- Avoid copying and pasting the Linear node; instead, add a new one from the menu.
- Remember to configure the custom Productboard field in the \"Get Productboard Feature ID\" node."
},
"typeVersion": 1
},
{
"id": "adcb71e4-880b-4c19-acbb-0708ae4af95f",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
5500,
620
],
"parameters": {
"color": 5,
"width": 492.6340257353018,
"height": 182.8624066540728,
"content": "## Preview Slack Message
:linear: to :productboard: update
My awesome feature name
Status: Candidate
:dart: date: Decembre 2024
You can view the update in Productboard using the link below:
<link productboard feature>"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "",
"connections": {
"If": {
"main": [
[
{
"node": "update productboard status & timeframe",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Merge2",
"type": "main",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "map linear to productboard status",
"type": "main",
"index": 0
},
{
"node": "get productboard feature details",
"type": "main",
"index": 0
}
]
]
},
"Merge2": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"mapping": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"linear project id": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"Your Linear Project 1": {
"main": [
[
{
"node": "get productboard feature id",
"type": "main",
"index": 0
},
{
"node": "linear project id",
"type": "main",
"index": 0
}
]
]
},
"Your Linear Project 2": {
"main": [
[
{
"node": "linear project id",
"type": "main",
"index": 0
},
{
"node": "get productboard feature id",
"type": "main",
"index": 0
}
]
]
},
"get productboard feature id": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"get productboard feature details": {
"main": [
[
{
"node": "Merge2",
"type": "main",
"index": 1
}
]
]
},
"map linear to productboard status": {
"main": [
[
{
"node": "mapping",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"update productboard status & timeframe": {
"main": [
[
{
"node": "Slack",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Set
- Httprequest
- Code
- Merge
- Splitout
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的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错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作