# AI sales agent: fully email handling & lead scoring system: n8n workflow

> Started by a clock, and works across Gmail and NocoDB. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/ai-sales-agent-fully-email-handling-and-lead-scoring-system (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)

# AI sales agent: fully email handling & lead scoring system

Started by a clock, and works across Gmail and NocoDB. It hands the judgement calls to OpenAI. 57 steps, 4 branches, 3 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%2Fai-sales-agent-fully-email-handling-and-lead-scoring-system)

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

**4** Branches: places the flow splits

**3** Loops or waits

**2** Services it connects to

## The flow

Starts it 4 Model 3 Logic 23 Service 27

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

- 1 **Daily Trigger** Cron *Starts it*
- 2 **Hourly Trigger** Cron *Starts it*
- 3 **Gmail Webhook** Gmail trigger *Starts it*
- 4 **Brevo Event** Send In Blue trigger *Starts it*
- 5 **Get All Active Leads** Noco Db *Service*
- 6 **Get Top 10 Leads** Noco Db *Service*
- 7 **Parse Response Data** Code *Logic*
- 8 **Parse Event Data** Code *Logic*
- 9 **Process in Batches** Split In Batches *Logic*
- 10 **Loop Over Leads** Split In Batches *Logic*
- 11 **Find Lead by Email** Noco Db *Service*
- 12 **Find Lead** Noco Db *Service*
- 13 **Collect All Results** Aggregate *Logic*
- 14 **Calculate Score Decay** Code *Logic*
- 15 **Get Product Info** Noco Db *Service*
- 16 **Get Previous Correspondance** Noco Db *Service*
- 17 **Get Current Template** Noco Db *Service*
- 18 **AI Intent Classification** Open Ai *Model*
- 19 **Lead Found?** If *Logic*
- 20 **Generate Analytics Report** Code *Logic*
- 21 **Update Lead Scores** Noco Db *Service*
- 22 **All Products** Aggregate *Logic*
- 23 **All Correspondance** Aggregate *Logic*
- 24 **Current Template** Aggregate *Logic*
- 25 **Route By Response Type** Switch *Logic*
- 26 **Log Engagement Event** Noco Db *Service*
- 27 **Send a message** Gmail *Service*
- 28 **Needs Re-engagement?** If *Logic*
- 29 **Merge** Merge *Logic*
- 30 **Lead Pending Review** Noco Db *Service*
- 31 **Lead Unsubscribed** Noco Db *Service*
- 32 **Lead Out Of Office** Noco Db *Service*
- 33 **Get Previous Exchange** Noco Db *Service*
- 34 **Get All Products** Noco Db *Service*
- 35 **Calculate Score Update** Code *Logic*
- 36 **Store Analytics** Noco Db *Service*
- 37 **Schedule Re-engagement** Noco Db *Service*
- 38 **Aggregate** Aggregate *Logic*
- 39 **Create Manual Review** Noco Db *Service*
- 40 **All Exchanges** Aggregate *Logic*
- 41 **Aggregated Products** Aggregate *Logic*
- 42 **Update Lead Engagement** Noco Db *Service*
- 43 **Set Outreach Variables** Set *Logic*
- 44 **Notify Sales Team** Gmail *Service*
- 45 **Merge1** Merge *Logic*
- 46 **Special Action Needed?** If *Logic*
- 47 **Generate Personalized Email** Open Ai *Model*
- 48 **Aggregate For Response** Aggregate *Logic*
- 49 **Delete a row** Noco Db *Service*
- 50 **Send Initial Outreach Email** Http Request *Service*
- 51 **Generate AI Response** Open Ai *Model*
- 52 **Log Outreach** Noco Db *Service*
- 53 **Natural Response Delay** Wait *Logic*
- 54 **Update Lead Status** Noco Db *Service*
- 55 **Send AI Response** Gmail *Service*
- 56 **Log Interaction** Noco Db *Service*
- 57 **Update Lead Score** Noco Db *Service*

## How it's built

- **Starts on:** A clock
- **Steps:** 57, with 4 branches, 3 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, NocoDB
- **Model:** OpenAI

## Questions

What does it need to run?

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

What starts it?

It starts on a clock.

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 57 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 57 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%2Fai-sales-agent-fully-email-handling-and-lead-scoring-system)
- **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.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[NocoDB](https://millionrounds.com/workflows?service=NocoDB#library)

## Workflows like it

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

- [**End-to-end B2B real estate lead enrichment & outreach** 58 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/end-to-end-b2b-real-estate-lead-enrichment-and-outreach)
- [**Smart email outreach sequence – AI-powered & customizable** 56 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/smart-email-outreach-sequence-ai-powered-and-customizable)
- [**Gmail Cold Email Sequence with Google Sheets Tracking** 55 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/gmail-cold-email-sequence-with-google-sheets-tracking)
- [**Local business leads and run AI-powered cold email sequences** 62 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/local-business-leads-and-run-ai-powered-cold-email-sequences)
- [**Run a full lead-to-meeting pipeline with Google Sheets** 52 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/run-a-full-lead-to-meeting-pipeline-with-google-sheets)
- [**Automate product Hunt lead generation with Apify** 49 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/automate-product-hunt-lead-generation-with-apify)
