{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "nodes": [
    {
      "id": "c0976bf6-0479-4e3f-8cc1-80c108ed4d05",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        0,
        432
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "40f0e3e2-e0f2-4756-b57c-2938c6b1a076",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        560,
        704
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4e984eec-ff19-4cd9-a30a-0779331fe5f3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 408,
        "content": "### \ud83d\udee0\ufe0f Setup Instructions\n1. Create and connect your API credentials:\n   - [Telegram Bot](https://sendpulse.com/knowledge-base/chatbot/telegram/create-telegram-chatbot)\n   - [OpenAI API Key](https://apidog.com/blog/openai-api-key-free/)\n   - [Notion Integration](https://developers.notion.com/docs/create-a-notion-integration#create-your-integration-in-notion)\n2. Deploy the article parser:\n   - Use this repo: [article-parser-api](https://github.com/Yosua1011/article-parser-api)\n   - Deploy it to Vercel or any serverless environment\n3. Link your Notion database:\n   - Duplicate the [AI\u2011Enhanced Knowledge Base Tracker](https://www.notion.com/templates/ai-enhanced-knowledge-base-tracker)\n   - Add n8n connection to your Notion database page ([guide](https://www.notion.com/help/add-and-manage-connections-with-the-api?g-exp=use_transcend_for_cookie_consent_on_front--on#add-connections-to-pages))\n   - Copy the database URL and connect it in the Notion node\n4. Test your workflow:\n   - Click **Execute workflow**\n   - Send an article link to your Telegram bot\n5. Once verified, activate the workflow so it runs automatically"
      },
      "typeVersion": 1
    },
    {
      "id": "98fd40b1-4632-4a34-bc81-b68be413ee96",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        832
      ],
      "parameters": {
        "color": 7,
        "width": 162,
        "height": 115,
        "content": "\ud83d\udc46 You can exchange this with any other chat model of your choice."
      },
      "typeVersion": 1
    },
    {
      "id": "0a84a129-b018-451f-b16e-57c42b4a6ae7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        624
      ],
      "parameters": {
        "color": 7,
        "width": 402,
        "height": 399,
        "content": "\ud83d\udc46 How to setup **Save Article to Notion Database** node\n\n1. **Connect Your Notion Account**  \n   - Click the \"add your connection\" link at the top of this node.  \n   - Without this, the system won't be able to access your Notion database.\n\n2. **Enter Your Notion Database URL**  \n   - In the **\"Database\"** field, select \"By URL\" and paste your full Notion database link.  \n   - \u26a0\ufe0f Ensure your database matches the required structure.  \n   - You can use the [AI-Enhanced Knowledge Base Tracker Notion Template](https://www.notion.so) as a starting point.\n\n> \ud83d\udca1 **Tip:** You must do this whenever using a new Notion database, as property identifiers vary by page.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e6a516f0-0a7e-444e-8294-0f0895e5152e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -16
      ],
      "parameters": {
        "width": 562,
        "height": 284,
        "content": "### \ud83d\udd0d Workflow breakdown:\n1. **Telegram Trigger** - Listens for incoming message containing an article link.\n2. **Fetch Article Title & Content** - Calls the [article-parser-api](https://github.com/Yosua1011/article-parser-api) deployed on Vercel to fetch and parse the article content into structured JSON (title and content).\n3. **Generate Highlight + Tag (AI Agent)** - Processes the parsed content to generate Highlight and Type tag values.\n4. **Structured Metadata for Notion** - Adjusts the extracted data before saving it to Notion.\n5. **Save Article to Notion Database** - Inserts the article and generated metadata into your Notion knowledge base.\n6. **Confirm Save via Telegram** - Sends a confirmation message and the Notion page link back to the Telegram bot chat after the entry is created."
      },
      "typeVersion": 1
    },
    {
      "id": "bf8383b2-79ec-4d9a-a827-083c2e64abdd",
      "name": "Fetch Article Title & Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        256,
        432
      ],
      "parameters": {
        "url": "=https://YOUR_DEPLOYED_ARTICLE_PARSER_URL.vercel.app/api/parse?url={{$json[\"message\"][\"text\"]}}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "3e61d36a-b943-422f-8500-3792ee36e21c",
      "name": "Generate Highlight + Tag (AI Agent)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        560,
        432
      ],
      "parameters": {
        "text": "=You are a knowledge management assistant. Given an article title and content, your job is to:\n\n1. Generate a 1\u20132 sentence highlight summarizing the article.\n2. Suggest a relevant single-word tag for the article's topic (e.g., AI, Health, Startups, Cloud, Finance).\n\nHere is the article:\n\nTitle: {{ $json[\"title\"] }}\n\nContent: {{ $json[\"content\"] }}\n\nPlease respond with a JSON object like:\n{\n  \"highlight\": \"...\",\n  \"type\": \"...\"\n}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "383cb738-85da-4cfd-9fb9-66a35d1e720e",
      "name": "Structure Metadata for Notion",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ASSIGNMENT_1_ID",
              "name": "title",
              "type": "string",
              "value": "={{$node[\"Fetch Article Title & Content\"].json[\"title\"]}}"
            },
            {
              "id": "ASSIGNMENT_2_ID",
              "name": "url",
              "type": "string",
              "value": "={{$node[\"Telegram Trigger\"].json[\"message\"][\"text\"]}}"
            },
            {
              "id": "ASSIGNMENT_3_ID",
              "name": "highlight",
              "type": "string",
              "value": "={{ JSON.parse($node[\"Generate Highlight + Tag (AI Agent)\"].json[\"output\"].replace(/```json|```/g, '').trim()).highlight }}"
            },
            {
              "id": "ASSIGNMENT_4_ID",
              "name": "type",
              "type": "string",
              "value": "={{ JSON.parse($node[\"Generate Highlight + Tag (AI Agent)\"].json[\"output\"].replace(/```json|```/g, '').trim()).type }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2475df33-b459-4fbb-9989-daa387c58fac",
      "name": "Save Article to Notion Database",
      "type": "n8n-nodes-base.notion",
      "position": [
        1280,
        432
      ],
      "parameters": {
        "title": "={{$json[\"title\"]}}",
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "url",
          "value": "https://www.notion.so/YOUR_DATABASE_ID_PLACEHOLDER?v=YOUR_VIEW_ID_PLACEHOLDER"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "=\u2705 Status|select",
              "selectValue": "=Backlog"
            },
            {
              "key": "=\ud83d\udcc5 Date Added|date",
              "date": "={{ $now.format('yyyy-MM-dd') }}"
            },
            {
              "key": "=\ud83d\udcf0 Headline|title",
              "title": "={{$json[\"title\"]}}"
            },
            {
              "key": "=\ud83d\udd17 URL|url",
              "urlValue": "={{$json[\"url\"]}}"
            },
            {
              "key": "=\ud83c\udff7\ufe0f Type|multi_select",
              "multiSelectValue": "={{$json[\"type\"]}}"
            },
            {
              "key": "=\u2728 Highlight|rich_text",
              "textContent": "={{$json[\"highlight\"]}}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "09133985-19cc-4795-9c2f-f4ac931f5060",
      "name": "Confirm Save via Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1600,
        432
      ],
      "parameters": {
        "text": "=\u2705 New article saved to Notion!\n\n\ud83d\udccc {{ $json[\"name\"] }}\n\ud83d\udcdd Highlight: {{ $json[\"property_highlight\"] }}\n\n\ud83d\udd17 Notion Page: {{ $json[\"url\"] }}\n",
        "chatId": "={{ $node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "406d4a53-c1eb-43f2-a58e-1876c2cff9c6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        592
      ],
      "parameters": {
        "color": 7,
        "width": 242,
        "height": 627,
        "content": "\ud83d\udc46 Calls your deployed `article-parser-api` to extract a clean **title** + **content** from the article link sent in Telegram.\n\n**Configure:**\n- Replace the base URL with your own deployment.\n- Pass the Telegram message text into `url=` param:\n  `?url={{ $json[\"message\"][\"text\"] }}`\n\n**Example URL**\n`https://YOUR_DEPLOYED_ARTICLE_PARSER_URL.vercel.app/api/parse?url={{$json[\"message\"][\"text\"]}}`\n\n**Expected Output JSON:**\n{\n  \"title\": \"...\",\n  \"content\": \"...\"\n}\n\nIf parsing fails or returns empty content, the AI step may error.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Fetch Article Title & Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Highlight + Tag (AI Agent)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Article Title & Content": {
      "main": [
        [
          {
            "node": "Generate Highlight + Tag (AI Agent)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structure Metadata for Notion": {
      "main": [
        [
          {
            "node": "Save Article to Notion Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Article to Notion Database": {
      "main": [
        [
          {
            "node": "Confirm Save via Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Highlight + Tag (AI Agent)": {
      "main": [
        [
          {
            "node": "Structure Metadata for Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}