Opening Problem Statement
Meet Alex, a sales development representative at a growing SaaS company. Every week, Alex spends countless hours manually searching for promising companies on LinkedIn, filtering through thousands of profiles to identify potential clients that might benefit from their CRM implementation services. This tedious process is often riddled with errors, duplicates, and outdated information, causing Alex to waste valuable time and lose promising leads.
Alex’s frustration mounts as the team misses targets because they aren’t consistently identifying the best-fit companies early enough. On average, manual prospecting consumes over 10 hours weekly, which could be better spent nurturing actual leads or closing sales. Without automation, lead quality dips and valuable opportunities slip through the cracks.
What This Automation Does
This n8n workflow solves Alex’s problem by automating the LinkedIn company search, enriching company data, scoring leads via AI, and managing the results efficiently in a Google Sheets CRM. Specifically, when running this workflow, it:
- Searches LinkedIn companies matching your customized criteria—such as industry, location, and company size—using the Ghost Genius API.
- Retrieves detailed company information, including website, follower count, industry, and specialties.
- Filters out companies lacking a website or with fewer than 200 LinkedIn followers to ensure lead quality.
- Checks for duplicates in the Google Sheets CRM by LinkedIn company ID to prevent redundant entries.
- Uses OpenAI’s AI capabilities to score companies based on relevance and fit to your product or service, considering positive and negative business indicators.
- Appends newly qualified companies with their AI-generated score directly into the Google Sheets CRM, maintaining an organized and enriched prospect list.
By automating these steps, Alex saves approximately 8-10 hours weekly while dramatically improving lead relevance and organization.
Prerequisites ⚙️
- n8n account (self-hosting possible for more control and scalability) 🔌
- Ghost Genius API account for LinkedIn company searches 🔑
- Google Sheets account with access to the CRM spreadsheet 📊
- OpenAI account with API key for AI company scoring 🔐
Step-by-Step Guide
1. Set Your Target Variables
Navigate to the “Set Variables” node. Here, you’ll enter your targeting parameters such as your ideal company type (e.g., Growth Marketing Agency), location (using a city or country ID from Ghost Genius’s location finder), and your product or service description (e.g., CRM implementation services). You also specify positive and negative indicators for your AI scoring model. For example, positive indicators might include companies mentioning challenges with sales processes or marketing automation needs.
Expected Outcome: Variables are set to tailor searches and AI prompts to your specific sales goals.
Common Mistake: Leaving any variable blank can lead to ineffective searches or scoring later.
2. Trigger the Workflow Manually
Start the n8n workflow manually using the “Start” manual trigger. This initiates the automation from the beginning with your preset variables.
Expected Outcome: The workflow proceeds to search LinkedIn companies using Ghost Genius API.
Common Mistake: Forgetting to press start after updates, so changes aren’t tested.
3. Search Companies via Ghost Genius API
The “Search Companies” HTTP Request node queries the Ghost Genius API, searching LinkedIn companies based on your variables. Pagination is enabled to fetch multiple pages but limited to three for testing purposes. The node uses Header Authentication with your API key.
HTTP Request Details:
Method: GET
URL: https://api.ghostgenius.fr/v2/search/companies
Query Parameters: keywords (target industry), locations (location ID), company_size (size category)
Authentication: Bearer Token in headers.
Expected Outcome: You receive a batch of companies matching your criteria.
Common Mistake: Incorrect API keys or rate limit exceeding can cause failures.
4. Extract and Split Company Data
The “Extract Company Data” node splits the batch response into individual company items for processing.
Expected Outcome: Subsequent nodes can handle companies one by one.
5. Process Each Company with Batching
Using the “Process Each Company” SplitInBatches node, the workflow processes one company at a time with a two-second delay to avoid API throttling.
Expected Outcome: Reliable and sequential data handling preventing API overload.
6. Get Detailed Company Info
The “Get Company Info” node calls Ghost Genius API to fetch detailed information about each company using its LinkedIn URL. This includes website, followers count, and industry specifics.
Expected Outcome: Rich company profiles to analyze.
Common Mistake: Missing or malformed URLs lead to empty results.
7. Filter Valid Companies
The “Filter Valid Companies” IF node removes companies without websites or those with LinkedIn followers fewer than 200 to ensure quality leads.
Expected Outcome: Only credible and potentially valuable companies proceed onward.
8. Check If Company Already Exists
The “Check If Company Exists” Google Sheets node searches your CRM for a company using its LinkedIn ID to prevent duplicate entries.
Expected Outcome: Companies already in your CRM won’t be added again.
9. AI Company Scoring
If the company is new, the “AI Company Scoring” node uses OpenAI GPT-4.1 to rate the company’s likelihood to need your CRM services from 0 to 10. The scoring is done via a custom prompt configured in the “Set Variables” step, ensuring it aligns with your positive and negative indicators.
{
"score": 8
}Expected Outcome: Numerical score helps prioritize leads.
Common Mistake: Poorly set indicators degrade score accuracy.
10. Wait 2 Seconds to Respect API Limits
To avoid hitting Google Sheets API limits, the workflow pauses for 2 seconds using the “Wait 2s” node before adding data to the sheet.
11. Add Company to Google Sheets CRM
The “Add Company to CRM” Google Sheets node appends the company details and AI score to your CRM spreadsheet under the “Companies” sheet.
Expected Outcome: Up-to-date and enriched CRM records.
12. Loop Back to Process Next Company
The workflow loops back to the batch processor to continue until all companies are handled.
Customizations ✏️
- Adjust Company Size Filter: In the “Set Variables” node, change the value of
B: 1-10 employees, C: 11-50 employees, etc.to target different company sizes relevant to your product. - Change Follower Threshold: Modify the “Filter Valid Companies” IF node to increase or decrease the minimum LinkedIn follower count to better filter lead quality.
- Customize AI Scoring Prompt: Edit the “Set Variables” node ‘Positive indicators’ and ‘Negative indicators’ fields to finely tune how the AI evaluates company fit.
- Switch CRM Storage: Replace the Google Sheets nodes with Airtable or another CRM via their API if preferred.
- Expand Pagination: Adjust the “Search Companies” node pagination settings to pull more results if needed, but respect API limits.
Troubleshooting 🔧
- Problem: “HTTP Request failed with status 401 Unauthorized”
Cause: Incorrect or expired Ghost Genius API key.
Solution: Reenter the API key in your HTTP header authentication credentials and verify the key is active. - Problem: “Google Sheets append operation failed due to quota limits”
Cause: API request limit exceeded.
Solution: Increase the wait time in the “Wait 2s” node or optimize batch sizes to avoid hitting limits. - Problem: AI Scores unrelated or off-topic
Cause: Insufficiently specific AI prompts or inaccurate indicator definitions.
Solution: Refine your “Set Variables” entries and test with multiple company examples.
Pre-Production Checklist ✅
- Verify Ghost Genius API key is active and header credentials properly configured.
- Make a copy of the Google Sheets CRM and connect your Google Sheets OAuth2 credentials in n8n.
- Ensure OpenAI API key is valid and linked to the AI Company Scoring node.
- Run test searches with limited pagination to validate company retrieval.
- Check for duplicates by searching existing CRM entries manually before full runs.
- Review AI scoring outputs for consistency with expectations.
Deployment Guide
Activate the workflow by toggling it in n8n once all credentials and variables are set. Since this workflow handles rate limits with batch processing and waits, you can run it regularly—daily or weekly depending on your prospecting needs —using n8n’s Cron node or manually trigger it as desired.
Monitor executions via n8n’s built-in logs to catch any runtime errors. Regularly back up your Google Sheets CRM data to prevent loss.
Conclusion
By implementing this tailored n8n workflow, Alex has fully automated the LinkedIn lead prospecting process with intelligent AI scoring and seamless Google Sheets CRM integration. This reduces manual effort by nearly 90%, improves the quality and consistency of leads, and ultimately accelerates sales opportunities.
Next steps to consider include integrating email outreach automation, syncing CRM data with other sales tools, or expanding AI scoring criteria for even smarter lead prioritization.
With this setup, you too can turn hours of tedious research into minutes of targeted, actionable lead data — setting yourself up for more effective sales success.