{
  "id": "wtKqVmCe49QAo6vt",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Planner (LinkedIn)",
  "tags": [],
  "nodes": [
    {
      "id": "e370e284-f06e-482b-ae7f-3d10019f4a58",
      "name": "Receive Telegram Messages",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        48,
        144
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "47c0a6c6-f78f-4188-8315-4f7d898bd5fc",
      "name": "Voice or Text?",
      "type": "n8n-nodes-base.switch",
      "position": [
        240,
        128
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "af30c479-4542-405f-b315-37c50c4e2bef",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a3ca8cd4-fbb2-40b5-829a-24724f2fbc85",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text || \"\" }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Error",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9bcfdee0-2f09-4037-a7b9-689ef392371d",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "error",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "bd65c98e-46ed-44bb-a6ad-2683e9ba2030",
      "name": "Fetch Voice Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        560,
        112
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f3a78105-8324-4839-b6bb-7c5aae425e34",
      "name": "Transcribe Voice to Text",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        768,
        112
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "translate"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "f75e8f3c-e61d-43df-8969-978f7d1b5ab4",
      "name": "Prepare for LLM",
      "type": "n8n-nodes-base.set",
      "position": [
        560,
        288
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b324a329-3c49-4f7f-b683-74331b7fe7f8",
              "name": "=text",
              "type": "string",
              "value": "={{$json.message.text}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fac183f6-26ee-4f3e-88b2-071f0a38671a",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2928,
        -144
      ],
      "parameters": {
        "text": "=Task Link :{{ $json.url }}",
        "chatId": "={{ $('Receive Telegram Messages').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8cd17bb-e7a7-44b6-ab3d-a9b267e2ecbe",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        16
      ],
      "parameters": {
        "width": 1196,
        "height": 484,
        "content": " **Get Telegram Message**  "
      },
      "typeVersion": 1
    },
    {
      "id": "634ce7e4-c996-4bdd-8cf4-37f7849d8ba5",
      "name": "Detect Intent",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1312,
        192
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=You are a classification assistant that analyzes a user's natural-language message and determines their intent related to tasks.\n\nYou must choose only one of the following intents:\n\ncreate \u2192 the user wants to add a new task\n\nupdate \u2192 the user wants to change, fix, or improve an existing task\n\nanalyze \u2192 the user is asking for insights, feedback, evaluation, or reflection based on existing tasks (e.g., workload, productivity, effectiveness, goals)\n\nThe user message may be unclear, indirect, or informal. Think carefully and infer intent if needed.\n\nRespond with only one word: create, update, or analyze. No punctuation. No explanation.\n\nExamples:\n\n\"Create a task to prepare slides by Friday\" \u2192 create\n\n\"Update the grocery task to include milk\" \u2192 update\n\n\"What does my task list say about my priorities today?\" \u2192 analyze\n\n\"Am I too busy tomorrow?\" \u2192 analyze\n\n\"Fix the title of the morning meeting task\" \u2192 update\n\n\"Add a task to write birthday letter\" \u2192 create\n\n\"Do my tasks this week help me reach my goal?\" \u2192 analyze\n\n\"My schedule is a mess\" \u2192 analyze\n\n\"I want to change that annoying deadline\" \u2192 update\n\n\"Don't forget to call the dentist\" \u2192 create\n\n\"Move the research task to next week\" \u2192 update\n\n\"Add: Buy winter shoes\" \u2192 create\n\n\"Is next week too full?\" \u2192 analyze"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "2f9456d5-cae5-432d-9324-40a36f085fdc",
      "name": "Wrap Intent",
      "type": "n8n-nodes-base.set",
      "position": [
        1584,
        192
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"intent\": \"{{ $json.text }}\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "31c3417f-ef35-4525-af3e-33eb61df2cfa",
      "name": "Prepare Unified Text",
      "type": "n8n-nodes-base.set",
      "position": [
        1040,
        192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a91f8b36-f7b5-4cd3-81cf-f42d5a98152c",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "72d1f0dc-39bc-434d-b229-9f6eaa3a1c18",
      "name": "Route by Intent",
      "type": "n8n-nodes-base.switch",
      "position": [
        1936,
        176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "35719492-2ca4-4d67-8bfc-225f68cd3fd7",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.intent}}",
                    "rightValue": "create"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d1af2fb7-bb6f-412f-b886-42a0d16915a0",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.intent}}",
                    "rightValue": "update"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a198158d-2b3b-4f9d-af67-4f38d6f5f281",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.intent}}",
                    "rightValue": "analyze"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "4d6fbc0d-c537-46e9-aabb-91e9945f5923",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        16
      ],
      "parameters": {
        "width": 860,
        "height": 484,
        "content": " **Add Intent (create, update, analyze)**  "
      },
      "typeVersion": 1
    },
    {
      "id": "bef334e7-bab9-48b8-944a-315568364289",
      "name": "Extract Create Task Fields",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2608,
        64
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"title\": \"Call Anna about the report\",\n  \"priority\": \"High\",\n  \"description\": \"optional detail\",\n  \"due_date\": \"2025-08-26 08:00\",\n  \"tags\": [\"work\", \"important\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "41816606-bb23-4083-af02-29a23b79096d",
      "name": "Wrap Intent + Text",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        192
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      intent: $items(\"Detect Intent\")[0].json.text,\n      text: $items(\"Prepare Unified Text\")[0].json.text\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "0b11032b-a1d1-49c3-aefd-bf74ca9a20be",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2352,
        -224
      ],
      "parameters": {
        "width": 828,
        "height": 452,
        "content": " **Create Task**  "
      },
      "typeVersion": 1
    },
    {
      "id": "47c13987-833b-48ea-bcef-6161f014fa13",
      "name": "Update Task Prompt",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        3568,
        352
      ],
      "parameters": {
        "text": "=User message:\n{{ $json.text }}\n\nOriginal task:\n{{ JSON.stringify($json.task, null, 2) }}\n",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are an assistant helping to update a task.\n\nYou\u2019ll receive:\n\nThe user's message describing what to change\n\nThe original task JSON from Todoist\n\nYour job is to return a new version of the task JSON that includes the requested changes (e.g. new content, updated priority, deadline, etc.).\n\n\ud83d\udd39 If the user mentions a list (e.g. items to buy or do), format those items as bullet points in the content field using newline-separated dashes (- item).\n\n\ud83d\udd39 Keep all unchanged fields as-is unless the user asked to modify them.\n\n\ud83d\udd39 Do not add explanations, comments, or extra keys.\n\n\ud83d\udd39 Return only the updated JSON object of the task.\n\nExample Input:\n\nUser: \"Change the task to include 'buy milk, water, and bread' and set it to high priority\"\n\nOriginal Task:\n{\n  \"id\": 123,\n  \"content\": \"Go to the shop\",\n  \"priority\": 2\n}\n\nOutput:\n{\n  \"id\": 123,\n  \"content\": \"Go to the shop\\n- milk\\n- water\\n- bread\",\n  \"priority\": 4\n}"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "bc306d2b-591d-43d7-a63b-1b8e0b8c8f6e",
      "name": "Find Matching Task",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        3072,
        352
      ],
      "parameters": {
        "text": "=Search string:\n{{ $json.search_string }}\n\nAvailable tasks:\n{{ JSON.stringify($json.tasks, null, 2) }}\n",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are an assistant that finds the most relevant task from a given list.\n\nYou will be given:\n- A list of tasks in JSON format (each with content, id, and other fields)\n- A search string (from the user)\n\nYour job is to return only the ONE best-matching task as valid JSON \u2014 exactly the original task object.\n\nDo not return explanations or wrap it in text. Do not modify the task. Just return the raw JSON object that best matches the search string.\n"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "0f9074e7-cbcd-4fcd-9781-1a182fe25e0b",
      "name": "Prepare Match Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        2896,
        352
      ],
      "parameters": {
        "jsCode": "const searchString = $items('Get Search String')[0].json.text;\nconst tasks = $items('Get Notion Tasks (update)').map(item => item.json);\n\nreturn [\n  {\n    json: {\n      search_string: searchString,\n      tasks: tasks\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a5f243be-9d47-4167-9177-3a99b758837b",
      "name": "Get Search String",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2400,
        352
      ],
      "parameters": {
        "text": "={{$json.text}}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You receive a user's message about updating a task. Your job is to extract only the fuzzy match string that can be used to identify the task to update.\n\nReturn a single string. Do not return JSON.\n\nExamples:\n\nInput: \"Update the grocery task to include bread\"\nOutput: grocery\n\nInput: \"Change the bug fixing task to high priority\"\nOutput: bug fixing\n"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "d979fad4-b32c-4f80-8f36-0530b7ececd1",
      "name": "Prepare Update Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        3392,
        352
      ],
      "parameters": {
        "jsCode": "const userMessage = $items('Wrap Intent + Text')[0].json.text;\nconst matchedTask = JSON.parse($json.text);\n\nreturn [\n  {\n    json: {\n      text: userMessage,\n      task: matchedTask\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3bfc2d17-6d97-4655-9dc4-53390205ef72",
      "name": "to task object",
      "type": "n8n-nodes-base.code",
      "position": [
        3920,
        352
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: JSON.parse($json.text)\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d0b04c84-5952-4a4c-a491-f36296239bc8",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2352,
        288
      ],
      "parameters": {
        "width": 2140,
        "height": 436,
        "content": " **Update Task**  "
      },
      "typeVersion": 1
    },
    {
      "id": "74560ede-e144-465f-a155-89f4289ae854",
      "name": "Prepare Analysis Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        2560,
        848
      ],
      "parameters": {
        "jsCode": "const userText = $items('Wrap Intent + Text')[0].json.text;\nconst tasks = $items('Get Notion Tasks (analyze)').map(item => item.json);\n\nreturn [\n  {\n    json: {\n      question: userText,\n      tasks: tasks\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b2e89a91-f0a4-4641-bc08-4f5b6e59cdbf",
      "name": "AI Analyze Tasks",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2736,
        848
      ],
      "parameters": {
        "text": "=User question:\n{{ $json.question }}\n\nTasks:\n{{ JSON.stringify($json.tasks, null, 2) }}\n",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are a thoughtful assistant helping the user analyze their current Notion task list and provide useful insights.\n\nYou will receive:\n\n* A natural-language question or comment from the user (e.g. \u201cAm I too overloaded today?\u201d, \u201cWill this week\u2019s plan help me reach my goals?\u201d)\n* A list of current tasks (in JSON), each with fields like `title`, `priority`, `due_date`, `description`, and `tags`\n\nYour job is to:\n\n1. Understand the user's concern or goal (e.g. goal alignment).\n2. Analyze the task list based on:\n\n* Time sensitivity (due dates and today\u2019s load)\n* Priorities\n\n3. Offer actionable advice to improve, rebalance, or adjust the plan.\n\n* If tasks drift from core goals, suggest focus redirection.\n\nOutput format:\n\n* Use plain text only \u2014 friendly, warm, and practical tone\n* Avoid technical terms or code\n* Write as if you\u2019re speaking to a close friend\n\nExample Inputs:\n\u201cAm I too overloaded today?\u201d\n\u201cWill this week\u2019s plan help me reach my goals?\u201d\n\u201cWhat\u2019s the most important thing to do today?\u201d\n\nExample Output:\nYou have 7 tasks today, 4 of which are high priority and work-related. Consider rescheduling 1\u20132 items to tomorrow and adding a 30-minute recharge break.\nYou\u2019re doing great progressing in your professional development \u2014 keep up the focus!\n"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "66f11a2e-185a-4491-9366-88b9d6448a45",
      "name": "Send Analysis Result",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3056,
        848
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "15e9786c-7bf9-4c23-87c3-1ead6e474215",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2352,
        784
      ],
      "parameters": {
        "width": 860,
        "height": 452,
        "content": " **Analyze Tasks**  "
      },
      "typeVersion": 1
    },
    {
      "id": "3e614a4a-d65c-4164-b43b-b336c4f57cde",
      "name": "Create a database page",
      "type": "n8n-nodes-base.notion",
      "position": [
        2736,
        -144
      ],
      "parameters": {
        "title": "={{ $json.output.title }}",
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "25a041f0-262c-8015-855a-f2d5595a2d3a",
          "cachedResultUrl": "https://www.notion.so/25a041f0262c8015855af2d5595a2d3a",
          "cachedResultName": "Tasks"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "={{ $json.output.title }}"
            },
            {
              "key": "Description|rich_text",
              "textContent": "={{ $json.output.description }}"
            },
            {
              "key": "Due Date|date",
              "date": "={{ $json.output.due_date }}",
              "timezone": "Europe/Warsaw"
            },
            {
              "key": "Priority|select",
              "selectValue": "={{ $json.output.priority }}"
            },
            {
              "key": "Tags|multi_select",
              "multiSelectValue": "={{ $json.output.tags }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4742c1df-7a47-46c3-bc73-b5d94c31ac0b",
      "name": "Get Notion Tasks (analyze)",
      "type": "n8n-nodes-base.notion",
      "position": [
        2384,
        848
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "returnAll": true,
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "25a041f0-262c-8015-855a-f2d5595a2d3a",
          "cachedResultUrl": "https://www.notion.so/25a041f0262c8015855af2d5595a2d3a",
          "cachedResultName": "Tasks"
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0cc6b5ed-7394-4c72-a52f-8466cd64592c",
      "name": "Get Notion Tasks (update)",
      "type": "n8n-nodes-base.notion",
      "position": [
        2704,
        352
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "returnAll": true,
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "25a041f0-262c-8015-855a-f2d5595a2d3a",
          "cachedResultUrl": "https://www.notion.so/25a041f0262c8015855af2d5595a2d3a",
          "cachedResultName": "Tasks"
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "095a579c-7c2f-485d-9244-fb0f7fc8c3cc",
      "name": "Update a database page",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4096,
        352
      ],
      "parameters": {
        "url": "=https://api.notion.com/v1/pages/{{ $json[\"id\"] }}",
        "method": "PATCH",
        "options": {},
        "jsonBody": "={\n  \"properties\": {\n    \"Name\": {\n      \"title\": [\n        {\n          \"text\": {\n            \"content\": \"{{ $json[\"property_name\"] }}\"\n          }\n        }\n      ]\n    },\n    \"Description\": {\n      \"rich_text\": [\n        {\n          \"text\": {\n            \"content\": \"{{ $json[\"property_description\"] }}\"\n          }\n        }\n      ]\n    },\n    \"Priority\": {\n      \"select\": {\n        \"name\": \"{{ $json[\"property_priority\"] }}\"\n      }\n    },\n    \"Due Date\": {\n      \"date\": {\n        \"start\": \"{{ $json[\"property_due_date\"].start }}\"\n      }\n    },\n    \"Tags\": {\n      \"multi_select\": [\n        {{ $json.property_tags.map(tag => `{ \"name\": \"${tag}\" }`).join(',') }}\n      ]\n    }\n  }\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi"
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6ebefebc-fd3c-4c22-8119-a5ca7c69daa0",
      "name": "OpenAI Chat Model (Detect Intent)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1312,
        368
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "516646ea-9c5c-49c3-a2c5-989193557f4c",
      "name": "Create Task (Prompt)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2432,
        -144
      ],
      "parameters": {
        "text": "={{$json.text}}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are an assistant that extracts structured task data for creating a Notion task.\n\nYour goal is to return a single JSON object with only these fields:\n- title (string) \u2192 required\n- priority (\"Low\", \"Medium\", \"High\") \u2192 optional\n- description (string) \u2192 optional\n- due_date (YYYY-MM-DD or YYYY-MM-DD HH:mm) \u2192 optional\n- tags (array of lowercase strings) \u2192 optional\n\n\u26a0\ufe0f Only include fields relevant to the input.\n\n\ud83d\udd39 If the user mentions a list (e.g. tasks to do or items to buy), format the list inside the description field using newline-separated bullet points (- item).\n\n\ud83d\udd39 Return only valid JSON. Do not include markdown, prose, or explanations.\n\nExamples:\n\nInput:\n\"Create a high priority task to buy groceries tomorrow and tag it as urgent\"\n\nOutput:\n{\n  \"title\": \"Buy groceries\",\n  \"priority\": \"High\",\n  \"due_date\": \"2025-08-24 08:00\",\n  \"tags\": [\"urgent\"]\n}\n\nInput:\n\"Create a task for tomorrow to go to the store and buy milk, eggs, and bread\"\n\nOutput:\n{\n  \"title\": \"Go to the store\",\n  \"description\": \"- milk\\n- eggs\\n- bread\",\n  \"due_date\": \"2025-08-24\"\n}"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "ec18d81d-ca79-4162-8fb9-3a57486068ab",
      "name": "Create Task Prompt (Model)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2432,
        64
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e2a00da4-206d-49b2-9b73-de4bb09cb2a0",
      "name": "Get Search String Prompt (Model)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2400,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5a56fb1d-86d9-4160-ba39-efe00675373a",
      "name": "Find Matching Task Prompt (Model)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        3072,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "de42695e-3a57-4e02-a47e-2d2692fc69ce",
      "name": "Update Task Prompt (Model)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        3568,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3cc67684-f2a5-4294-b8fa-5dc4bd05b033",
      "name": "Alalyze Task Prompt (Model)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2736,
        1056
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d302a9fc-f927-4e37-be36-69ee37de5278",
      "name": "Send Confirmation (update)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4272,
        352
      ],
      "parameters": {
        "text": "=Task Link :{{ $json.url }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "67fd9d79-98c5-4ac7-9685-e5b7b317f5f8",
  "connections": {
    "Wrap Intent": {
      "main": [
        [
          {
            "node": "Wrap Intent + Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Intent": {
      "main": [
        [
          {
            "node": "Wrap Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Voice or Text?": {
      "main": [
        [
          {
            "node": "Fetch Voice Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare for LLM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "to task object": {
      "main": [
        [
          {
            "node": "Update a database page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare for LLM": {
      "main": [
        [
          {
            "node": "Prepare Unified Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Intent": {
      "main": [
        [
          {
            "node": "Create Task (Prompt)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Search String",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Notion Tasks (analyze)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Analyze Tasks": {
      "main": [
        [
          {
            "node": "Send Analysis Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Search String": {
      "main": [
        [
          {
            "node": "Get Notion Tasks (update)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Matching Task": {
      "main": [
        [
          {
            "node": "Prepare Update Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Task Prompt": {
      "main": [
        [
          {
            "node": "to task object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wrap Intent + Text": {
      "main": [
        [
          {
            "node": "Route by Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Voice Message": {
      "main": [
        [
          {
            "node": "Transcribe Voice to Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Task (Prompt)": {
      "main": [
        [
          {
            "node": "Create a database page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Match Prompt": {
      "main": [
        [
          {
            "node": "Find Matching Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Unified Text": {
      "main": [
        [
          {
            "node": "Detect Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Update Prompt": {
      "main": [
        [
          {
            "node": "Update Task Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a database page": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update a database page": {
      "main": [
        [
          {
            "node": "Send Confirmation (update)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Analysis Prompt": {
      "main": [
        [
          {
            "node": "AI Analyze Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe Voice to Text": {
      "main": [
        [
          {
            "node": "Prepare Unified Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Notion Tasks (update)": {
      "main": [
        [
          {
            "node": "Prepare Match Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Telegram Messages": {
      "main": [
        [
          {
            "node": "Voice or Text?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Task Prompt (Model)": {
      "ai_languageModel": [
        [
          {
            "node": "Create Task (Prompt)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Create Task Fields": {
      "ai_outputParser": [
        [
          {
            "node": "Create Task (Prompt)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Notion Tasks (analyze)": {
      "main": [
        [
          {
            "node": "Prepare Analysis Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Task Prompt (Model)": {
      "ai_languageModel": [
        [
          {
            "node": "Update Task Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Alalyze Task Prompt (Model)": {
      "ai_languageModel": [
        [
          {
            "node": "AI Analyze Tasks",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Search String Prompt (Model)": {
      "ai_languageModel": [
        [
          {
            "node": "Get Search String",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Find Matching Task Prompt (Model)": {
      "ai_languageModel": [
        [
          {
            "node": "Find Matching Task",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model (Detect Intent)": {
      "ai_languageModel": [
        [
          {
            "node": "Detect Intent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}