8
n8n 中文网amn8n.com

在 Todoist 中自动创建每日待办事项列表

中级

这是一个Other领域的自动化工作流,包含 13 个节点。主要使用 If, Code, Filter, Todoist, ScheduleTrigger 等节点。 在 Todoist 中自动创建每日待办事项列表

前置要求
  • 无特殊前置要求,导入即可使用

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "id": "d49ee203-5bd1-45c0-859d-f1b248bfdf71",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        40
      ],
      "parameters": {
        "color": 5,
        "width": 424.4907862645661,
        "height": 154.7766688696994,
        "content": "### 👨‍🎤 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "e69dd4e2-7ff6-4613-a1c9-ac1f3da37955",
      "name": "从模板项目获取所有任务",
      "type": "n8n-nodes-base.todoist",
      "position": [
        860,
        420
      ],
      "parameters": {
        "filters": {
          "projectId": "2299363018"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "todoistApi": {
          "id": "1",
          "name": "Todoist account"
        }
      },
      "executeOnce": true,
      "retryOnFail": true,
      "typeVersion": 1
    },
    {
      "id": "fa907d45-3822-4549-9f84-8385bb4183cc",
      "name": "解析任务详情",
      "type": "n8n-nodes-base.code",
      "position": [
        1080,
        420
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const item = {};\n\nitem.description = $input.item.json.description;\nitem.content = $input.item.json.content;\n\nconst parts = item.description.split(';').map((v) => v.trim());\nparts.forEach((v) => {\n  const tag = v.split(':');\n  if (tag && tag.length === 2) {\n    item[tag[0]] = tag[1].trim();\n  }\n});\n\nif (item.due) {\n  item.due = parseTimeString(item.due);\n}\n\nreturn item;\n\nfunction parseTimeString(timeString) {\n    const regex = /^(\\d{1,2})(\\.)?(\\d{2})?([ap]m)$/i;\n    const match = timeString.match(regex);\n    \n    if (!match) {\n        throw new Error(\"Invalid time format\");\n    }\n\n    let hours = parseInt(match[1], 10);\n    let minutes = match[3] ? parseInt(match[3], 10) : 0;\n    const period = match[4].toLowerCase();\n\n    if (hours === 12) {\n        hours = period === 'am' ? 0 : 12;\n    } else {\n        hours = period === 'pm' ? hours + 12 : hours;\n    }\n\n    // Check if minutes are valid\n    if (minutes < 0 || minutes >= 60) {\n        throw new Error(\"Invalid minutes\");\n    }\n\n    const now = DateTime.now().set({ hour: hours, minute: minutes, second: 0, millisecond: 0 });\n    return now.toUTC();\n}\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4989bac6-0741-4cdc-bc9c-e7800f9b3019",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        600
      ],
      "parameters": {
        "color": 7,
        "width": 351.4230769230764,
        "height": 222.50000000000006,
        "content": "### 👆 这会将到期日期从描述添加到任务中.."
      },
      "typeVersion": 1
    },
    {
      "id": "accc330b-1b67-4181-8735-94b0debc8d70",
      "name": "保留匹配今天的任务",
      "type": "n8n-nodes-base.filter",
      "position": [
        1300,
        420
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.days }}",
              "value2": "={{ ['sun', 'mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun'][new Date().getDay()] }}",
              "operation": "contains"
            },
            {
              "value1": "={{ $json.days }}",
              "value2": "={{ ['sun', 'mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun'][new Date().getDay()] }}",
              "operation": "contains"
            }
          ]
        },
        "combineConditions": "OR"
      },
      "typeVersion": 1
    },
    {
      "id": "dbe1fc24-1833-493b-b444-de21a4b3c3c5",
      "name": "每天凌晨 5:10",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        620,
        420
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 5,
              "triggerAtMinute": 10
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b4737822-89aa-4ca0-bd9b-c5f9a16360c0",
      "name": "每天凌晨 5 点",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        400,
        220
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 5,
              "triggerAtMinute": 10
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "2a9adc4b-552b-47a9-a32c-54d8d4bfb669",
      "name": "从收件箱获取所有任务",
      "type": "n8n-nodes-base.todoist",
      "position": [
        620,
        220
      ],
      "parameters": {
        "filters": {
          "projectId": "938017196"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "todoistApi": {
          "id": "1",
          "name": "Todoist account"
        }
      },
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "d4794543-3002-4663-8979-360eb437fb4e",
      "name": "如果列表不为空",
      "type": "n8n-nodes-base.if",
      "position": [
        840,
        220
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"id\"] }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "297fcbcb-efe3-4965-b836-34e78a3b452d",
      "name": "如果它有每日标签",
      "type": "n8n-nodes-base.if",
      "position": [
        1080,
        220
      ],
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ ($json[\"labels\"] || []).includes('daily') }}",
              "value2": true
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0365a865-f03b-4afc-a535-4e3892fc3add",
      "name": "删除任务",
      "type": "n8n-nodes-base.todoist",
      "position": [
        1280,
        220
      ],
      "parameters": {
        "taskId": "={{ $json[\"id\"] }}",
        "operation": "delete"
      },
      "credentials": {
        "todoistApi": {
          "id": "1",
          "name": "Todoist account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1
    },
    {
      "id": "b14a8ecc-ee07-4a33-ab4b-122c98694c60",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1740,
        440
      ],
      "parameters": {
        "color": 7,
        "width": 256.14371825927645,
        "height": 100,
        "content": "### 👈🏽 每个新任务都有 `daily` 标签,该标签在其他流程中被删除"
      },
      "typeVersion": 1
    },
    {
      "id": "d951f461-685e-4507-b010-bce2be0e3709",
      "name": "在收件箱中创建新任务",
      "type": "n8n-nodes-base.todoist",
      "position": [
        1520,
        420
      ],
      "parameters": {
        "labels": [
          "daily"
        ],
        "content": "={{ $json.content }}",
        "options": {
          "description": "={{ $json.description }}",
          "dueDateTime": "={{ $json.due }}"
        },
        "project": {
          "__rl": true,
          "mode": "list",
          "value": "938017196",
          "cachedResultName": "Inbox"
        }
      },
      "credentials": {
        "todoistApi": {
          "id": "1",
          "name": "Todoist account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 2,
      "alwaysOutputData": false
    }
  ],
  "pinData": {},
  "connections": {
    "Every day at 5am": {
      "main": [
        [
          {
            "node": "Get all tasks from Inbox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If list not empty": {
      "main": [
        [
          {
            "node": "if it has daily label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse task details": {
      "main": [
        [
          {
            "node": "Keep tasks that match today",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every day at 5:10am": {
      "main": [
        [
          {
            "node": "Get all tasks from template project",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if it has daily label": {
      "main": [
        [
          {
            "node": "Delete task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all tasks from Inbox": {
      "main": [
        [
          {
            "node": "If list not empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep tasks that match today": {
      "main": [
        [
          {
            "node": "Create new task in Inbox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all tasks from template project": {
      "main": [
        [
          {
            "node": "Parse task details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 其他

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量13
分类1
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
外部链接
在 n8n.io 查看

分享此工作流