{
  "name": "AI-Journaling",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": false
        }
      },
      "id": "0c402bdc-7fa2-4fa1-96d6-f02853cfdaa1",
      "name": "Telegram Message Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -1408,
        -944
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $('Telegram Message Trigger').item.json.message.voice.file_id }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -304,
        -848
      ],
      "id": "66219c83-6371-4cc6-ad43-57cee44f52da",
      "name": "Get a file",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "2b538077-d3d3-4713-b973-68748313ff97",
              "leftValue": "={{ $('Telegram Message Trigger').item.json.message.voice }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -528,
        -752
      ],
      "id": "3a1a7f7f-f122-438d-a0f2-1e80d1072dba",
      "name": "Check if Audio file"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -80,
        -848
      ],
      "id": "6f314aef-7ff1-4211-8656-e2c1f8fea374",
      "name": "Transcribe audio",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "id": "61f3b0a0-210a-4eaa-91b5-e381d5f56754",
      "name": "Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        704,
        -1072
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"type\": {\n        \"type\": \"string\"\n      },\n      \"content\": {\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\"type\", \"content\"]\n  }\n}\n"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        832,
        -1072
      ],
      "id": "81e3d526-1105-4315-a24a-5face4153a37",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "jsCode": "// Nimm den strukturierten Output aus dem vorherigen Node\nconst output = $input.first().json.output;\n\n// Hilfsfunktion: Konvertiert den Prompt-Output in Notion-kompatible Blocks\nfunction toNotionBlocks(items) {\n  return items.map(item => {\n    const block = {\n      object: \"block\",\n      type: item.type,\n    };\n\n    if (item.type === \"divider\") {\n      // Divider bekommt kein rich_text, nur ein leeres Objekt\n      block.divider = {};\n    } else {\n      // rich_text immer als Array initialisieren\n      block[item.type] = {\n        rich_text: []\n      };\n\n      // Nur f\u00fcllen, wenn content nicht leer ist\n      if (item.content && item.content.trim() !== \"\") {\n        block[item.type].rich_text.push({\n          type: \"text\",\n          text: { content: item.content }\n        });\n      }\n\n      // Spezialbehandlung f\u00fcr To-Dos\n      if (item.type === \"to_do\") {\n        block.to_do.checked = false;\n      }\n    }\n\n    return block;\n  });\n}\n\n// Wandle den Output um\nconst notionBlocks = toNotionBlocks(output);\n\n// R\u00fcckgabe an den n\u00e4chsten Node\nreturn [\n  {\n    json: {\n      notionBlocks\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1008,
        -1136
      ],
      "id": "587f6d08-71d1-4cb1-9939-1e0e8ba9d968",
      "name": "Format output for POST"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "eb912219-2436-4f04-8ffc-c1c20eb07344",
              "name": "text",
              "value": "={{ $('Telegram Message Trigger').item.json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -80,
        -656
      ],
      "id": "2e9b0ca3-2a0f-441d-89a0-28365c5ba3ef",
      "name": "Set field"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineAll",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        448,
        -1136
      ],
      "id": "fb602c37-afc6-45af-832b-0b90efa5bee1",
      "name": "Merge"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Message Trigger').first().json.message.chat.id }}",
        "text": "=\u2728 Tagebuch-Eintrag erfolgreich erstellt.\nDu kannst den Eintrag [hier]({{ $json.url || \"https://notion.so/\" + $('Get existing entry').item.json.id }}) abrufen.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2224,
        -1248
      ],
      "id": "7dea5c17-bfdb-4874-918b-a6583298efa2",
      "name": "Success Message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Input Processing",
        "height": 464,
        "width": 1200,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -896
      ],
      "id": "0f8da11a-94ce-487a-b98c-a691bf56b859",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "# Template Filling\n",
        "height": 416,
        "width": 1536,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        640,
        -1312
      ],
      "id": "7d437116-a1c9-4936-b321-be6032f2b290",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Message Trigger').first().json.message.chat.id }}",
        "text": "\u231b\ufe0f Tagebuch-Eintrag wird generiert...",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -768,
        -752
      ],
      "id": "cbd49e97-4d81-4cc7-9b93-a03b10b369a9",
      "name": "Wait for creation",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "https://api.notion.com/v1/blocks/{{}}/children",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "authorization",
              "value": ""
            },
            {
              "name": "notion-version",
              "value": "2025-09-03"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -144,
        -1056
      ],
      "id": "8bad1e83-7037-4205-a873-402d7f38af5f",
      "name": "Template request"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "25cbdafb-8a19-4823-af55-67c543e6b246",
              "name": "text",
              "value": "={{ $json.text || $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        144,
        -752
      ],
      "id": "a282c595-166f-45bb-8b85-1e320c234faa",
      "name": "Set text"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "ed1e9433-fe49-4af6-a5ca-b0c45b1ea08e",
              "leftValue": "={{ $json.text.length }}",
              "rightValue": 30,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        336,
        -832
      ],
      "id": "c8f66242-6e63-49fa-a5da-f6fee8cfe629",
      "name": "Length check"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Message Trigger').first().json.message.chat.id }}",
        "text": "\u274c Dieser Inhalt ist zu kurz f\u00fcr einen Tagebucheintrag.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        464,
        -592
      ],
      "id": "5c4a3935-2c28-41f4-837f-d6a4055a42a6",
      "name": "Input too short Error",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Message Trigger').first().json.message.chat.id }}",
        "text": "\u274c Es ist ein Fehler bei der Erstellung des Eintrags aufgetreten!",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2224,
        -1056
      ],
      "id": "78846c6b-2f4f-4d21-8927-793aa147366b",
      "name": "Creation Error Message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        -976,
        -944
      ],
      "id": "8d5aeb3e-2c8f-4be2-9165-c4ad66b17a5b",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "Journal",
          "cachedResultUrl": "https://www.notion.so/{{}}"
        },
        "returnAll": true,
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        -1200,
        -944
      ],
      "id": "b46a98c3-2b0e-4625-ac01-a6b221ed9e0d",
      "name": "Get all journal entries",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c86134e7-d5ff-4b56-8dca-b7d91f30adce",
              "leftValue": "={{ $json[\"data\"].some(item => item.property_datum && item.property_datum.start === $now.format(\"yyyy-MM-dd\"))}}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -768,
        -1072
      ],
      "id": "51c580df-1264-427c-901e-695af905f26f",
      "name": "If journal entry for today exists"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.notion.com/v1/pages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "authorization",
              "value": ""
            },
            {
              "name": "notion-version",
              "value": "2025-09-03"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"parent\": {\n    \"database_id\": \"\"\n  },\n  \"properties\": {{ JSON.stringify($('Property Generator Agent').item.json.output.properties) }},\n  \"children\": {{ JSON.stringify($('Format output for POST').item.json.notionBlocks) }}\n} ",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2032,
        -1168
      ],
      "id": "1941648e-a1ca-4bab-933c-dd26fe9d4d09",
      "name": "Write entry to Notion",
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "content": "# Entry existence check",
        "height": 880,
        "width": 720,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1280,
        -1312
      ],
      "id": "11916bdd-1260-402c-af2d-06e542adb4b1",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "jsCode": "// n8n Code Node (JavaScript)\n// Ziel: Vereinfacht den Notion-Block-Response zu [{ type, content }, ...]\n\nconst blocks = $input.first().json.results || []; // Greif auf das Array \"results\" zu\n\nconst output = blocks.map(block => {\n  const type = block.type;\n  let content = '';\n\n  // Versuche den Text-Inhalt aus dem jeweiligen Typ herauszuholen\n  if (block[type]?.rich_text?.length > 0) {\n    // F\u00fcge alle Text-Elemente zusammen (z. B. bei mehreren Rich-Text-Objekten)\n    content = block[type].rich_text.map(rt => rt.plain_text).join('');\n  } else {\n    content = ''; // Falls kein Text vorhanden ist\n  }\n\n  return {\n    type,\n    content\n  };\n});\n\n// Gib das Ergebnis als n8n-kompatibles Array zur\u00fcck\nreturn [\n  {\n    json: {\n      template: output // das Array mit den Bl\u00f6cken\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        128,
        -1152
      ],
      "id": "cb7756ad-973d-4337-b5fc-aea4612ca398",
      "name": "Reformat template JSON"
    },
    {
      "parameters": {
        "url": "=https://api.notion.com/v1/blocks/{{ $json.id }}/children",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "authorization",
              "value": ""
            },
            {
              "name": "notion-version",
              "value": "2025-09-03"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -144,
        -1248
      ],
      "id": "ce23b758-e619-4a17-ba48-94fd11bc7f88",
      "name": "Entry request"
    },
    {
      "parameters": {
        "content": "# Entry / Template Reading",
        "height": 416,
        "width": 1200
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -1312
      ],
      "id": "1673f342-01bf-4fa0-ab4d-b84e66582ef5",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "jsCode": "for (const item of $input.first().json.data) {\n  if (item.property_datum?.start === $now.toFormat(\"yyyy-MM-dd\")) {\n    return item;\n  }\n}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -400,
        -1248
      ],
      "id": "6a9c4219-cd39-474c-8219-7f360d531e8f",
      "name": "Get existing entry"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "e7885a0c-084b-4d7b-8caf-931e67c51992",
              "leftValue": "={{ $('Aggregate').item.json.data.some(item => item.property_datum && item.property_datum.start === $now.format(\"yyyy-MM-dd\"))}}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1232,
        -1136
      ],
      "id": "cf082c7a-ab7d-4541-9936-fef665f90e94",
      "name": "If existing entry was edited"
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.notion.com/v1/pages/{{$('Get existing entry').item.json.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": ""
            },
            {
              "name": "Notion-Version",
              "value": "2025-09-03"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "archived",
              "value": "={{true}}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1504,
        -1248
      ],
      "id": "2610be84-62a0-4f8d-9902-c70775166802",
      "name": "Delete existing entry"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "id": "b1bee855-126a-4b88-b963-ea3b7d28f812",
      "name": "Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1472,
        -624
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=template:\n{{ JSON.stringify($json.template) }}\n\ntext:\n{{ $json.text }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=template: Liste von Objekten mit den Feldern type und content. \n\ntext: unstrukturierter Flie\u00dftext \u00fcber den Tag des Nutzers, der inhaltlich den Feldern zugeordnet werden soll. \n\n\nRegeln: \n\nTemplate-Struktur bleibt grunds\u00e4tzlich unver\u00e4ndert. \n\nKein Element darf gel\u00f6scht werden. Die Reihenfolge der urspr\u00fcnglichen Elemente bleibt unver\u00e4ndert. Das Feld type wird niemals ver\u00e4ndert. \n\nNur das Feld content darf bei Nicht-Heading-Elementen angepasst werden. \n\nHeadings (heading_*) bleiben immer unver\u00e4ndert, sowohl type als auch content. \n\n\n\nInhaltliche Bef\u00fcllung: \n\nInhalte aus text sollen passend den Nicht-Heading-Feldern (paragraph, to_do, quote, callout usw.) zugeordnet werden. \n\nInhalte, die Aufgaben, Pflichten oder Vors\u00e4tze ausdr\u00fccken \u2192 to_do Beschreibende, reflektierende, erl\u00e4uternde Textteile \u2192 paragraph Zitate \u2192 quote Hinweise, Warnungen oder Betonungen \u2192 callout \n\n\nLockerung: \n\nEs d\u00fcrfen zus\u00e4tzliche paragraph- und to_do-Elemente erstellt werden, wenn der Text mehr Inhalte liefert, als das urspr\u00fcngliche Template abbilden kann. \n\nFalls mehr to_do-Elemente im Template vorhanden sind, als tats\u00e4chlich To-Dos existieren, bleiben deren content-Felder leer. \n\n\n\nWichtig: Vorhandene Inhalte im Template:\n\nDas Template kann bereits mit Inhalten gef\u00fcllt sein.\n\nDiese vorhandenen Inhalte m\u00fcssen mit neuen, passenden Inhalten sinnvoll erg\u00e4nzt werden. \n\nEs d\u00fcrfen keine wesentlichen Informationen aus den vorhandenen Inhalten entfernt werden\n\nAlle wesentlichen Informationen aus dem bestehenden Template und dem neuen Text bleiben vollst\u00e4ndig erhalten.\n\nDie Erg\u00e4nzung erfolgt durch sinnvolle Erweiterung der bestehenden Inhalte, ohne Doppelungen oder Sinnverlust.\n\n\n\nRichtext-Array: \n\nBeim Erstellen des finalen Richtext-Arrays werden nur Elemente aufgenommen, deren content nicht leer ist. \n\nKeine Erg\u00e4nzungen zu quote oder callout au\u00dfer es gibt entsprechende Inhalte im Text. \n\nSinn und Aussage des Originaltextes d\u00fcrfen nicht ver\u00e4ndert werden. \n\n\nSprache: \n\nInhalte sollen klar, verst\u00e4ndlich und nat\u00fcrlich formuliert sein. \n\n\nAusgabeformat: \n\nAusschlie\u00dflich die vollst\u00e4ndig ausgef\u00fcllte JSON-Struktur (Richtext-Array nur mit nicht-leeren content-Feldern). \n\nSyntaktisch korrektes JSON. \n\nKeine Erkl\u00e4rungen, Kommentare oder zus\u00e4tzlicher Text au\u00dferhalb der JSON."
        }
      },
      "id": "f958d2f6-6602-4443-bfae-ef628af09b84",
      "name": "Template Filling Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        704,
        -1216
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=content:\n{{ JSON.stringify($('Format output for POST').item.json.notionBlocks) }}\n\nproperties:\n{{ JSON.stringify($json.properties) }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=Du bist ein Experte f\u00fcr Notion-Datenbanken und die Notion API. Du bekommst zwei Inputs:\n\nContent \u2013 ein JSON-Array, das die Notion-Blockstruktur enth\u00e4lt. Beispiel:\n\n[\n  {\n    \"object\": \"block\",\n    \"type\": \"heading_1\",\n    \"heading_1\": {\n      \"text\": [\n        {\n          \"type\": \"text\",\n          \"text\": {\n            \"content\": \"Tagesr\u00fcckblick\"\n          }\n        }\n      ]\n    }\n  },\n  {\n    \"object\": \"block\",\n    \"type\": \"paragraph\",\n    \"paragraph\": {\n      \"text\": [\n        {\n          \"type\": \"text\",\n          \"text\": {\n            \"content\": \"Heute habe ich an mehreren Projekten gearbeitet.\"\n          }\n        }\n      ]\n    }\n  }\n]\n\n\nProperties \u2013 ein JSON-Objekt, das die existierenden Datenbank-Properties beschreibt. Beispiel:\n\n{\n  \"Datum\": {\"id\":\"MZTi\",\"name\":\"Datum\",\"description\":null,\"type\":\"date\",\"date\":{}},\n  \"Name\": {\"id\":\"title\",\"name\":\"Name\",\"description\":null,\"type\":\"title\",\"title\":{}}\n}\n\n\nAktuelles Datum \u2013 das heutige Datum f\u00fcr Tagebucheintr\u00e4ge ist {{ $now }}\n\nRegeln (angepasst):\n\nEs kann beliebig viele Properties geben, in unterschiedlichen Typen (title, rich_text, number, select, multi_select, date, checkbox, url, \u2026).\n\nTitel fixieren: Das title-Property wird immer auf \"Tagebucheintrag\" gesetzt. Inhalt aus dem Content wird daf\u00fcr nicht verwendet.\n\nF\u00fclle die anderen Properties typgerecht aus dem Content:\n\nrich_text: Text aus Content \u00fcbernehmen, wenn eindeutig erkennbar.\n\nnumber: Nur Zahlen einf\u00fcgen, wenn eindeutig erkennbar.\n\nselect / multi_select: M\u00f6glichst passende Werte aus Content ableiten, nur wenn eindeutig.\n\ndate: Wenn das Feld ein Tagebuch-Datum darstellt, verwende das aktuelle Datum.\n\ncheckbox: true/false nur, wenn eindeutig erkennbar.\n\nurl: nur f\u00fcllen, wenn eindeutig.\n\nUnsichere Properties weglassen: Versuche, den Wert der Properties auf Basis des Content zu erkennen. Wenn ein Property nicht aus dem Content abgeleitet werden kann, entferne es komplett aus der Ausgabe, auch wenn es im Input vorhanden ist.\n\nOutput:\n\nNur JSON, genau diesem Schema f\u00fcr die Notion-API-kompatibel:\n\n{\n  \"properties\": {\n    \"Name\": {\n      \"title\": [\n        { \"text\": { \"content\": \"Tagebucheintrag\" } }\n      ]\n    },\n    \"Datum\": {\n      \"date\": { \"start\": \"2025-10-13\" }\n    }\n  }\n}\n\n\nAlle Properties m\u00fcssen enthalten sein, die einen klaren Wert haben. Unsichere Properties werden vollst\u00e4ndig weggelassen.\n\nDatumsfelder f\u00fcr Tagebucheintr\u00e4ge sollen immer das angegebene aktuelle Datum nutzen.\n\nF\u00fclle nur Inhalte, die sicher ableitbar sind, andere bleiben komplett weg."
        }
      },
      "id": "eecc5d13-d6ac-4b76-ab09-a40b4dfa0d36",
      "name": "Property Generator Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        1472,
        -816
      ]
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineAll",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1808,
        -1104
      ],
      "id": "f39feee3-a1bd-4cfc-9df8-6c272817704f",
      "name": "Merge1"
    },
    {
      "parameters": {
        "content": "# Property Generation\n\n",
        "height": 464,
        "width": 1536,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        640,
        -896
      ],
      "id": "72c20735-cf18-4bf5-9ff3-f091f7fcfbd5",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "resource": "database",
        "databaseId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "Journal",
          "cachedResultUrl": "https://www.notion.so/{{}}"
        },
        "simple": false
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        1264,
        -816
      ],
      "id": "409495a8-301e-4f07-b735-095edebf7300",
      "name": "Get a database",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"title\": \"NotionPropertiesOutput\",\n  \"type\": \"object\",\n  \"required\": [\"properties\"],\n  \"properties\": {\n    \"properties\": {\n      \"type\": \"object\",\n      \"additionalProperties\": {\n        \"type\": \"object\",\n        \"oneOf\": [\n          {\n            \"title\": \"TitleProperty\",\n            \"properties\": {\n              \"title\": {\n                \"type\": \"array\",\n                \"items\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"text\": {\n                      \"type\": \"object\",\n                      \"properties\": {\n                        \"content\": { \"type\": \"string\" }\n                      },\n                      \"required\": [\"content\"]\n                    }\n                  },\n                  \"required\": [\"text\"]\n                }\n              }\n            },\n            \"required\": [\"title\"]\n          },\n          {\n            \"title\": \"RichTextProperty\",\n            \"properties\": {\n              \"rich_text\": {\n                \"type\": \"array\",\n                \"items\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"text\": {\n                      \"type\": \"object\",\n                      \"properties\": {\n                        \"content\": { \"type\": \"string\" }\n                      },\n                      \"required\": [\"content\"]\n                    }\n                  },\n                  \"required\": [\"text\"]\n                }\n              }\n            },\n            \"required\": [\"rich_text\"]\n          },\n          {\n            \"title\": \"NumberProperty\",\n            \"properties\": {\n              \"number\": { \"type\": [\"number\", \"null\"] }\n            },\n            \"required\": [\"number\"]\n          },\n          {\n            \"title\": \"SelectProperty\",\n            \"properties\": {\n              \"select\": {\n                \"type\": [\"object\", \"null\"],\n                \"properties\": {\n                  \"name\": { \"type\": \"string\" }\n                }\n              }\n            },\n            \"required\": [\"select\"]\n          },\n          {\n            \"title\": \"MultiSelectProperty\",\n            \"properties\": {\n              \"multi_select\": {\n                \"type\": \"array\",\n                \"items\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"name\": { \"type\": \"string\" }\n                  },\n                  \"required\": [\"name\"]\n                }\n              }\n            },\n            \"required\": [\"multi_select\"]\n          },\n          {\n            \"title\": \"DateProperty\",\n            \"properties\": {\n              \"date\": {\n                \"type\": [\"object\", \"null\"],\n                \"properties\": {\n                  \"start\": { \"type\": \"string\", \"format\": \"date\" }\n                },\n                \"required\": [\"start\"]\n              }\n            },\n            \"required\": [\"date\"]\n          },\n          {\n            \"title\": \"CheckboxProperty\",\n            \"properties\": {\n              \"checkbox\": { \"type\": [\"boolean\", \"null\"] }\n            },\n            \"required\": [\"checkbox\"]\n          },\n          {\n            \"title\": \"UrlProperty\",\n            \"properties\": {\n              \"url\": { \"type\": [\"string\", \"null\"] }\n            },\n            \"required\": [\"url\"]\n          }\n        ]\n      }\n    }\n  }\n}\n"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        1616,
        -640
      ],
      "id": "c967db4c-6081-4fee-89ae-0686fd8ae0c0",
      "name": "Structured Output Parser1"
    }
  ],
  "connections": {
    "Telegram Message Trigger": {
      "main": [
        [
          {
            "node": "Get all journal entries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a file": {
      "main": [
        [
          {
            "node": "Transcribe audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Audio file": {
      "main": [
        [
          {
            "node": "Get a file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe audio": {
      "main": [
        [
          {
            "node": "Set text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model": {
      "ai_languageModel": [
        [
          {
            "node": "Template Filling Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Template Filling Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Format output for POST": {
      "main": [
        [
          {
            "node": "If existing entry was edited",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get a database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set field": {
      "main": [
        [
          {
            "node": "Set text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Template Filling Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for creation": {
      "main": [
        [
          {
            "node": "Check if Audio file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Template request": {
      "main": [
        [
          {
            "node": "Reformat template JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set text": {
      "main": [
        [
          {
            "node": "Length check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Length check": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Input too short Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "If journal entry for today exists",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait for creation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all journal entries": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If journal entry for today exists": {
      "main": [
        [
          {
            "node": "Get existing entry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Template request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write entry to Notion": {
      "main": [
        [
          {
            "node": "Success Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Creation Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reformat template JSON": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Entry request": {
      "main": [
        [
          {
            "node": "Reformat template JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get existing entry": {
      "main": [
        [
          {
            "node": "Entry request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If existing entry was edited": {
      "main": [
        [
          {
            "node": "Delete existing entry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete existing entry": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Property Generator Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Template Filling Agent": {
      "main": [
        [
          {
            "node": "Format output for POST",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Write entry to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Property Generator Agent": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get a database": {
      "main": [
        [
          {
            "node": "Property Generator Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Property Generator Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5faacc8a-a3d5-439e-b565-4ac76aa88dda",
  "meta": {
    "templateId": "voice_assistant_agent_with_telegram",
    "templateCredsSetupCompleted": true
  },
  "id": "WNdQHEPSn0LDvH70",
  "tags": []
}