AutomationFlowsAI & RAG › Telegram AI Agent for Lead Scraping & Research

Telegram AI Agent for Lead Scraping & Research

Original n8n title: Lead Gen Agent (telegram)

ByAbdul Mir @abdulmir on n8n.io

Use your voice or text to command a Telegram-based AI agent that scrapes leads or generates detailed research reports—instantly.

Event trigger★★★★☆ complexityAI-powered20 nodesTool WorkflowAgentOpenAI ChatMemory Buffer WindowTelegramOpenAITelegram Trigger
AI & RAG Trigger: Event Nodes: 20 Complexity: ★★★★☆ AI nodes: yes Added:

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

This workflow follows the Agent → OpenAI Chat 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
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "171159eb-9936-4dbd-94a3-4277799353bc",
      "name": "leadScraping",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        680,
        460
      ],
      "parameters": {
        "name": "leadScraping",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "IPhiwjZXcxi0UDSf",
          "cachedResultName": "Lead Scraping"
        },
        "description": "=Call this tool to scrape leads once you have enough details about the search query. \n\nYour input must be in json like this: \n\n[\n  {\n    \"location\": [\n      \"LOCATION1+HERE\",\n      \"LOCATION2+HERE\",\n      ...\n    ],\n    \"business\": [\n      \"BUSINESS1+HERE\",\n      \"BUSINESS2+HERE\",\n      ...\n    ],\n    \"job_title\": [\n      \"TITLE1+HERE\",\n      \"TITLE2+HERE\",\n      ...\n    ]\n  }\n]",
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b561761a-a725-4b6e-b37f-090563107d24",
      "name": "leadResearch",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        840,
        440
      ],
      "parameters": {
        "name": "leadResearch",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "LAvUyCmqSnNmVrjk",
          "cachedResultName": "Lead Research Agent"
        },
        "description": "Call this tool to research leads. the input should be their linkedin URL in the following format: \n\n{\n\"linkedinURL\": \"[URL-HERE]\"\n}",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "query",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "quer"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2
    },
    {
      "id": "7ad71d24-25fd-4ca8-80c8-3124651ec6cf",
      "name": "Lead Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueErrorOutput",
      "position": [
        520,
        100
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=# Overview \nYou are Sam Ovens, a lead generation agent, responsible for scraping and researching leads. \n\n# Tools \n### leadScraping: \nUse this tool to scrape leads into a Google Sheet. Only call this tool once you have enough information to complete the desired JSON search query. \n\n### leadResearch: \nUse this tool to research a lead by their linkedIn URL. \n\n# Rules:\n- Ask clarifying questions if you're unsure about something. \n- Ask questions to gather enough information to satisfy the query for each of the tools. \n- You should introduce yourself as \"Sam Ovens\" and ask the user what leads they want to scrape today. \n- Always replace spaces with '+' in your search queries. For example, instead of \"los angeles united states\", your query should be \"los+angeles+united+states\". \n- You always need a linkedIn URL to research a lead. \n- You can only research one person at a time. \n- Feel free to be lighthearted and funny.\n- Make sure you always call the tools with correct JSON formatting, but don't wrap the query in ```json```.\n\n# Example \n- Input: \"Hi\" \n- Output: \"Sam Ovens here, the god of B2B outreach. Which leads can I help you scrape today? Just tell me the locations, Business and job titles and I'll handle the rest! \" \n- Input: \"Let's do \\n Locations: \\n - Chicago United States \\n - Sydney Australia \\n\\n Business: \\n - Financial Planners \\n] \n- Output: \"Awesome. I think you forgot the job titles. Which job titles should I search for?\" \n- Input: \"Only CEOs please\" \n- Call leadScrape tool with query: \n\n[\n  {\n    \"location\": [\n      \"chicago+united+states\",\n      \"sydney+australia\"\n    ],\n    \"business\": [\n      \"financial+planner\"\n    ],\n    \"job_title\": [\n      \"ceo\"\n    ]\n  }\n] \n- Input from tool: \"25 new contacts have been added to the Google Sheet!\" \n- Output: \"Done! I've added 25 new contacts to the Google Sheet. Let me know if you need anything else!\" \n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "0d408086-fcd9-4d45-a3f3-8513fc6b3286",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        440,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "db2aefae-bd30-4ec1-8f10-21be6ffc51b7",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        560,
        400
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "5b27c7d7-3b29-4dfa-8ee3-8e6db26683cd",
      "name": "Download File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        0,
        0
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4dedbb6f-1f11-4e9a-a878-e08625674ac8",
      "name": "Transcribe",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        220,
        0
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.6
    },
    {
      "id": "3958a793-f379-4703-aabe-e2d508b1f2c4",
      "name": "Text",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fe7ecc99-e1e8-4a5e-bdd6-6fce9757b234",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "79fc7be1-4af8-440d-aa98-f66ae47884f9",
      "name": "Voice or Text",
      "type": "n8n-nodes-base.switch",
      "position": [
        -220,
        100
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8c844924-b2ed-48b0-935c-c66a8fd0c778",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "4e6e5070-1498-4e92-bd60-a6241f52f309",
      "name": "Response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1000,
        0
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4d8e1de4-a02b-4fa9-ad0e-d57a03ef2aaa",
      "name": "Error Response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1000,
        200
      ],
      "parameters": {
        "text": "={{ $json.error }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5f476e63-4b80-43c4-957d-85261db977b9",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -480,
        100
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f21ff98d-e562-4ab6-9d14-0b675717e8ab",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -640
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 540,
        "content": "## Research Report\n![](https://i.imgur.com/OnzVcDj.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "e70fba28-bcd8-4d34-912f-9a14676c6dee",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 780,
        "height": 540,
        "content": "## Example Output\n![](https://i.imgur.com/q3pN5im.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "55a0f125-836d-45c6-af8b-fa7dbca2337c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -1200
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 540,
        "content": "## Scraping Leads\n![](https://i.imgur.com/qiF5T23.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "345b869b-6150-4d03-8429-fd4fc577573a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -1200
      ],
      "parameters": {
        "color": 5,
        "width": 780,
        "height": 540,
        "content": "## Example Output\n![](https://i.imgur.com/vu7OOqE.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "d27149b2-bfc3-4d4a-a0b6-2414322c8700",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -40
      ],
      "parameters": {
        "color": 6,
        "width": 880,
        "height": 440,
        "content": "## Message Telegram Bot\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4d9b792a-4d43-4702-873e-539ad6c5bf59",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -40
      ],
      "parameters": {
        "color": 6,
        "width": 800,
        "height": 660,
        "content": "## Call Research or Scraping workflow & respond on Telegram\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2e106fbe-506c-4d8c-90a8-2a12fd07a10a",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        440
      ],
      "parameters": {
        "color": 5,
        "width": 440,
        "height": 240,
        "content": "## Hey, I'm Abdul \ud83d\udc4b\n### I build growth systems for consultants & agencies. If you want to work together or need help automating your business, check out my website: \n### **https://www.builtbyabdul.com/**\n### Or email me at **abdul@buildabdul.com**\n### Have a lovely day ;)`"
      },
      "typeVersion": 1
    },
    {
      "id": "8260426e-0e2f-4fbe-9327-8b4248014f70",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -740,
        -1260
      ],
      "parameters": {
        "width": 780,
        "height": 1160,
        "content": "# Ultimate Lead Gen Agent Telegram\n## Overview\nUse your voice or text to command a Telegram-based AI agent that scrapes leads or generates detailed research reports\u2014instantly.\n\nThis workflow turns your Telegram bot into a full-blown outbound machine. Just tell it what type of leads you need, and it\u2019ll use Apollo to find and save them into a spreadsheet. Or drop in a LinkedIn profile, and it\u2019ll generate a personalized research dossier with info like job title, company summary, industry insights, and more. It handles voice messages too\u2014just speak your request and get the results sent back like magic.\n\n### Who\u2019s it for\n- Cold emailers and growth marketers  \n- Solo founders running outbound  \n- SDRs doing daily prospecting  \n- Agencies building high-quality lead lists or custom research for clients  \n\n### How it works\n- Triggered by a message (text or voice) in Telegram  \n- If it\u2019s voice, it transcribes using OpenAI Whisper  \n- Uses an AI agent to interpret intent: scrape leads or research a person  \n- For lead scraping:\n  - Gathers criteria (e.g., location, job title) via Telegram  \n  - Calls the Apollo API to return fresh leads  \n  - Saves the leads to Google Sheets  \n- For research reports:\n  - Takes a LinkedIn profile link  \n  - Uses AI and lead data tools to create a 1-page professional research report  \n  - Sends it back to the user via email\n\n### Example outputs\n- **Lead scraping**: Populates a spreadsheet with names, roles, LinkedIn links, company info, emails, and more  \n- **Research report**: A formatted PDF-style brief with summary of the person, company, and key facts\n\n### How to set up\n1. Connect your Telegram bot to n8n  \n2. Add your OpenAI credentials (for Whisper + Chat agent)  \n3. Plug in your Apollo API key or scraping tool  \n4. Replace the example spreadsheet with your own  \n5. Customize the prompts for tone or data depth  \n6. (Optional) Add PDF generation or CRM sync\n\n### Requirements\n- Telegram Bot Token  \n- OpenAI API Key  \n- Apollo (or other scraping API) credentials  \n- LinkedIn URLs for research functionality\n\n### How to customize\n- Replace Apollo with Clay, People Data Labs, or another scraping tool  \n- Add a CRM push step (e.g. Airtable, HubSpot, Notion)  \n- Add scheduling to auto-scrape daily  \n- Reformat the research report as a downloadable PDF  \n- Change the agent\u2019s tone or role (e.g. \u201cOutreach Assistant,\u201d \u201cInvestor Scout,\u201d etc.)\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Text": {
      "main": [
        [
          {
            "node": "Lead Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lead Agent": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe": {
      "main": [
        [
          {
            "node": "Lead Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "leadResearch": {
      "ai_tool": [
        [
          {
            "node": "Lead Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "leadScraping": {
      "ai_tool": [
        [
          {
            "node": "Lead Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Transcribe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Lead Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Voice or Text": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Voice or Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Lead Agent",
            "type": "ai_languageModel",
            "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

Use your voice or text to command a Telegram-based AI agent that scrapes leads or generates detailed research reports—instantly.

Source: https://n8n.io/workflows/6532/ — 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

BoomerBobBot.TP. Uses agent, telegramTrigger, telegram, memoryBufferWindow. Event-driven trigger; 95 nodes.

Agent, Telegram Trigger, Telegram +10
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

Jarvis is a powerful multi-agent productivity assistant built in n8n. It works directly from Telegram and can understand both text messages and voice notes.

Telegram Trigger, Telegram, OpenAI +10
AI & RAG

Unlock the Power of Language with Personalized AI Learning! MOTION TUTOR is a revolutionary AI-powered language learning platform that adapts to your progress and guides you from basic vocabulary to c

Agent, Airtable Tool, OpenAI Chat +6
AI & RAG

Automate your personal productivity with this intelligent n8n workflow that integrates Telegram, Google Sheets, and OpenAI (GPT-4o). This system uses multiple AI agents to manage work hours, tasks, fi

Agent, OpenAI Chat, Telegram +9