{
  "id": "demo_workflow_id",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Comprehensive Reuters News Intelligence System With Brightdata & Telegram Alerts",
  "tags": [],
  "nodes": [
    {
      "id": "cab6b73a-d522-47b1-b0af-6732358a5798",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -660,
        0
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "Claude 4 Sonnet"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2e9f25b0-5ffb-4d2e-a848-fc2b0958ade3",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -400,
        20
      ],
      "parameters": {
        "url": "https://api.brightdata.com/datasets/v3/trigger",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('JSON', `This HTTP POST request sends the user's chat input (like \"Election\") to the BrightData Reuters News collector. The collector uses this input to create a new scraping snapshot based on the keyword. The request body includes a sessionId, action, and chatInput, and the response will return a snapshot_id which will be used in the next steps to fetch the scraped data. \n[\n  {\n    \"keyword\": \"Gas shocks\",\n    \"sort\": \"newest\"\n  }\n]`, 'json') }}",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "dataset_id",
              "value": "gd_lyptx9h74wtlvpnfu"
            },
            {
              "name": "include_errors",
              "value": "true"
            },
            {
              "name": "type",
              "value": "discover_new"
            },
            {
              "name": "discover_by",
              "value": "keyword"
            },
            {
              "name": "limit_per_input",
              "value": "2"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c8190def-19a1-4d93-a3c5-1c0939404d6b",
      "name": "Check Scraping Status",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -120,
        60
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `use snapshot id to create http request url \nfor example:\nhttps://api.brightdata.com/datasets/v3/progress/your_snapshot_id`, 'string') }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            }
          ]
        },
        "toolDescription": "Makes an HTTP request to check the status of snapshot_id and returns the status like \"ready\" or \"running\". If the status received is \"running\", then make another HTTP request.",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "51df9a2a-677b-4e6c-a3c6-2b7a55f9f266",
      "name": "Fetch Snapshot Data",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        200,
        80
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `make http request URL with snapshot_id \nfor example:\nhttps://api.brightdata.com/datasets/v3/snapshot/your_snapshot_id`, 'string') }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            }
          ]
        },
        "toolDescription": "Makes an HTTP request when snapshot_id is in ready status and returns the response data",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "13a0c262-7ff5-4e34-8e92-f27cbc1c7f9a",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -700,
        -300
      ],
      "parameters": {
        "options": {},
        "formTitle": "Reuters News Intelligence",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Keywords",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "News Type",
              "fieldOptions": {
                "values": [
                  {
                    "option": "newest"
                  },
                  {
                    "option": "oldest"
                  },
                  {
                    "option": "relevance"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "89648837-569a-4bbe-85e8-f91a7b7bad48",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        200,
        -300
      ],
      "parameters": {
        "text": "={{ $json.article_url }}{{ $json.heading }}{{ $json.description }}{{ $json.content }}",
        "chatId": "DEMO_CHAT_ID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "07b29eb4-7241-436d-a2cc-a966726a8890",
      "name": "sleep tool",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        440,
        0
      ],
      "parameters": {
        "jsCode": "await new Promise(resolve => setTimeout(resolve, 60 * 1000));\n\nreturn \"1 minute wait done\";",
        "description": "Call this tool before checking snapshot_id status."
      },
      "typeVersion": 1.2
    },
    {
      "id": "499deea0-4b84-4a13-9012-f62027c5771a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -380
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 240,
        "content": "Trigger node that starts the workflow when a form is submitted with \"Keywords\" and \"News Type\"."
      },
      "typeVersion": 1
    },
    {
      "id": "3dea92a2-dbd0-42b1-92e4-4b9cc5bc37bc",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -760,
        -100
      ],
      "parameters": {
        "color": 6,
        "width": 260,
        "height": 220,
        "content": "Sends the input to Claude (Anthropic's LLM) for language-based processing or prompt handling."
      },
      "typeVersion": 1
    },
    {
      "id": "589e68d2-5a78-41fc-957a-2952510cca4b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        -380
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 240,
        "content": "Uses LangChain's AI agent to orchestrate actions based on the input and other node outputs."
      },
      "typeVersion": 1
    },
    {
      "id": "b6e0daec-5f83-4abd-8910-828f1d87218f",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        -60
      ],
      "parameters": {
        "width": 220,
        "height": 220,
        "content": "Sends a request to BrightData to trigger a new Reuters news scraping snapshot by keyword."
      },
      "typeVersion": 1
    },
    {
      "id": "3f7f75c2-6923-4bcf-8561-ba5797a0feaf",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 220,
        "content": "Verifies if the BrightData snapshot has finished processing and is ready to be fetched."
      },
      "typeVersion": 1
    },
    {
      "id": "26841dd7-e136-44bf-b0b3-6e7eee2499dc",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        0
      ],
      "parameters": {
        "color": 3,
        "height": 220,
        "content": "Retrieves the actual data (articles) from BrightData once the snapshot is ready."
      },
      "typeVersion": 1
    },
    {
      "id": "dbbf1a00-115b-4753-b4e7-6713185b0788",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -380
      ],
      "parameters": {
        "color": 5,
        "height": 240,
        "content": "JavaScript code node to extract, clean, and structure only the required article fields."
      },
      "typeVersion": 1
    },
    {
      "id": "552878fd-455d-4c8d-92ce-df00167b955f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -380
      ],
      "parameters": {
        "height": 240,
        "content": "Sends the final cleaned news article data to a specified Telegram chat."
      },
      "typeVersion": 1
    },
    {
      "id": "835f1987-d44a-47aa-aed8-c90e95266b80",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -60
      ],
      "parameters": {
        "color": 4,
        "height": 220,
        "content": "Waits for 1 minute before checking again to ensure snapshot has time to complete."
      },
      "typeVersion": 1
    },
    {
      "id": "a644da6d-31a1-4231-a57e-d859f4a03b2b",
      "name": "MCP for Data Fetching through Anthropic",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -440,
        -300
      ],
      "parameters": {
        "text": "=Scrape the latest Reuters news articles based on the keyword: \"{{ $json.Keywords }}\".\nNews Type:\"{{ $json['News Type'] }}\"\nFor each matching article, return the following details in the output JSON:\n\narticle_title: The title of the article\n\nheadline: The headline shown on Reuters site\n\ndescription: The short summary or meta description of the article\n\ncontent: The full article content/body text\n\narticle_url: The full URL to the article\n\nNote:- Make sure there is no duplication and that each field is clean and readable.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "f2858466-d520-411f-aebf-44aee942be5b",
      "name": "Data Formatting",
      "type": "n8n-nodes-base.code",
      "position": [
        -60,
        -300
      ],
      "parameters": {
        "jsCode": "// Step 1: Raw scraped response\nconst rawOutput = $json[\"output\"];\n\n// Step 2: Extract the JSON array part from within triple backticks ```json ... ```\nconst matches = rawOutput.match(/```json\\s+([\\s\\S]*?)\\s+```/);\n\nif (!matches || matches.length < 2) {\n  throw new Error(\"Could not find JSON block in output\");\n}\n\nconst articles = JSON.parse(matches[1]);\n\n// Step 3: Map and clean only the required fields\nconst cleanedArticles = articles.map(article => ({\n  heading: article.headline || article.article_title || \"\",\n  article_url: article.article_url || \"\",\n  description: article.description || \"\",\n  content: article.content || \"\"\n}));\n\n// Step 4: Return cleaned articles as individual items\nreturn cleanedArticles.map(item => ({ json: item }));\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "demo_version_id",
  "connections": {
    "sleep tool": {
      "ai_tool": [
        [
          {
            "node": "MCP for Data Fetching through Anthropic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "MCP for Data Fetching through Anthropic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Data Formatting": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "MCP for Data Fetching through Anthropic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Snapshot Data": {
      "ai_tool": [
        [
          {
            "node": "MCP for Data Fetching through Anthropic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "MCP for Data Fetching through Anthropic",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check Scraping Status": {
      "ai_tool": [
        [
          {
            "node": "MCP for Data Fetching through Anthropic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "MCP for Data Fetching through Anthropic": {
      "main": [
        [
          {
            "node": "Data Formatting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}