Automation library · Lead generation

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.

LargeCalls a model: OpenAIRetrieval

84 stepsLarge: read it before trusting it with anything live
8Branches: places the flow splits
12Loops or waits
4Services it connects to

The flow

Starts it 5Model 10Logic 35Service 10

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

  1. 1Schedule Trigger1Schedule triggerStarts it
  2. 2OpenAI Chat ModelLm Chat Open AiModel
  3. 3Structured Output ParserOutput Parser StructuredModel
  4. 4Schedule Trigger3Schedule triggerStarts it
  5. 5Schedule Trigger4Schedule triggerStarts it
  6. 6Schedule Trigger6Schedule triggerStarts it
  7. 7OpenAI Chat Model1Lm Chat Open AiModel
  8. 8Simple MemoryMemory Buffer WindowModel
  9. 9User messageTelegram triggerStarts it
  10. 10Structured Output Parser1Output Parser StructuredModel
  11. 11Supabase2SupabaseService
  12. 12create email sequenceAgentModel
  13. 13Get many rowsSupabaseService
  14. 14Supabase11SupabaseService
  15. 15Supabase13SupabaseService
  16. 16Scraper agentAgentModel
  17. 17Voice or Text1SwitchLogic
  18. 18Sort2SortLogic
  19. 19CodeCodeLogic
  20. 20If3IfLogic
  21. 21Evualute when the mail was sentCodeLogic
  22. 22Evualute when the mail was sent1CodeLogic
  23. 23Generate query payloadSetLogic
  24. 24Select already scraped mailsPostgresService
  25. 25Download File1TelegramService
  26. 26Text1SetLogic
  27. 27If2IfLogic
  28. 28MergeMergeLogic
  29. 29Sort1SortLogic
  30. 30No Operation, do nothingNo OpLogic
  31. 31If1IfLogic
  32. 32IfIfLogic
  33. 33Create URLCodeLogic
  34. 34Keep only the new leadsCompare DatasetsService
  35. 35Transcribe1Open AiModel
  36. 36Limit1LimitLogic
  37. 37No Operation, do nothing2No OpLogic
  38. 38Time ZoneCodeLogic
  39. 39LimitLimitLogic
  40. 40SortSortLogic
  41. 41No Operation, do nothing1No OpLogic
  42. 42Sort3SortLogic
  43. 43No Operation, do nothing4No OpLogic
  44. 44Run an ActorApifyService
  45. 45Already scrapedNo OpLogic
  46. 46Create rows with new leadsSupabaseService
  47. 47SwitchSwitchLogic
  48. 48Sender EmailCodeLogic
  49. 49research about companyOpen AiModel
  50. 50Limit2LimitLogic
  51. 51Limit4LimitLogic
  52. 52Extract InfoSetLogic
  53. 53Set Telegram messageSetLogic
  54. 54Loop Over ItemsSplit In BatchesLogic
  55. 55Loop Over Items1Split In BatchesLogic
  56. 56Your leads tableSupabaseService
  57. 57General anlysisOpen AiModel
  58. 58Switch5SwitchLogic
  59. 59Switch6SwitchLogic
  60. 60Only Keep Verified Emails FilterLogic

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.