Automate Lead Generation and Weekly Marketing Reports with n8n: 2 Real Workflows
Prospecting and reporting are two of the most repetitive jobs in any small business: search, copy, paste, write, send, and again next week. Here are two workflows from our portfolio that do both on a schedule, what each node does in general, and how to reuse the pattern for a real estate agency, a distributor or a clinic.
Short answer
Lead generation and weekly reporting follow the same recipe in n8n: a Schedule Trigger starts the workflow, HTTP Request nodes collect data from public or analytics APIs, Filter, Merge and Limit nodes clean and control the list, an AI node writes the text, and Gmail plus Google Sheets send it and remember what was done. The two portfolio workflows below find Tunisian e-commerce shops and email ten new ones a day, and turn last week's Google Analytics data into a strategy report every Monday. Both can be adapted to almost any sector, as long as you respect data protection and email rules.
The pattern behind both workflows
Look past the tools and both workflows do the same five things a marketing assistant would do by hand:
- Start on time: every day at 8:00, or every Monday at 9:00 (Schedule Trigger).[1]
- Collect: call an API and receive JSON (HTTP Request).[2]
- Clean and decide: keep only useful items, combine sources, cap the volume (Code, Merge, Filter, Limit).
- Write: let a language model draft the email or the analysis (AI Agent or Basic LLM Chain).
- Act and remember: send the email and record it so tomorrow's run doesn't repeat it (Gmail, Google Sheets).
Each step passes a list of items to the next, and every node runs once per item automatically.[3][4] If that sounds abstract, our first article explains how n8n items and expressions work. Here we stay at the business level: no code, just what each node is for.
Workflow 1: e-commerce lead generation, every morning
View “Scrape Tunisia E-commerce Contacts” on GitHub ↗What it does. The workflow has two branches that run one hour apart.[5] At 8:00 it finds shops in Tunisia that have a website listed in OpenStreetMap. It visits each website, extracts a public contact email, removes addresses already in the list and appends the new leads to a Google Sheet. At 9:00 it reads the sheet and keeps only the shops not yet contacted, takes ten of them, asks an AI model to write a personalised email for each one, sends it and marks the row as sent. If anything fails, the error-alert workflow from part 2 of this series sends an email.
The lead nodes, explained in general
| Node | What it does in any workflow | Its job here |
|---|---|---|
| Schedule Trigger | Starts a workflow at fixed times, such as daily, weekly or every X minutes[1] | Two clocks: discovery at 8:00, outreach at 9:00 |
| HTTP Request | Calls any web API or page and returns the response as items[2] | Queries OpenStreetMap's Overpass API[6] and downloads each shop's homepage |
| Code | Runs a small JavaScript or Python step when no ready-made node fits[7] | Turns raw map data into clean lead rows and finds a mailto: email in each page |
| Merge | Combines two branches: append, match on a field, pair by position and more[8] | Brings website pages and already-known emails together so duplicates can be dropped |
| Google Sheets | Reads, appends and updates rows, which makes a free, shareable mini-CRM[9] | Stores leads, then flags each row as sent |
| Filter | Lets through only items that match conditions; the rest are dropped[10] | Keeps rows whose “email sent” column is empty |
| Limit | Keeps only the first N items[11] | Ten emails a day: safe for deliverability, and easy to review |
| AI Agent + chat model + Simple Memory | A language model that follows instructions and can use tools; memory keeps context per conversation[12][13] | Writes a personalised email per shop, using its name, activity and our services page |
| Gmail | Sends, replies to, labels or reads email[14] | Sends each email from the business account |
We used Code nodes for parsing and de-duplicating, but n8n has a dedicated Remove Duplicates node for the second job.[15] If the source is a site that's hard to read, an Apify actor can do the scraping. See calling Apify from n8n.
Three design choices worth copying
- Split discovery from outreach. Two branches an hour apart mean a slow scrape never delays emails, and you can review or clean the sheet in between.
- The sheet is the memory. The “sent” flag makes each run aware of the previous ones, so nobody gets the same email twice.
- Cap the volume. A Limit node is the simplest safety valve against sending hundreds of AI-written emails because of one bad filter.
Workflow 2: a weekly marketing report written by AI
View “Marketing Analytics” on GitHub ↗What it does. Every Monday at 9:00, the workflow asks Google Analytics 4 three questions about the last seven days: which city sent the most visitors, how the site performed overall (sessions, users, bounce rate), and which pages were read most.[5] It sends this to a language model, which returns a short strategy report and a draft outreach email. The report is emailed to the site owner. The workflow then looks up businesses with a website in the top city and sends them the outreach email. It connects “where our visitors come from” to “who we should talk to”.
The report nodes, explained in general
- HTTP Request to an analytics API. GA4's Data API has a
runReportmethod. You ask for dimensions (city, page) and metrics (sessions, views) over a date range, and it returns rows.[16] Any analytics, ads or e-commerce platform with an API works the same way. - Code nodes as translators. Each API answers in its own format. A short Code step after each call turns the answer into simple named fields, such as city, sessions and bounce rate, that the next nodes and the AI can read.[7]
- Basic LLM Chain vs AI Agent. The Basic LLM Chain sends one prompt and returns one answer;[17] the AI Agent can decide to call tools and loop.[12] A weekly report needs no tools, so the simpler chain is cheaper and more predictable. Use the agent when the model must look things up.
- Asking the AI for structured output. The prompt asks the model to answer in a fixed shape (report, email subject, email body), and a Code node checks it before anything is sent. Never pass raw AI output straight to customers.
- Gmail to the owner first. The human gets the analysis before any outreach goes out. That's the review step.
In Part B, the HTTP Request nodes call OpenStreetMap's Nominatim service to turn the city name into map coordinates, then Overpass to list businesses in that area.[18][6] These are free community services with strict usage rules, which we cover below.
Apply it to your business
Keep the skeleton (schedule → collect → clean → write → act and remember) and change the sources and the message:
| Business | Collect | Clean & decide | Write & act |
|---|---|---|---|
| B2B distributor | Shops of a given type in a new region (map data or a directory) | Filter by category; drop existing customers with Merge | AI drafts an intro offer; sales rep reviews; Sheets tracks follow-ups |
| Real estate agency | New listings from your own site or CRM | Filter listings that match each saved buyer search | Personalised “new property for you” email to opted-in buyers |
| Restaurant or hotel | Last week's reviews and bookings via their platforms' APIs | Summarize by rating; flag reviews below 3 stars | Monday report to the manager; draft replies for negative reviews |
| Clinic | Tomorrow's appointments from the booking system | Filter unconfirmed ones | Reminder email or SMS; no-shows logged for follow-up |
| Marketing agency | GA4 and ads data for each client | Loop over clients; compare with last week | One AI-written summary per client, sent after human review |
When you have many clients or properties to go through, the same nodes simply run once per item. When you must group results, such as one report per client with totals, the Split Out, Aggregate and Summarize nodes take over.
Stay legal: data, email and API rules
Automating outreach makes it easy to break rules at scale, so build them into the workflow from day one. This is general information, not legal advice.
- Personal data needs a legal basis. Under the EU GDPR, processing personal data requires a lawful basis, and people can object to direct marketing at any time, after which you must stop.[19] Add an opt-out line and a “do not contact” column that your Filter node respects.
- Marketing email rules. The EU ePrivacy Directive generally requires prior consent for marketing email to individuals, with a narrow exception for existing customers.[20] Generic company addresses carry less risk than named personal ones, but check the rules in your target country.
- Tunisia has its own law. Organic Law 2004-63 governs personal data processing in Tunisia,[21] so the same care applies to Tunisian leads.
- Respect the data sources. OpenStreetMap data is under the Open Database License and requires attribution.[22] The public Nominatim service allows at most one request per second, requires an identifying User-Agent, and asks you to cache results.[18]
- Keep a human in the loop. Review AI-written emails before volume grows. A model can invent facts about a business it never visited.
What the research says about the gains
The writing steps in these workflows are where language models help most. A study published in Science estimated that about 80% of the US workforce could have at least 10% of their tasks affected by large language models, and about 19% at least half of them.[23] In a study of 5,172 customer-support agents published in The Quarterly Journal of Economics in 2025, access to an AI assistant raised the number of issues resolved per hour by 15% on average, and less experienced workers improved in both speed and quality.[24]
The automation steps add a different gain: consistency. The report arrives every Monday even in a busy week, and the follow-up list never forgets anyone. A 2025 field experiment across 66 firms points the same way: workers who used an AI tool spent about two fewer hours a week on email and worked less outside regular hours.[25]
Next in the series: n8n data pipelines with Split Out, Aggregate, loops and AI agents, based on a sales report and a healthcare data pipeline.
Frequently asked questions
Can n8n generate leads automatically?
Yes. n8n can collect business data from APIs or public sources on a schedule, clean and de-duplicate it, store it in a sheet or CRM, and draft outreach with an AI node.[1][2][9] You still need a legal basis for contacting people and a review step before emails go out.[19]
Is it legal to email businesses found with automation?
It depends on the country and on whether the address belongs to a person. In the EU, marketing emails to individuals generally need prior consent,[20] and anyone can object to direct marketing under the GDPR.[19] Tunisia has its own data protection law.[21] Always include an opt-out and honour it.
How do I connect Google Analytics 4 to n8n?
Use an HTTP Request node with Google OAuth credentials to call the GA4 Data API's runReport method, asking for the dimensions and metrics you need over a date range.[16][2] Then use a small Code or Edit Fields step to turn the returned rows into simple fields.
Should I use the AI Agent or the Basic LLM Chain node?
Use the Basic LLM Chain when one prompt and one answer are enough, such as summarising a report.[17] Use the AI Agent when the model needs tools, such as looking up a customer or querying a database, or memory across messages.[12][13]
How many emails should an automated workflow send per day?
Start small. Our workflow uses a Limit node to send ten a day,[11] which keeps volume reviewable and protects your domain's reputation. Raise it gradually only after replies and bounce rates look healthy.
Sources
Every explanation in this article is based on the technical standards, official documentation, peer-reviewed research and real workflows listed below. Numbers in the text, such as [1], link to the matching source and open this list. All links were checked on October 28, 2026.
Show all 25 sourcesHide sources
- n8n Docs. Schedule Trigger node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/
- n8n Docs. HTTP Request node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/
- n8n Docs. Data structure (items). Official n8n documentation. docs.n8n.io/data/data-structure/
- n8n Docs. Looping in n8n. Official n8n documentation. docs.n8n.io/flow-logic/looping/
- Meddeb, Y. (2026). n8n-workflows: portfolio of production and training n8n workflows (exported JSON). GitHub repository. github.com/yahmed-web/n8n-workflows
- OpenStreetMap Wiki. Overpass API. wiki.openstreetmap.org/wiki/Overpass_API
- n8n Docs. Code node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/
- n8n Docs. Merge node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.merge/
- n8n Docs. Google Sheets node. Official n8n documentation. docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/
- n8n Docs. Filter node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.filter/
- n8n Docs. Limit node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.limit/
- n8n Docs. AI Agent node. Official n8n documentation. docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/
- n8n Docs. Simple Memory node. Official n8n documentation. docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memorybufferwindow/
- n8n Docs. Gmail node. Official n8n documentation. docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.gmail/
- n8n Docs. Remove Duplicates node. Official n8n documentation. docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.removeduplicates/
- Google for Developers. Method: properties.runReport. Google Analytics Data API v1 documentation. developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
- n8n Docs. Basic LLM Chain node. Official n8n documentation. docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm/
- OpenStreetMap Foundation. Nominatim Usage Policy. operations.osmfoundation.org/policies/nominatim/
- European Union (2016). Regulation (EU) 2016/679 (General Data Protection Regulation), Articles 6 and 21. Official Journal of the EU. eur-lex.europa.eu/eli/reg/2016/679/oj
- European Union (2002). Directive 2002/58/EC (ePrivacy Directive), Article 13: unsolicited communications. Official Journal of the EU. eur-lex.europa.eu/eli/dir/2002/58/oj
- Republic of Tunisia (2004). Loi organique n° 2004-63 du 27 juillet 2004 portant sur la protection des données à caractère personnel (full text, French). legislation-securite.tn/wp-content/uploads/sites/5/2023/11/Loi-n%C2%B0-2004-63-du-27-Juillet-2004-Fr.pdf
- OpenStreetMap Foundation. Copyright and License (Open Database License, ODbL). www.openstreetmap.org/copyright
- Eloundou, T., Manning, S., Mishkin, P. & Rock, D. (2024). GPTs are GPTs: Labor market impact potential of LLMs. Science, 384(6702), 1306–1308. Preprint: arXiv:2303.10130. arxiv.org/abs/2303.10130
- Brynjolfsson, E., Li, D. & Raymond, L. R. (2025). Generative AI at Work. The Quarterly Journal of Economics, 140(2), 889–942. doi:10.1093/qje/qjae044. doi.org/10.1093/qje/qjae044
- Dillon, E. W., Jaffe, S., Immorlica, N. & Stanton, C. T. (2025). Shifting Work Patterns with Generative AI. NBER Working Paper 33795, National Bureau of Economic Research. www.nber.org/papers/w33795