AutomationFlowsAI & RAG › Summarize Telegram-shared Webpages with Openai Gpt-4o

Summarize Telegram-shared Webpages with Openai Gpt-4o

ByDr. Firas @drfiras on n8n.io

This workflow listens for Telegram messages containing a URL, fetches and cleans the webpage content, summarizes it with an OpenAI chat model, and replies in the same Telegram chat with a formatted summary including key points and action items. Triggers when a new Telegram…

Event trigger★★★★☆ complexityAI-powered19 nodesTelegram TriggerHTTP RequestAgentOpenAI ChatOutput Parser StructuredTelegram
AI & RAG Trigger: Event Nodes: 19 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #16936 — we link there as the canonical source.

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "DAlAi9ultq5lsnMY",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Summarize webpages shared in Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "599031e0-ed29-4d24-8f7d-35cdd784e61c",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        0,
        208
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f38e5bd2-52cb-42d6-af47-296237f69b11",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "openai-model",
              "name": "openai_model",
              "type": "string",
              "value": "gpt-4o"
            },
            {
              "id": "max-page-size",
              "name": "max_page_size",
              "type": "number",
              "value": 60000
            },
            {
              "id": "include-raw-url",
              "name": "include_raw_url_in_prompt",
              "type": "boolean",
              "value": true
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "960af6c7-04bd-4556-9262-867e463fd7b3",
      "name": "Extract URL",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        208
      ],
      "parameters": {
        "jsCode": "const message = $input.first().json.message || {};\nconst text = message.text || '';\nconst chatId = message.chat?.id;\nconst match = text.match(/https?:\\/\\/[^\\s]+/);\nreturn {\n  json: {\n    source_url: match ? match[0] : '',\n    chat_id: chatId ? String(chatId) : '',\n  },\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "490b4171-0455-480e-a2e1-3e98135cd2a8",
      "name": "URL Valid?",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "regex",
                "rightValue": "^https?:\\/\\/.+"
              },
              "leftValue": "={{ $('Extract URL').item.json.source_url }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f197dedb-f660-482a-90a7-b3492e5e63b4",
      "name": "Fetch Webpage",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        896,
        112
      ],
      "parameters": {
        "url": "={{ $('Extract URL').item.json.source_url }}",
        "options": {
          "timeout": 15000,
          "redirect": {
            "redirect": {
              "maxRedirects": 5
            }
          },
          "response": {
            "response": {}
          }
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "10965fa4-7916-4f77-adf9-947289b1495c",
      "name": "Extract Page Content",
      "type": "n8n-nodes-base.html",
      "onError": "continueErrorOutput",
      "position": [
        1120,
        112
      ],
      "parameters": {
        "options": {
          "trimValues": true,
          "cleanUpText": true
        },
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "page_title",
              "cssSelector": "title"
            },
            {
              "key": "page_body",
              "cssSelector": "body",
              "skipSelectors": "script, style, nav, footer, header, aside, .ads, .advertisement, .menu, .navigation, .sidebar, .social, .share, .comments, .cookie-banner, .modal, .popup"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "75171323-2c2c-4f64-bd97-06daa1c04a34",
      "name": "Prepare Summary Input",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        112
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "page-title",
              "name": "page_title",
              "type": "string",
              "value": "={{ $('Extract Page Content').item.json.page_title || 'Untitled page' }}"
            },
            {
              "id": "page-text",
              "name": "page_text",
              "type": "string",
              "value": "={{ (() => { const body = $('Extract Page Content').item.json.page_body || ''; const max = $('Configuration').item.json.max_page_size || 60000; return body.length > max ? body.substring(0, max) + '\\n[truncated]' : body; })() }}"
            },
            {
              "id": "source-url-final",
              "name": "source_url",
              "type": "string",
              "value": "={{ $('Extract URL').item.json.source_url }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "1ac3b9a5-51ad-4d81-9419-76f9a392f6ea",
      "name": "Summarize Page",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueErrorOutput",
      "position": [
        1712,
        112
      ],
      "parameters": {
        "text": "={{ (() => { const url = $('Prepare Summary Input').item.json.source_url; const title = $('Prepare Summary Input').item.json.page_title; const text = $('Prepare Summary Input').item.json.page_text; const includeUrl = $('Configuration').item.json.include_raw_url_in_prompt; let prompt = 'Summarize the following webpage.\\n\\n'; if (includeUrl) prompt += 'Source URL: ' + url + '\\n'; prompt += 'Page title: ' + title + '\\n\\n'; prompt += 'Page text:\\n' + text + '\\n\\n'; prompt += 'Return a JSON object with these fields only: page_title (string), source_url (string), short_summary (string), key_points (array of strings), useful_insights_or_action_items (array of strings).'; return prompt; })() }}",
        "options": {
          "maxIterations": 5,
          "systemMessage": "You are a precise web-page summarizer. Use the provided title and body text. Do not invent facts. Keep the short_summary under 200 words. Return exactly the requested JSON shape."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "c0cb5c27-e819-4679-84ab-b1e27dcf4b7c",
      "name": "OpenAI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1728,
        336
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configuration').item.json.openai_model }}"
        },
        "options": {
          "maxTokens": 2500,
          "temperature": 0.3
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "061fd4db-8c28-44fe-96df-8b0077c0055e",
      "name": "Summary Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1856,
        336
      ],
      "parameters": {
        "jsonSchemaExample": "{\"page_title\":\"string\",\"source_url\":\"string\",\"short_summary\":\"string\",\"key_points\":[\"string\"],\"useful_insights_or_action_items\":[\"string\"]}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "e8c401ab-05b7-4d21-8a0b-5b686f7e1933",
      "name": "Format Summary",
      "type": "n8n-nodes-base.set",
      "position": [
        2064,
        112
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "telegram-text",
              "name": "telegram_text",
              "type": "string",
              "value": "={{ (() => { const d = $('Summarize Page').item.json.output || {}; let s = '<b>' + (d.page_title || 'Summary') + '</b>\\n'; s += '<a href=\"' + (d.source_url || '') + '\">' + (d.source_url || '') + '</a>\\n\\n'; s += '<b>Summary</b>\\n' + (d.short_summary || '') + '\\n\\n'; if (Array.isArray(d.key_points) && d.key_points.length) { s += '<b>Key points</b>\\n'; d.key_points.forEach(p => { s += '\u2022 ' + p + '\\n'; }); s += '\\n'; } if (Array.isArray(d.useful_insights_or_action_items) && d.useful_insights_or_action_items.length) { s += '<b>Insights / Action items</b>\\n'; d.useful_insights_or_action_items.forEach(i => { s += '\u2022 ' + i + '\\n'; }); } return s; })() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dd4b7a7f-a4e1-4e56-936c-a3a2506bb006",
      "name": "Send Summary to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2288,
        112
      ],
      "parameters": {
        "text": "={{ $('Format Summary').item.json.telegram_text }}",
        "chatId": "={{ $('Extract URL').item.json.chat_id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false,
          "disable_web_page_preview": true
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "835e5354-30fb-4e21-baf6-475dd9e1ae7d",
      "name": "Send Invalid URL Error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        304
      ],
      "parameters": {
        "text": "I could not find a valid URL in your message. Please send a web link starting with http:// or https://.",
        "chatId": "={{ $('Extract URL').item.json.chat_id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4e3cffe7-7a50-43a9-9ed4-aefb20e5a0b2",
      "name": "Main Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -448
      ],
      "parameters": {
        "color": 6,
        "width": 540,
        "height": 1476,
        "content": "# Summarize webpages shared in Telegram\n\n# \ud83d\udce5  [Open full documentation on Notion](https://automatisation.notion.site/How-to-Install-n8n-on-Hermes-Agent-Course-Prompts-3983d6550fd9810c8da8dcaf0f93d271)\n\n## How it works\nA user sends any text message containing a URL to a connected Telegram bot. The workflow extracts the first valid `http://` or `https://` link, fetches the page HTML, removes boilerplate elements, and sends the cleaned text to an OpenAI model. The structured JSON summary is then formatted and sent back to the same chat.\n\n## Setup\n1. Connect a Telegram credential to the **Telegram Trigger** and **Send Summary to Telegram** nodes.\n2. Connect an OpenAI credential to the **OpenAI Model** node (use the credential named **OpenAI account**).\n3. Open the **Configuration** node and adjust the variables if needed.\n4. Save and activate the workflow.\n\n## Requirements\n- A Telegram bot credential.\n- An OpenAI API credential with access to `gpt-4o` or `gpt-4o-mini`.\n\n## Customization\n- Change `openai_model` to switch models.\n- Change `max_page_size` to send more or less text to the model.\n- Toggle `include_raw_url_in_prompt` to include or hide the source URL from the AI prompt.\n\nNeed help customizing?\nContact me for consulting and support : [Linkedin](https://www.linkedin.com/in/doctor-firass/)\n\n# MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new YouTube channel](https://www.youtube.com/@DRFIRASS). Here I'll share videos and Shorts with practical tutorials and FREE templates for n8n.\n\n[![The AI Doctor](https://www.dr-firas.com/the-ai-doctor.png)](https://www.youtube.com/@DRFIRASS)"
      },
      "typeVersion": 1
    },
    {
      "id": "92941515-4723-45de-9d8c-e5d1eb312269",
      "name": "Note: Configuration",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 460,
        "height": 572,
        "content": "## Configuration\nSet your summarization preferences here: `openai_model`, `max_page_size`, and `include_raw_url_in_prompt`."
      },
      "typeVersion": 1
    },
    {
      "id": "f8508c5b-0c94-4e9e-966c-f6cb6f7a6118",
      "name": "Note: Input validation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 392,
        "height": 572,
        "content": "## Input validation\nExtract the first URL from the Telegram message and branch on whether it is a valid HTTP/HTTPS link."
      },
      "typeVersion": 1
    },
    {
      "id": "25e85202-12f7-4625-b57d-2aa67e36068f",
      "name": "Note: Webpage extraction",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 680,
        "height": 568,
        "content": "## Webpage extraction\nFetch the page HTML, remove scripts, styles, nav, footer, ads, sidebars, and menus, then prepare the cleaned text."
      },
      "typeVersion": 1
    },
    {
      "id": "09e68e3d-3458-4e48-a6e7-1579f87092f8",
      "name": "Note: AI summarization",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 408,
        "height": 576,
        "content": "## AI summarization\nSend the title and cleaned body to the OpenAI model and parse a structured JSON response."
      },
      "typeVersion": 1
    },
    {
      "id": "243e130e-7b52-4ca4-b8b6-ff7e4f773ec0",
      "name": "Note: Output",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2016,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 404,
        "height": 572,
        "content": "## Output\nFormat the JSON summary as Telegram HTML and reply to the original chat. Errors are also sent back to Telegram."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "41ce9eb9-dcf9-49e1-8940-e34df62aa33f",
  "nodeGroups": [],
  "connections": {
    "URL Valid?": {
      "main": [
        [
          {
            "node": "Fetch Webpage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Invalid URL Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URL": {
      "main": [
        [
          {
            "node": "URL Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Model": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Page",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Configuration": {
      "main": [
        [
          {
            "node": "Extract URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Webpage": {
      "main": [
        [
          {
            "node": "Extract Page Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Summary": {
      "main": [
        [
          {
            "node": "Send Summary to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Page": {
      "main": [
        [
          {
            "node": "Format Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Page Content": {
      "main": [
        [
          {
            "node": "Prepare Summary Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Summary Input": {
      "main": [
        [
          {
            "node": "Summarize Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summary Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Summarize Page",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow listens for Telegram messages containing a URL, fetches and cleans the webpage content, summarizes it with an OpenAI chat model, and replies in the same Telegram chat with a formatted summary including key points and action items. Triggers when a new Telegram…

Source: https://n8n.io/workflows/16936/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.

@Blotato/N8N Nodes Blotato, Google Sheets, OpenAI Chat +9
AI & RAG

RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.

Telegram, Telegram Trigger, OpenAI Chat +8
AI & RAG

Digital marketers, content creators, social media managers, and businesses who want to use AI marketing automation for YouTube Shorts without spending hours on production. This AI workflow helps anyon

OpenAI, HTTP Request, OpenAI Chat +7
AI & RAG

This template is designed for marketers, content creators, and e-commerce brands who want to automate the creation of professional ad videos at scale. It’s ideal for teams looking to generate consiste

Telegram, Telegram Trigger, Google Drive +8
AI & RAG

💥 Automate video ads with NanoBanana, Seedream 4, ChatGPT Image and Veo 3 - VIDE. Uses telegram, telegramTrigger, googleDrive, agent. Event-driven trigger; 63 nodes.

Telegram, Telegram Trigger, Google Drive +8