# Automate personalized cold email sequences with Mailgun: n8n workflow

> Started by an incoming Telegram message, and works across Apify, Postgres, Supabase and Telegram.

Source: https://millionrounds.com/workflow/automate-personalized-cold-email-sequences-with-mailgun (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)

# Automate personalized cold email sequences with Mailgun

Started by an incoming Telegram message, and works across Apify, Postgres, Supabase and Telegram. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 84 steps, 8 branches, 12 loops or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomate-personalized-cold-email-sequences-with-mailgun)

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

**8** Branches: places the flow splits

**12** Loops or waits

**4** Services it connects to

## The flow

Starts it 5 Model 10 Logic 35 Service 10

The steps in the order they run, from what starts it. The first 60 of 84.

- 1 **Schedule Trigger1** Schedule trigger *Starts it*
- 2 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 3 **Structured Output Parser** Output Parser Structured *Model*
- 4 **Schedule Trigger3** Schedule trigger *Starts it*
- 5 **Schedule Trigger4** Schedule trigger *Starts it*
- 6 **Schedule Trigger6** Schedule trigger *Starts it*
- 7 **OpenAI Chat Model1** Lm Chat Open Ai *Model*
- 8 **Simple Memory** Memory Buffer Window *Model*
- 9 **User message** Telegram trigger *Starts it*
- 10 **Structured Output Parser1** Output Parser Structured *Model*
- 11 **Supabase2** Supabase *Service*
- 12 **create email sequence** Agent *Model*
- 13 **Get many rows** Supabase *Service*
- 14 **Supabase11** Supabase *Service*
- 15 **Supabase13** Supabase *Service*
- 16 **Scraper agent** Agent *Model*
- 17 **Voice or Text1** Switch *Logic*
- 18 **Sort2** Sort *Logic*
- 19 **Code** Code *Logic*
- 20 **If3** If *Logic*
- 21 **Evualute when the mail was sent** Code *Logic*
- 22 **Evualute when the mail was sent1** Code *Logic*
- 23 **Generate query payload** Set *Logic*
- 24 **Select already scraped mails** Postgres *Service*
- 25 **Download File1** Telegram *Service*
- 26 **Text1** Set *Logic*
- 27 **If2** If *Logic*
- 28 **Merge** Merge *Logic*
- 29 **Sort1** Sort *Logic*
- 30 **No Operation, do nothing** No Op *Logic*
- 31 **If1** If *Logic*
- 32 **If** If *Logic*
- 33 **Create URL** Code *Logic*
- 34 **Keep only the new leads** Compare Datasets *Service*
- 35 **Transcribe1** Open Ai *Model*
- 36 **Limit1** Limit *Logic*
- 37 **No Operation, do nothing2** No Op *Logic*
- 38 **Time Zone** Code *Logic*
- 39 **Limit** Limit *Logic*
- 40 **Sort** Sort *Logic*
- 41 **No Operation, do nothing1** No Op *Logic*
- 42 **Sort3** Sort *Logic*
- 43 **No Operation, do nothing4** No Op *Logic*
- 44 **Run an Actor** Apify *Service*
- 45 **Already scraped** No Op *Logic*
- 46 **Create rows with new leads** Supabase *Service*
- 47 **Switch** Switch *Logic*
- 48 **Sender Email** Code *Logic*
- 49 **research about company** Open Ai *Model*
- 50 **Limit2** Limit *Logic*
- 51 **Limit4** Limit *Logic*
- 52 **Extract Info** Set *Logic*
- 53 **Set Telegram message** Set *Logic*
- 54 **Loop Over Items** Split In Batches *Logic*
- 55 **Loop Over Items1** Split In Batches *Logic*
- 56 **Your leads table** Supabase *Service*
- 57 **General anlysis** Open Ai *Model*
- 58 **Switch5** Switch *Logic*
- 59 **Switch6** Switch *Logic*
- 60 **Only Keep Verified Emails** Filter *Logic*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 84, with 8 branches, 12 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Apify, Postgres, Supabase, Telegram
- **Model:** OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Apify, Postgres, Supabase and Telegram accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an incoming Telegram message.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 84 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 84 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%2Fautomate-personalized-cold-email-sequences-with-mailgun)
- **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.

[Apify](https://millionrounds.com/workflows?service=Apify#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[Supabase](https://millionrounds.com/workflows?service=Supabase#library)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

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

- [**Complete B2B sales pipeline: Apollo lead gen, Mailgun outreach** 96 steps · calls a model · Apify, Gmail](https://millionrounds.com/workflow/complete-b2b-sales-pipeline-apollo-lead-gen-mailgun-outreach)
- [**Automate business partner outreach with Google Maps and OpenAI** 55 steps · calls a model · Apify, Google Drive](https://millionrounds.com/workflow/automate-business-partner-outreach-with-google-maps-and-open)
- [**Automate social fan-out, marketplace outreach, and CRM alerts** 49 steps · Google Sheets, Salesforce](https://millionrounds.com/workflow/automate-social-fan-out-marketplace-outreach-and-crm-alerts)
- [**Automated lead nurturing with Gemini and Telegram** 42 steps · calls a model · Email, Gmail](https://millionrounds.com/workflow/automated-lead-nurturing-with-gemini-and-telegram)
- [**RAG Chatbot with Signup Automation** 38 steps · calls a model · Google Drive, Postgres](https://millionrounds.com/workflow/rag-chatbot-with-signup-automation)
- [**Manage hotel guest requests and post-stay outreach** 35 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/manage-hotel-guest-requests-and-post-stay-outreach)
