N8N + AI Agents = Unlimited Lead Generation [ Free N8N Workflow ]

In this tutorial Michael Elliott demonstrates a complete, no‑code lead generation pipeline built in n8n. The workflow consists of three stages: (1) scraping LinkedIn profile URLs, occupations and locations using the SERP API via Google search, handling pagination and exporting results to a Google Sheet; (2) enriching each lead with detailed profile data (skills, recommendations, headline, etc.) via Apify’s LinkedIn scraper, respecting free‑tier limits and aggregating the data for spreadsheet output; (3) feeding the enriched data into an OpenAI‑powered AI agent that generates a personalized LinkedIn connection note (≤200 characters) and a follow‑up message (90‑140 words) using a carefully crafted prompt and output parser. Michael walks through each node, shows how to configure API keys (SERP, Apify, OpenAI), explains the purpose of the canonical city name extraction, demonstrates the code node that consolidates arrays, and highlights practical considerations such as rate limits, free‑tier quotas, anti‑spam guidelines, and how to scale the flow with paid plans. The end result is a ready‑to‑use n8n workflow that produces personalized outreach messages for up to ten leads (free) or any number with a paid Apify subscription, with links to the Gumroad resource for the workflow file.
Chapters
Hey guys, my name's Michael. Today I'm going to be giving away an NAT and workflow that's going to win you more business. We're going to be scraping LinkedIn profiles using Google Search, including location and occupation. We're then going to enrich that lead using apify and then finally use an AI agent in order to be able to craft the personalization message both for the connection and then the first Kickstarter message. So let's jump in. So on the screen now we have the full flow. It's broken down into three individual sections as explained. Section one, this is where we go and scrape using SERP API. So to get all LinkedIn profiles with the occupation and the location alongside it, the middle section is where we enrich the lead using apify. We then execute a sub workflow and that sub workflow is an AI agent which uses all the information that we've scraped to enrich the leads. Now I'm going to go in deep into these with you. I'm going to take you inside of them just so that you understand them. For beginners, it'll be very helpful for anybody experienced. You know, if I am repeating myself and you already understand it, bear with the. Bear with the beginners. You were there once. So let's hit execute workflow and when we execute workflow, this is it. The search parameters are the individual occupation of the user. So let's say hotel owner and then let's set the location as London, submit the flow and the first part of the flow will fire off and will be complete pretty quickly. But I'm going to run you through what is actually happening. Okay, it's now sent the HTTP request and the rest of the flow does take a little bit longer because it's using external requests to apify etc and they need to run. But it gives me time to showcase this to you. So there's a bit of a weird thing at the start of this. Start this flow and it will require your open AI credentials, but it's a very, very basic prompt that basically tells it to analyze the location, input format and output, only the city name. And the reason that best describes the city, which is important because you'll see that the input JSON location, input location is London. Right? And then if we look at the output, we'll see that the city name is London. If you make a typo, if something happens inside of the location, that causes an issue. But it's mainly because we're using a SERP API location request to here that allows US to be able to get the correct phrase for the correct city. You'll see California, Vietnam, you know, Russia, France, whatever. So it ensures that the output is correct each time you use it. When it comes down to that API request, there's not really a lot to understand, but the query is basically the city name and it takes the city name. The limit is one because there is only one and that's it. But very importantly, there is a canonical name here that gets pushed out and that is what we use later on for all of the individual scraping and formatting and everything that we use. Location wise, we then create a spreadsheet. So inside of this spreadsheet node is the URL. I'm going to grab that now. I shouldn't have to copy anything else. I'll just keep hold of it. I should have Mackie enabled. Now this is the first page results. So this pulls the first page results. Rajat Sued hotel owner and hospitality entrepreneur Sounds pretty good to me for what we're trying to look for. Yeah, and there's lots of other individual bits of information as you can see, which is good. So you know, the snippet ot alone over 23 years ago started my journey in hospitality. All of that information can be used to enrich the lead later for our cold outreach efforts. I send 3,000 cold emails a day and send a lot of cold DMs every single day. And it's important that we use this information correctly in order to be able to build up a rapport with the person on the other end. It's exactly why personalization is so important with cold outreach. You should not understate it. But then what happens with all the other pages is we loop over the items that goes through and it searches the other nine pages from a, from a search engines results page point of view, leaving us with 100 leads at the end of it. There's not much happening inside here for me to explain the pagination here, but you don't have to do anything. You've just got obviously got to set up your SERP API off, which you have to do for all of the individual HTTP requests. It's free up to 250 searches. So you can get those leads for nothing. We then merge all of that information. So we merge them all. There's 94 items, not 100. Skip for a few. We then append the sheet aggregate all of that information so all the LinkedIn profiles are aggregated and we then send off a HTTP request, you know, which simply goes to the next webhook, what does it send? Sheet ID profiles. The message workflow has started. So inside of the next phase which might be complete now the that. So that's the flow complete in terms of the executions, it has succeeded. So this is the second flow. So let's copy this, the, the second part of this flow to the editor so we can go through it together. So the information that was received came from us, the host. It comes through here and all of the LinkedIn profiles were, were sent through as well as the sheet id. And that's the sheet ID that I have just copied and pasted and that I'll show you in a moment. These are the enriched leads. But I'll go come back to those in a moment. You can see all of these leads are all put together. If we look at it from a table view. If you. Yeah, but there you go. Actually you see it in the table view, you'll see that the array starts, comes through, has each individual section. There's, there's 10, there should be 10, 11. We go through, aggregated them all together before it came through and got spat out as one item. So it's very clear. But I don't know why I said that. But when it comes down to creating the sheet, it creates the enriched lead sheet. Because I have a limit here. You can see that we split them all out again. So this was where I was going with it a minute ago. We split all of the leads out to each individual lead. Inside of this table we can see all of the leads that we have actually generated. Okay. So we can go through and we could look through all of the individual leads we've scraped, but some of them, like three followers, example, 120 followers. All of the information is inside of here. London United Kingdom Tudor Court Hotel. Never heard of it. It's nice. But what we do is we create the sheet for the enriched leads with the Google sheet id, which is obviously the ID which we've pulled through, which was sent through. And then the split out node splits them out into individual LinkedIn profiles ready for enrichment. And we enrich using Apify. I have put a limiter inside of here which is 10, because to use this Apify scraper for free, you get 10 free leads. So as I've given it to you, you can like literally just go and run it and get yourself 10 free enriched leads. But what you can't do is go and ENRICH the whole 194 or 94 items that we've scraped. So that's why the Limit is there if you want to do that. As I again, I tell you that all of my inflows have full instructions. If you want to remove this limit for paid plans and go and blast the hell out of LinkedIn, be my guest. That's exactly what I do. But I'm going to leave it in for now. And obviously I left it in for now. That limit means that 94 items entered, 10 left. We then aggregate them together. These are the 10 that we were left with. Rajat. There he is again. Hero. If you're watching this, Rajat, you're famous. Now this is the apify authenticator. Okay? So you need to go to your apify account and copy your API key, so there's a link directly to it inside of here. All of my apify keys are hidden, so that's absolutely fine. All you need to do is go inside of here. If you need to create a new token, do it. If you've got one, just copy it in. But again, the links are there. Now this is a HTTP request to appify, and this has your. You'll have to connect your appify token into. We have to connect your appify token in inside of Nam. But what we're doing is we're scraping the profile and the cost, if anyone's interested, is ten dollars per a thousand leads for you to be able to use this scraper. The scraper is, is, is fantastic. It's, it's this one here. It's the Harvest API LinkedIn profile search. But we can see that we make the apify request and it was successful. The output here gives us all of this information so about everybody, every individual. And that's a long, that's a long bit of. Bit of text. But when it comes down to this cover picture, photo experience, the output that we receive, direct skills, director level, digital strategy, design management, project management. And I'll show you why that's important in a moment. Because once the output is put out, we then aggregate it all together and we merge it. So all that data is then merged again and then we split out into 10 individual items. Once everything is aggregated and we've got all the information that we've gone and looked for with these 10 pieces of information. What we also do is we use a code node, which looks complicated, but actually just aggregates all of the individual recommendations, skills, etc. Into an array for the spreadsheet. Because when you look inside of the spreadsheet, you, you'll see that when it comes down to the enriched leads, if I Just pop this and do this. If we see this, like here, like recommendations. All of these are individual unless they are put back into an array. Which is why we aggregate them. Same here. With the skills. They're all aggregated. There is very important information that we need in order to be able to use it for the personalization. But to have all of those listed individually would be an absolute disaster and won't read very well. And I'll get to those connection nodes in a minute. Once we've gone through the AI, we then aggregate that information back together. It appends and updates the row in the sheet. Where do we get to the code node? So the code node. Don't worry about this. But that's all it's doing is very, very simply just aggregating it together. Selects the data to export. We selected the only the information we wanted because obviously a lot of information comes back first name, email if. If possible. Like here. This is the information that we've got. Headline current position, receive recommendations, skills, follow, account about. Pulls out all that information and calls the next step of the workflow which we already. Sorry. Executes the next step of the workflow which is an AI agent which if any of you have watched my content, you'll be like, why is Michael using an AI agent? He doesn't like them. In this particular case, it works. AI agents are very good. They are very powerful. But what I don't like and what probably my next video or new video coming up about is going to be is about why they fail in production. Okay. And they do fail in production. So you need to understand how to build a flow as an AI agent when you're doing something quirky like this. And then you need to know how to build it if you're going to go and deploy it for a SAS company that's paying you 50 grand to build the flows. And that's the difference anyway. The information that was given to this is obviously from the previous execution, goes through all of the individual aggregated items and arrays. But I don't want to get bogged down in that. We've been bogged in on that for too long. We split it out again. So it gets split out into 10 individual items for each individual. Raja is here again. What geezer. We loop over those individual items. But what we've got the AI agent doing is. And you could improve this prompt. No doubt. But you're a LinkedIn outreach copywriter. Goal write two personalized message for a specific lead. A LinkedIn connection note with a maximum of 200 characters. A first follow up message to send after the connection is accepted. 90 to 140 words. We then give it some rules. Do not mention automation AI Nan, you know, do not keep time, friendly, personal, non salesy, non spammy, no hype, no emojis. We don't want it to just go wild and start sending bumblebee emojis to everybody on LinkedIn. You're not going to win any jobs evidently. So we try and force the, well we force the AI to ensure that the outputs are eligible for LinkedIn's cap of like you know, connection numbers etc. So that's what the AI agent does. What else do we have? We have the OpenAI agent model which you will have to add your open AI to as you will have done previously. At the top here where we use the. Use the AI, connect the AI agent there and then we have a structured output parser and that is the output is a connection note and a follow up message. That is simply it. Okay. And, and you can see here it's personalized it. If I go through one of the runs, if I go back to number one, we see Rajax. I quite, I quite like the guy. Might connect with him on LinkedIn in your journey in hospitality and innovation is inspiring. I'd love to connect and learn more about your exciting ventures in London and beyond. It's personalized it to him and then you can see here like that it personalizes it further. But we'll see this in the sheet, in the edit fields in the edit fields column. You pull this loop over items ID LinkedIn, URL connection note follow up message. Very simple as I just showed you earlier on of how you would be able to to piece that together. Send notification when when the job is done. So now everything is complete. So we should be able to go to our sheet as we have already been to and find 10 connection notes and 10 follow up messages for individual leads. Hi Rajat. We've done that already so let's have a look at another one. Hi Mark, I admire your work creating unique spaces in the hideaway spaces in the pop up hotel. I'd love to connect and learn more about your innovative projects. And then the follow up message is hi Mark, thanks for connecting. Really impressed with how you blend creativity, practical expertise and developing unique experience. Show spaces. There you go. I can say it can speak English. I'd love to hear more about your approach with hideaway spaces and upcoming projects. If you're open for a quick chat sometime, let me know. Okay, you can play with the individual AI agent to get it to speak however you want for whatever service you have, but you've got a really good solid base there to make sure that it doesn't go crazy on you. This flow allows you to enrich those profiles if you just remove the limiter. If you've got a paid subscription on Apify, you'll be able to do it for all 100 inquiries or 94 inquiries as we receive from this individual scrape. If you're new in your entrepreneurial journey, you can manually do it. Be careful with how many DMs you send on LinkedIn a day. Don't get yourself banned, that's important. But there are tools out there like Linked helper and other LinkedIn outreach tools that you could go on and further automate this with. That wouldn't give you any problems and cause for concern and would fully automate the process for you. But here is about generating leads via LinkedIn and I hope that I've given you that in the description there will be a link to the gumroad. Every single thing you need to change is literally documented inside of the flow as you've just seen it. We have just personalized the outreach for 10 LinkedIn leads because of the limit and they were all bang on the money. We looked at Rajats, we looked at Matts and it used information based off of their individual expertise to reach out to them. Your response rate will get a boost from using this. My name is Michael Elliot. Like subscribe and I'll catch you in the next one.










