This guide will show you how to build a powerful, AI-powered lead generation agent that delivers verified leads — complete with emails, job titles, and LinkedIn profiles — directly to your Google Sheet.

We’ll use the intuitive, no-code automation platform n8n, integrating cutting-edge tools like Telegram and OpenAI.
This comprehensive, step-by-step process requires zero coding skill and will fundamentally change how your business handles prospecting.
Part 1: Setting Up the n8n Automation Ecosystem
Our AI agent lives inside the n8n platform. As a powerful, open-source automation tool, n8n allows us to connect Telegram, Google Sheets, and specialized scraping tools into one seamless workflow.
Step 1.1: Securing Your n8n Hosting Solution
Before building, you need a running instance of n8n. You have three main options for hosting:
- Self-Hosted (Local): Free, but requires technical know-how to set up and maintain on your own machine.
- Managed Hosting (Recommended): Services like Webspace Kit (WSK) offer a low-cost, quick-setup environment with benefits like unlimited workflows and executions, which are essential for high-volume lead generation.
- n8n Cloud: The official platform, offering simplicity but often with higher costs and more limited feature tiers compared to self-hosting options.
For most users seeking maximum benefit at a reasonable cost, a managed hosting solution like WSK is the ideal starting point. Complete the setup and log in to your fresh n8n dashboard.
Step 1.2: Importing the Pre-Built Workflow Template
To accelerate the build process and avoid manually creating hundreds of connections, we will import a ready-made template for the AI Lead Agent.
- Download the Template Files: Obtain the main workflow file and the sub-workflow file (usually provided in the tutorial resources).
- Import the Main Workflow: In the n8n dashboard, select the option to create a new workflow, then use the menu to Import from File. Upload the main workflow file.
- Initial Inspection: The workflow will appear, populated with nodes for Telegram, OpenAI, and Google Sheets. You will notice warning signs on several nodes — this indicates they need to be linked to your personal accounts and API keys.
Part 2: Configuring the Core AI Communication Engine
This section connects our agent to the communication channel (Telegram) and provides it with the intelligence (OpenAI) needed to understand complex requests.
Step 2.1: Integrating Telegram as the Agent Interface
Telegram will be the primary command center where you send voice or text messages to trigger the lead search.
- Create Your Telegram Bot:
Open Telegram and search for the official account @BotFather.
Send the command /newbot
.
Follow the prompts to choose a user-friendly display name (e.g., “Ultimate Lead Assistant”) and a unique username that must end with _bot
(e.g., UltimateLeadAssistant_bot
).
2. Secure the API Key: BotFather will instantly generate a unique API Token. Copy this token immediately.
3. Connect the n8n Node: Open the Telegram Trigger node in your n8n workflow. Create new credentials, paste the API Token, and save.
4. Synchronize Nodes: Ensure all other Telegram nodes (like the Reply nodes) within the workflow are updated to use the new credentials you just saved.
Step 2.2: Empowering the Agent with OpenAI Intelligence
The OpenAI API provides the power for both conversational intelligence and voice transcription.
OpenAI API Key Acquisition:
- Log in to your OpenAI platform dashboard.
- Generate a new secret API key.
- Crucial Note: OpenAI operates on a pay-as-you-go model. You must have a payment method on file to generate and use an API key, even though charges are minimal and based strictly on usage.
Connecting the Transcribe Node (Optional): If you plan to send voice commands (highly recommended for speed), open the Transcribe Node. Create new credentials, paste your OpenAI API key, and save. This node uses OpenAI’s speech-to-text service to convert voice recordings into text queries.
Configuring the Lead Agent Node (The Brain):
- Open the main Lead Agent node. This is the System Prompt that governs the AI’s behavior.
- Review and Refine: Examine the instructions. This is where you tell the AI exactly what information to extract from your requests (e.g., job title, industry, geographic location) and how it should format its response. Customize this prompt to fit your specific lead criteria.
- Memory Management: Adjust the “Simple Memory” setting to specify how many past messages the agent should remember to maintain conversational context.
Part 3: Building the Data Scraping and Storage Pipeline
The final part involves setting up a dedicated sub-workflow for the heavy lifting: scraping the data and saving it to your spreadsheet.
Step 3.1: Importing and Understanding the Lead Scraper Sub-Workflow
- Import the Sub-Workflow: In the main n8n workflow, navigate to the sub-workflow component and import the secondary template file.
- Workflow Review: The sub-workflow typically consists of nodes that handle:
- Receiving the structured data (title, location, industry) from the main AI agent.
- Formulating a precise search query URL.
- Executing the lead scraping tool.
- Filtering the resulting data.
- Saving the final list to Google Sheets.
Step 3.2: Connecting the Specialized Lead Scraper (Apify Integration)
The workflow relies on a powerful data extraction tool, such as the Upload Scraper available on platforms like Apify.
- Access Apify: Sign up or log in to the Apify platform.
- Rent the Scraper: Locate and activate the Upload Scraper tool. Many scrapers offer a short free trial, but be aware of the recurring rental cost for continuous use.
- Obtain the Apify API Key: Navigate to your Apify API endpoints section. Copy your unique API Token.
- Connect the n8n Scraper Node: Open the Upload Scraper Node in the n8n sub-workflow. Paste the Apify API Token into the required field and save the credentials.
Step 3.3: Finalizing the Google Sheets Destination
This step ensures your valuable data is saved in a viewable, sharable, and organized format.
- Prepare Google Sheet: Create a new, blank Google Sheet and name it (e.g., “AI Lead Generation Master List”). This will be your destination document.
- Enable Google Sheets API: Go to the Google Cloud Console. Create a new project for this workflow. Search for and enable the Google Sheets API.
- Create OAuth Credentials:
- In the Google Cloud Console, navigate to the OAuth Consent Screen. Configure the app details.
- Under Credentials, create an OAuth Client ID of type Web Application.
- Crucial Redirect URL: In the n8n Google Sheets node, copy the Redirect URL provided. Paste this exact URL into the Google Cloud Console’s Authorized Redirect URIs field.
- Copy and Paste: Copy the resulting Client ID and Client Secret and paste them into the corresponding fields in the n8n Google Sheets node.
4. Final Authorization: Sign in to Google through n8n, granting the necessary permissions for n8n to access and edit your Google Sheets.
5. Target Selection: In the n8n Google Sheets node, select the Document and Sheet you created in step 1. Select the option to Map Automatically to align the scraped fields with your spreadsheet columns.
Conclusion: Activating Your Automated Prospecting Powerhouse
You have now successfully configured one of the most powerful automated lead generation systems available.
- Save and Activate: Ensure you save both the main workflow and the sub-workflow. Toggle the switch to Activate the main workflow.
- Start the Bot: Open Telegram and send the command
/start
to your newly created bot to ensure the connection is live. - Test Your Agent: Send a query to your bot, either via text or voice.
Example Query to Maximize Results:
“Find 50 highly-qualified leads for Senior Sales Director roles in the SaaS industry based in San Francisco, California.
Within moments, the AI will process the command, execute the scraping sub-workflow, and reply with a confirmation that the data has been added. Check your Google Sheet, and you will find a list of fresh, verified, and qualified leads — ready for outreach.
Go ahead and put your AI agent to work.
0 Comments