8
n8n 中文网amn8n.com

集成 Notion 的 AI Telegram 任务助手

高级

这是一个自动化工作流,包含 23 个节点。主要使用 Set, Code, Notion, Switch, Telegram 等节点。 基于 Notion 集成的 AI Telegram 任务助手系统

前置要求
  • Notion API Key
  • Telegram Bot Token
  • OpenAI API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "luA3Pf8ljBmGGnnS",
  "meta": {
    "instanceId": "2fa7acc0cd134988fb8b40b8d8b56c9f29ee37789503fef505450e2733dc2bdf",
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "nodes": [
    {
      "id": "a0047d28-4079-4cde-aa32-5e5680ffa0e1",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1180,
        -360
      ],
      "webhookId": "f99f603b-1518-4578-8126-03cb6e820f8d",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "ar7qqwMS6eFB8SaY",
          "name": "NyroSikAIbot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c3b1e3d7-5bf0-4458-9097-e289a5b5929e",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        380,
        -360
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "e4956c2a-640a-4765-a9a6-56afd768d1e5",
      "name": "设置文本",
      "type": "n8n-nodes-base.set",
      "position": [
        -240,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8f2c8e61-be03-44bc-bea9-5cfa0bd8fda8",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "eb4ada6f-0838-4b05-8e57-400d834d7d22",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        360,
        -140
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "3ff0w5x5tfolokJ7",
          "name": "OpenAi account mingles new dev user"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d9dfe7db-df80-416f-9539-aa2a40c3cb4a",
      "name": "转录",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -80,
        -460
      ],
      "webhookId": "76702463-9851-4712-bd47-c71e3ed8e9a5",
      "parameters": {
        "text": "=#Transribation:\n\n{{ $json.text }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false,
          "disable_notification": true
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "ar7qqwMS6eFB8SaY",
          "name": "NyroSikAIbot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "05eae3da-b8bf-4104-ac25-cd987d888752",
      "name": "转录",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -300,
        -460
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "id": "3ff0w5x5tfolokJ7",
          "name": "OpenAi account mingles new dev user"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "c0d929c4-46fc-4608-8ab2-d76d97bd4a06",
      "name": "当由另一个工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -960,
        720
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "method"
            },
            {
              "name": "task_name"
            },
            {
              "name": "when"
            },
            {
              "name": "task_id"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b952b40c-61ab-4de7-b269-9ef807e47223",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1180,
        520
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "975befd9-e395-456e-b8d7-956e8ba5a894",
      "name": "设置",
      "type": "n8n-nodes-base.set",
      "position": [
        -740,
        620
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "550aca70-519d-4e5a-a303-7c59375a3d58",
              "name": "NOTION_DATABASE_ID",
              "type": "string",
              "value": "1f30e2a31ff0808c9c64ea31b24e1bba"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "91d129a0-bced-48dc-86ae-3301754f01fb",
      "name": "添加任务",
      "type": "n8n-nodes-base.notion",
      "position": [
        -300,
        520
      ],
      "parameters": {
        "title": "={{ $json.task_name }}",
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('SETUP').item.json.NOTION_DATABASE_ID }}"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "When|select",
              "selectValue": "={{ $json.when }}"
            },
            {
              "key": "Checkbox|checkbox"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "wB66m7r00NyUEmmc",
          "name": "Notion tasks"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c0c1d8eb-e2ae-4919-9618-1060b1d866ab",
      "name": "获取任务",
      "type": "n8n-nodes-base.notion",
      "position": [
        -300,
        320
      ],
      "parameters": {
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "returnAll": true,
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.NOTION_DATABASE_ID }}"
        }
      },
      "credentials": {
        "notionApi": {
          "id": "wB66m7r00NyUEmmc",
          "name": "Notion tasks"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "fc539220-0007-4154-8ba1-3a44410d1dc2",
      "name": "完成任务",
      "type": "n8n-nodes-base.notion",
      "position": [
        -300,
        720
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.task_id }}"
        },
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Checkbox|checkbox",
              "checkboxValue": "={{ $json.method === \"complete_task\" }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "wB66m7r00NyUEmmc",
          "name": "Notion tasks"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8fab5419-bba3-46a4-9291-ac8e6321707f",
      "name": "选择方法",
      "type": "n8n-nodes-base.switch",
      "position": [
        -520,
        578
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "list_tasks",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "baae5547-5856-44ac-a492-16cf17178d48",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.method }}",
                    "rightValue": "list_tasks"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "add_task",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fc7806f9-36f6-4e6d-9cca-115a24010c29",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.method }}",
                    "rightValue": "add_task"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "complete_task",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "66b4bf74-ba91-4461-82e6-304f4e8c40b8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.method }}",
                    "rightValue": "complete_task"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "uncomplete_task",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f14621d5-67ea-42d0-9684-33630e81b183",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.method }}",
                    "rightValue": "uncomplete_task"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "set_task_time",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "38cce21f-417f-4de8-93a0-e9e0f37a2d6e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.method }}",
                    "rightValue": "set_task_time"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "47e494d8-a3db-48c5-ad88-d208f4bac1a3",
      "name": "设置任务时间",
      "type": "n8n-nodes-base.notion",
      "position": [
        -300,
        920
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.task_id }}"
        },
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "When|select",
              "selectValue": "={{ $json.when }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "wB66m7r00NyUEmmc",
          "name": "Notion tasks"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0739dc69-77f0-40c2-aa2b-55506913e4da",
      "name": "响应",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        620
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Processing a single item\nconst task = $json;\nconst taskName = task.properties.Task?.title?.[0]?.text?.content || \"Untitled\";\nconst when = task.properties.When?.select?.name || \"later\";\nconst completed = task.properties.Checkbox?.checkbox || false;\n\n// Create status and emoji indicators\nconst status = completed ? \"✅ \" : \"⬜ \";\nconst whenEmoji = when.toLowerCase() === \"today\" ? \"🔴 \" : \"⚪ \";\n\n// Return Resource object\nreturn {\n  id: task.id,\n  uri: `notion://task/${task.id}`,\n  name: `${status}${whenEmoji}${taskName}`,\n  description: `When: ${when}, Completed: ${completed}`\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "0efa85a4-4ae4-4ef9-9b18-9e35feb6cf17",
      "name": "Notion 任务管理器工具",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        600,
        -140
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "luA3Pf8ljBmGGnnS",
          "cachedResultName": "NyroSikAIbot"
        },
        "description": "工具:Notion 任务管理器",
        "workflowInputs": {
          "value": {
            "when": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('when', ``, 'string') }}",
            "method": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('method', ``, 'string') }}",
            "task_id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('task_id', ``, 'string') }}",
            "task_name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('task_name', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "task_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "task_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "when",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "when",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "task_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "task_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2cf0f70f-fa36-486e-809a-a4ae6fe11377",
      "name": "语音或文本消息",
      "type": "n8n-nodes-base.switch",
      "position": [
        -740,
        -360
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "aeb8ee22-965f-4095-a8cb-1813972f7e74",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3193d0d1-8ff9-41c3-9fcd-de8b23dd9834",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "e9aab24f-0859-434b-8986-ce189ebd307d",
      "name": "下载语音文件",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -520,
        -460
      ],
      "webhookId": "345cb50c-ec2b-41db-be96-f07303fa5f33",
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "ar7qqwMS6eFB8SaY",
          "name": "NyroSikAIbot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "96e36864-d6c3-4baf-b89e-9dff5a3f77fa",
      "name": "响应用户",
      "type": "n8n-nodes-base.telegram",
      "position": [
        800,
        -360
      ],
      "webhookId": "76702463-9851-4712-bd47-c71e3ed8e9a5",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "ar7qqwMS6eFB8SaY",
          "name": "NyroSikAIbot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b51fb7c1-cb5a-43c0-bd6f-a28ca73756b8",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        480,
        -140
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "ccc7841a-8a29-4237-8ba4-3c65601a5ba1",
      "name": "设置文本1",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        -460
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8f2c8e61-be03-44bc-bea9-5cfa0bd8fda8",
              "name": "text",
              "type": "string",
              "value": "={{ $('Transcribe').item.json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1ea7deec-c934-4246-a8d7-6fdb4f2ea7f8",
      "name": "调试输入",
      "type": "n8n-nodes-base.set",
      "position": [
        -960,
        520
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"task_name\": \"value\",\n  \"when\": \"later\",\n  \"task_id\": \"1f30e2a3-1ff0-819f-b1e3-cbfec8873943\",\n  \"method\": \"complete_task\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "e6c26de9-2aa8-4222-b6f5-92d895698fc7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        200
      ],
      "parameters": {
        "color": 4,
        "width": 1460,
        "height": 940,
        "content": "## Notion 任务管理器工具"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f6705a90-3a36-4e07-9a8c-2ff6efd77ebc",
  "connections": {
    "SETUP": {
      "main": [
        [
          {
            "node": "Choose Method",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Response user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Task": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set text": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Tasks": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set text1": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe": {
      "main": [
        [
          {
            "node": "Transribation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Choose Method": {
      "main": [
        [
          {
            "node": "Get Tasks",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Task",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Complete Task",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Complete Task",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Task Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Complete Task": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Task Time": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Transribation": {
      "main": [
        [
          {
            "node": "Set text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Voice or Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Input for debuging": {
      "main": [
        [
          {
            "node": "SETUP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Voice File": {
      "main": [
        [
          {
            "node": "Transcribe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Voice or Text Message": {
      "main": [
        [
          {
            "node": "Download Voice File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion Tasks Manager Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "SETUP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Input for debuging",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级

需要付费吗?

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

工作流信息
难度等级
高级
节点数量23
分类-
节点类型14
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流