{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -600,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000001",
      "name": "Execute Workflow Trigger"
    },
    {
      "parameters": {
        "jsCode": "// Merge caller input with defaults\nconst input = $input.first().json || {};\nconst defaults = {\n  searchTerm: 'NVIDIA',\n  chatId: 'YOUR_CHAT_ID_1'\n};\nreturn [{ json: { ...defaults, ...input, searchTerm: input.text || input.searchTerm || defaults.searchTerm } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -400,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000002",
      "name": "Config"
    },
    {
      "parameters": {
        "operation": "search",
        "text": "={{ $json.searchTerm }}",
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        -180,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000003",
      "name": "Search Notion",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "block",
        "operation": "getAll",
        "blockId": {
          "__rl": true,
          "value": "={{ $json.url }}",
          "mode": "url"
        },
        "limit": 100
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        40,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000004",
      "name": "Get Page Blocks",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "language": "pythonNative",
        "pythonCode": "list_ = []\n\nfor item in _items:\n    if \"content\" in item[\"json\"]:\n        content = item[\"json\"][\"content\"]\n        list_.append(content)\n\nreturn [\n    {\n        \"json\": {\n            \"page_text\": list_\n        }\n    }\n]"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000005",
      "name": "Extract Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ln-set-noted",
              "name": "noted",
              "value": "={{ $json.page_text.join('\\n') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        480,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000006",
      "name": "Set Fields"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Summarize the following notes concisely. Focus on key insights and actionable information.\n\n{{ $json.noted }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You are a helpful assistant that summarizes notes. Return a JSON object with:\n- \"think\": your reasoning process\n- \"summary\": a concise 1-3 paragraph summary of the key insights"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        700,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000007",
      "name": "AI Summary"
    },
    {
      "parameters": {
        "modelName": "models/gemini-flash-latest",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        700,
        480
      ],
      "id": "ln100001-0001-0001-0001-000000000008",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"think\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"summary\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        1020,
        480
      ],
      "id": "ln100001-0001-0001-0001-000000000010",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "chatId": "={{ $('Config').first().json.chatId }}",
        "text": "=\ud83d\udcda Learning Notes\n\n{{ $json.output.summary }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        920,
        300
      ],
      "id": "ln100001-0001-0001-0001-000000000011",
      "name": "Send to Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Learning Notes\n\nSearches Notion for pages matching the search term, extracts text, and sends an AI-generated summary via Telegram.\n\n**Config**: Edit the Config node to change search term or chat ID.",
        "height": 200,
        "width": 300
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -600,
        60
      ],
      "id": "ln100001-0001-0001-0001-000000000012",
      "name": "Sticky Note - Overview"
    }
  ],
  "connections": {
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Search Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Notion": {
      "main": [
        [
          {
            "node": "Get Page Blocks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Page Blocks": {
      "main": [
        [
          {
            "node": "Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text": {
      "main": [
        [
          {
            "node": "Set Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Fields": {
      "main": [
        [
          {
            "node": "AI Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Summary": {
      "main": [
        [
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Summary",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Summary",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}