# Generate B2B Leads with SerpAPI: n8n workflow template

> Started by an event in a connected app, and works across Google Sheets. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/generate-b2b-leads-with-serpapi (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Lead generation](https://millionrounds.com/workflows?category=Lead+generation#library)

# Generate B2B Leads with SerpAPI

Started by an event in a connected app, and works across Google Sheets. It hands the judgement calls to OpenAI. 38 steps, 5 branches, 2 loops or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgenerate-b2b-leads-with-serpapi)

**38 steps** Large: read it before trusting it with anything live

**5** Branches: places the flow splits

**2** Loops or waits

**1** Service it connects to

## The flow

Starts it 1 Model 3 Logic 19 Service 15

The steps in the order they run, from what starts it.

- 1 **When clicking ‘Execute workflow’** Manual trigger *Starts it*
- 2 **Edit Fields** Set *Logic*
- 3 **Compute search key** Code *Logic*
- 4 **Upsert search key** Google Sheets *Service*
- 5 **Get row(s) in sheet** Google Sheets *Service*
- 6 **If template exists** If *Logic*
- 7 **Turn into search terms** Code *Logic*
- 8 **Generate SerpAPI query** Open Ai *Model*
- 9 **Verify and limit query amount** Limit *Logic*
- 10 **Add template** Google Sheets *Service*
- 11 **SerpApi Request** Http Request *Service*
- 12 **Extract items** Code *Logic*
- 13 **Increment run count by 1** Google Sheets *Service*
- 14 **Result validations** Open Ai *Model*
- 15 **Merge** Merge *Logic*
- 16 **Filter out non-matching websites** Filter *Logic*
- 17 **Collect the domains** Code *Logic*
- 18 **Instantly, Get List** Http Request *Service*
- 19 **If list exists** If *Logic*
- 20 **Extract list ID** Set *Logic*
- 21 **Instantly Lead List, Create** Http Request *Service*
- 22 **Merge SS query and List ID** Merge *Logic*
- 23 **Get row** Google Sheets *Service*
- 24 **If lead list exists** If *Logic*
- 25 **If seach filters exist** If *Logic*
- 26 **Instantly Lead List, Create temporary** Http Request *Service*
- 27 **Instantly SuperSearch, Create** Http Request *Service*
- 28 **Parse search filters to json** Code *Logic*
- 29 **Generate search filters** Open Ai *Model*
- 30 **Instantly SuperSearch, Create2** Http Request *Service*
- 31 **Add search filters** Google Sheets *Service*
- 32 **Instantly, Move Leads to Master List** Http Request *Service*
- 33 **Loop for 5 times** Code *Logic*
- 34 **Loop Over Items** Split In Batches *Logic*
- 35 **Wait 15s** Wait *Logic*
- 36 **Instantly, Check Move Job** Http Request *Service*
- 37 **If move succeeded** If *Logic*
- 38 **Instantly, Delete Temp Lead List** Http Request *Service*

## How it's built

- **Starts on:** An event in a connected app
- **Steps:** 38, with 5 branches, 2 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Sheets
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Google Sheets account, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an event in a connected app.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 38 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 38 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgenerate-b2b-leads-with-serpapi)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)

## Workflows like it

Also lead generation, with the same services where possible, closest in size first.

- [**Enrich leads from Google Sheets with ScraperCity** 38 steps · Google Sheets](https://millionrounds.com/workflow/enrich-leads-from-google-sheets-with-scrapercity)
- [**Automated website audit & personalized outreach** 39 steps · calls a model · Google Sheets](https://millionrounds.com/workflow/automated-website-audit-and-personalized-outreach)
- [**Capture and score multi-channel leads with Gmail** 39 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/capture-and-score-multi-channel-leads-with-gmail)
- [**Speed-to-Lead AI Response Engine for WhatsApp, Web Forms** 37 steps · Email, Google Sheets](https://millionrounds.com/workflow/speed-to-lead-ai-response-engine-for-whatsapp-web-forms)
- [**Speed-to-Lead AI Response Engine for WhatsApp, Web Forms, Chat** 37 steps · Email, Google Sheets](https://millionrounds.com/workflow/speed-to-lead-ai-response-engine-for-whatsapp-web-forms-chat)
- [**Scrape & analyze Google Ads with Bright Data API** 36 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/scrape-and-analyze-google-ads-with-bright-data-api)
