This Ai Agent researches Leads, Competitors and anything else

Rory Ridgers builds an AI research agent on Relevance AI that chains five tools: website scraper, LinkedIn scraper, Instagram scraper, Perplexity search, and Google Maps scraper. The agent picks the right tool based on what you ask it, whether that's lead generation, competitor analysis, stock prices, or finding marketing agencies in a city.
Chapters
In this video, we're going to be making an AI agent that can research pretty much anything from new leads to companies, social media trends, and even just general questions like what's the weather like today? Or what was the score of the game last night? If you haven't seen me before, my name's Rory Ridgers and I'm an AI enthusiast and I'm passionate about helping business owners integrate AI into their business. So if that's something you might be interested in, then I've left a link to my website in the description of this video and you can go ahead and book in a call with me and we can talk about some ways to integrate AI into your business. And as always, everything that I make in this video, the templates for them will be available for completely free in the description. If you go in the description, you should see a little link that says something like free templates. Click that and you can get all the templates for free. Let's not waste any more time. Let's get into the video and I can show you how it all works. Okay, so in this video we're going to be making majority of the AI agent on Relevance AI. There is one small Make.com scenario, and then we're also going to be using Appify for one of these tools, but I'll show you that when we get to it. So these are 5 tools we have here. We have the Google Maps scraper, Perplexity tool, Instagram scraper, LinkedIn scraper, and then also website scraper. So all of these are kind of self-explanatory what they do, but I want to show you inside all of them so you can sort of see how they all work. So first one is going to be the website scraper. This is probably the most simple out of all of them, and this is literally just going to do what it says on the tin. So it's going to scrape a company's website. So we have a look inside. You can see the first step is going to be company name, because for this I wanted to use to be able to just input the company name to find whatever it is looking for. So the input is going to be company name. And then what we're going to do is going to use a Google search block here, and we're simply going to put in the variable company name, and we're going to try and find their website. So what we do, we use a Google step here, search up the company name, then use a simple LLM step here to basically just go through the search results of this and output just the URL that is most likely to be this company's website URL, which is probably going to be sort of the first one that pops up. But that's what those two steps do. And then we have an extract website content step here. and we literally just put in the answer from this step, which should be the website URL. Put that into here, and this is just going to scrape all the content from their website. And then we use an LLM step here to just sort through that data and format it nicely so that it's nice and readable. So we're going to try this out really quickly. I'm going to say something like Gymshark, put that into the input, run tool, and they should find their website and then give us some information about their website. Okay, so it's just finished running here, and you can see The Google step, we get all of these outputs here, and we obviously want just the website URL. So that's what this LLM step does. You can see it's outputted the website URL. Then we extract the website content. This is what that looks like. I'm not going to click view all because there is quite a lot of content there. And then we use an LLM step to simply just create sort of a report or a summary of the website content. So you can see we've got a little summary here, and then key points, some of their promotions, discounts, featured products, uh, product categories, brand philosophy. Everything like that. And obviously you can customize this if you want to get sort of certain key points from their website. You just customize this prompt to get that, but I've just left it sort of general so it gets all the website content. So that's how that tool works, really simple. We can hit save and come out and look at these other ones. So we'll look at the LinkedIn scraper now because it's pretty similar to the website scraper tool except it's scraping the LinkedIn, obviously. So you can see, yeah, same input, company name, And then these two steps are pretty much the exact same, except this time we're looking for the LinkedIn. So we put the company name's LinkedIn and then use an LLM step to just again go through those search results and try and find the most likely URL that is the LinkedIn URL in this case. Then what we do is we use a get LinkedIn profile slash company and posts. We put in the LinkedIn URL that we got from this step and then we set it to get company profile. And then we just have an LLM step that's going to go through that data and format it nicely again. So pretty much exactly the same as what was happening on the scraping the website tool. And then we just repeat this process, but instead of getting the company profile, we get the company posts. And then same thing, we use an LLM step to just go through that data and sort of just make it look nice and summarize what it's found. So again, we're going to test this out. We'll just keep it the same, say Gymshark, hit run tool, and then we should see this working. So the Google step, these are the outputs we get. And then it's taking me to the bottom because it's still running, but, uh, you can see, yeah, the LLM step, this is what's given us the LinkedIn URL. Get company profile, that's what that looks like. And then this LLM step here should be summarizing their company. So yeah, we get all of these different data points here. And then we have the get company posts, and that's what that looks like. It's just all in JSON at the moment. And then this final LLM step should just go through those post results and give us an output here. So yeah, so this is the company summary. So we've got a description and then sort of the key data points here, and then employee count, follower count, funding information, all that kind of stuff that you find on their company profile that's summarized here. And then the LinkedIn post data, this is what that looks like. So the date they posted, the post title slash theme, and the engagement on it, and then the summary of it, and then a URL so we can view this post. So Yeah, really cool. Again, really simple, kind of like the web scraper tool. These are really simple to put together and test out. So yeah, that's that one. Let's hit save, come out of that, and now we'll have a look at the Instagram scraper tool because for this one we need to use Apify. So I'll show you inside that, and if you've never heard of Apify before, don't worry, I'll show you how it all works and how to use it. So again, the input is going to be company name and then pretty much the exact same thing we did for the LinkedIn and the website. All that's happening here is we're just going to try and find their Instagram URL. So we put in the company name's Instagram, and then we use an LLM step to go through those results and find the actual URL that we're looking for. And then we use an API step, and this is when we connect to the actor on Apify. So I'll show you that quickly. So this is my Apify account here. Basically what Apify is, if you've never heard of it, it's basically just a bunch of APIs made by the community, and you can just connect them in your agents and your tools. And they're mainly for scraping tools, so social media scrapers, web scrapers, news scrapers, that kind of thing. They're really, really simple to set up and connect with API steps. So I'll show you how they work. We're using this Instagram profile scraper actor here. So if we come into it, you can see this is how we set it up. So we don't want manual because that would be if we're using it inside of Apify, which we're not going to be. We want the JSON. So you can see here, this is the JSON here. This is the only thing we need, which is the username. Just want to mention, actually, I forgot about this. This LLM step after the Google search, it doesn't find the URL. It takes the URL that they think is most likely the Instagram URL, and then it will extract the username from that. Because for these actors to work, we need the username, not the URL. So you can see here in the prompt, I've said uh, so get the URL and extract the Instagram name from that URL. So if the URL looks like this, then the name would be Gymshark because it has to be the exact Instagram profile name. So that's why we do that. So if we look at this actor here, this is the JSON schema that we're going to have to use in our API steps. If we come over to our API step, the method is going to be POST. The URL is going to be— if we go to API, then go to API endpoints then we want to use this URL, run actor and get dataset items. So you can just copy that, put that into here. The content type is going to be application/json. It's going to be a JSON object. And then we literally just paste in this schema that we get here. We just paste that in, put it into here, and then obviously we switch out our variable. So we switch out this with our variable, which is this LLM answer, which is going to be the Instagram profile name. So when that's all connected up, these will trigger— that will trigger the actor. And then what happens is this API step will wait for the results from the actor because sometimes it can take a few seconds to scrape the Instagram profile. And then this LLM step basically just go through the data that we get from this API step from the actor and then again just formats it nicely so it's nice to look at. So we're going to test this out. Again, we'll use Gymshark as an example. We'll hit run tool, and then we should be able to see this actor actually work on Apify. So, okay, so you can see, yeah, this LLM step, it's got the name, and then now it's running the actor. So we should be able to see if we go to runs, we should be able to see— yeah, you can see it working now. And the nice thing about Apify is you actually get some free usage. I'm just on the free plan with it. You get some free usage every month with it, which is nice, so you don't have to worry about paying if you're just sort of testing these things out. When you come to actually use it in an agent that you use at the time, you might have to start paying, but for now you can just use the free credits that you get. So that looks like that's run, and this is what it's given us. It looks like there's nothing here. I'm not going to click View All because for some reason the data is at the bottom of this table. But I promise you it is there, because when we come to this LLM step where we get to summarize it, this is what it outputs. Outputs it like this, which might look weird to you right now, but when we use it in the agent, the agent will format it a bit nicer so we can actually read it properly. But you can see this is the data that we get here: the username, the full name, the bio, and then the website, followers, following, post counts, all of that stuff, and some information on their latest post. So That's really cool. So now you should be able to scrape a company's website, a company's LinkedIn, and a company's Instagram profile, all just from the name of the company. So those are the social media kind of scrapers. Now we're going to have a look at the other one. So we'll look at this Perplexity tool because this one, it's really, really simple. It's nice on Relevance AI, they have a native integration with Perplexity, so you don't have to worry about setting up an API key with Perplexity or anything like that, you can, you can put your API key in here and it will reduce the credit usage a bit because you'll be getting billed to Perplexity rather than through Relevance AI. If you don't want to do that, you can just do what I'm doing here. So the input is user query, and this is just going to be whatever the user's query is. So for Perplexity, if you don't know what Perplexity is, basically it's kind of like Google but with AI. So you can ask questions about virtually anything and it can give you real-time results and stuff. So as I said at the start of the video, you can ask it things like, what's the weather like in London today? And it will give you real-time results. And you can also ask it sort of more complex questions. You could say, um, how do large language models work? And it's able to search the web instantly pretty much and give you detailed answers back. So it's kind of like ChatGPT and Google combined. So we have the user query here, and then we simply just have an LLM step here, and all we do is we change the model to— if we go to Perplexity AI here, we can choose one of these models. And all we do, the prompt is simply going to be the user's query. So let's use one of the examples I've said. Uh, what is the weather like in London? What is the weather like in London? We'll hit run tool. So it's what's given us for London, the weather forecast for tomorrow, Sunday, December 15th, 2024. It's given us the temperature, the conditions, and then the general weather. So really nice. We can also ask it some more complex things. So I'm going to use again one of the examples I said, something like, how do large language models work? Something a little bit more complex. And it's also not real-time data, this is just sort of general query. So we're going to see what it comes out with when we put that. Okay, so this is what it's come back with. Large language models are sophisticated AI systems. It's given us the architecture, the training, fine-tuning, key components, um, how LLMs process text, use cases. So a really in-depth sort of analysis on how this works, which is really, really cool. You can ask it pretty much anything you like, so it's great for general knowledge, and it also gives you real-time data, which is really cool. So I'm going to hit save, come out of that. That's again a really, really simple tool. Now we're going to look at the Google Maps scraper, and this is the one that uses the Make scenario, so I'll show you that when we get to it. Again, the only input is user query, so this could be something like, um, what restaurants are there in New York, or I'm looking for digital marketing agencies in wherever. So it could be great for just sort of general stuff, like maybe you're out and about and you want to find a restaurant. Or it can also be great for if you want to do outreach, maybe. So if you're outreaching to construction companies, for instance, you could say find me construction companies in, and then wherever you live or wherever you're targeting. So that's kind of how we'd be using this tool. So the input, use a query And then we use an LLM step here. And what this does basically is it looks at the query and it tries to find the two variables that we need in the Make.com scenario. And those are the type of thing we're looking for. So restaurants, construction companies, parks, things like that. And then also the location. So I've given an example. If user says, I want to find restaurants in New York, then output New York and restaurants as two separate variables. And it's going to be outputting this in JSON. For some reason, when I was using this, the ChatGPT 4.0 Mini was taking ages, so I switched it to Claude. Don't know why, maybe it's just at the time recording this it's having a funny 5 minutes. But yeah, so it's basically going to get the type and the location, output them as 2 separate variables. It's going to output them as JSON, and then we use a convert JSON, like text to JSON, so it's going to convert this to actual JSON so we can use it as 2 separate variables. And then we have an API step here which is going to connect to this Make.com scenario. And all that we have here is a webhook to connect it to our API step on Relevance AI. And then we just have a Google Maps search for places. And if you haven't set up a Google Maps node on Make.com before, you will need to set it up in your Google Cloud and get an API key. But it's really, really simple to do. They kind of walk you through how to do it, so don't worry. But just be prepared, you can't just sort of one-click connect it. You will need to get an API key. But anyway, what we do is we go to find places. I've said by text search, and then the query for the search places is going to be the two variables that we get from the webhook, so the type and the place. So you can see I've already used it out here, parks and London. As you can see, this is the example they give you, restaurant 123 Main Street. So that's how we're inputting the data into the tool. You can fill all of these out if you want. This is obviously all up to you guys. The minimum price, the maximum price, the type— we don't need to do that because we've put it in here. And then the limit, I've set it to 10. You can set it to whatever you want. And then we use an array aggregator to basically just bundle all of this data into one array. So we just pick the variables that we want: total number of bundles, business status, the address, the URL on the map, the icon, the name, opening hours, photos, price level, rating. So you can just choose whichever ones you want. Those are the ones I felt are the most sort of relevant here. And then we use a webhook response to just send this back to Relevance AI via the webhook. So I'll test that out and show you how that works in a second. But we just have one more LLM step here that can just format it nicely for us. So really, really simple. I'll show you how this works. We'll hit run once with this and then we'll test it out. We'll say parks in London. Which is obviously the test that I used before this video. So parks in London uses LLM step here to— it should output parks and London, which it looks like it has. Yeah, parks in London, and it's given us the two separate variables here. This tool should have run and it's given us— yeah, all these different parks in London, I'm hoping. So we can look back at the tool and yeah, this is what it's given us. So Hyde Park, St. James's Park, Kensington Gardens. And then we also got the rating, the address, the status, the opening hours. And then we can also view this on the map, so there should be a link to Google Maps and we can view this. Yeah, so yeah, perfect. But now let's try it for something a little more practical as a business owner, something like the industry that you want to reach out to, like I said. So we can look at— and if you aren't sure what sort of type of industries you can look for on Google Maps If you come over to the Google Maps node on make.com, look at the type, and on here we'll have all the different industries that they have listed on Google Maps that you can look for. So we'll just pick one of these that we might want to reach out to. Yeah, real estate agency, that might be something that some of you guys want to reach out to. So we can say something like— so we can say something like, I want to find real estate agencies in New York. This LLM step should split up into real estate agencies and then New York. And then we convert it into two separate variables, send it off to the Make.com scenario which was triggered. That's good. Then this LLM step is going to go through all that and format it nicely for us. So let's see what it comes out with. Okay, so here we go, uh, the Bizarre Agency, rating 5. This is the address, the status, the opening hours, and then yeah, it's given us 10, the Manhattan Realty Group, Berkshire Group Real Estate, all of these different real estate agencies. Really cool. We can look on the map at some of these different agencies. So it looks like it's here. So very, very cool. So now we need to put all of these tools into an agent so we can use them all at the same time. So of course I've already done that, but if you're following along with the video, you'd click New Agent. But for me, I'm just gonna click Edit Agent. And for the name, I've said Research Agent. The agent description: this agent is able to research practically anything from competitors to leads to current stock prices. For me, this agent description is kind of valuable because I want to link it to my Personal Assistant agent. If you haven't watched my video Multi-Agent Systems and go watch that because I explain how that works. But for you guys, if you're going to be using this just as a one-off agent, then don't worry too much about the name and the description. The main part here is in the tools and the core instructions. So I'm going to show you what's in the tool section. Obviously it's just going to be all the tools that we've gone through in this video. Okay, so these are the tools, obviously the Instagram scraper, LinkedIn scraper, Perplexity tool, Google Maps scraper, and the website scraper. And when you add all these tools Make sure to set these from approval required to auto run, because the default is approval required. We want this agent to be able to automatically run these tools, so set it to auto run. And then we're going to look at the core instructions. So for me, I've put the role: you're a helpful research agent that's able to research things like leads, companies, real-time events, and general knowledge. And then under task, I've said your job is to take a user's query and use the appropriate tool to fulfill their request. You have 5 tools, and I've given it the 5 tools. You may have to use more than one tool to fulfill the user's request. The user's input to you will be something like research this person, or research this company, or what is the Amazon stock price at right now, something like that. And then I've given it a breakdown of the 5 tools. By the way, if you want to be able to directly reference these tools in the prompt, just click a forward slash and then you can click the tool here so the agent knows exactly what tool you're talking about. So then I've given it a breakdown of the tools, and I've kind of followed the same structure for all of this like I do in all my videos. So I've just given it the tool and said what the tool does. So this tool is able to find locations on Google Maps and info about these locations. Then I've given it the user input. So the only input is user_query, and I want you to use the user's input to you in this input as you receive it. So the user input and what it should put into the user input And then also just like to tell it when to use this tool. So I've said use this tool when a user says something like, I want to find parks in London, or what marketing agencies are there in New York, things like that. So pretty much kept the same structure for all these descriptions. You can pause the video and look through this, or you can just download the template for this agent and you'll get the prompt for free. But I've also just put some notes at the end. I said when a user just says they want to find more info out about a company use the web scraper tool, LinkedIn scraper tool, and Instagram scraper tool to create a report. Basically, when a user inputs a company name and says they want to find more information about this company— this could be either a lead or a competitor, or maybe they're just curious— they don't want the agent to be able to get the most information out about that company. So we're going to use the web scraper tool, LinkedIn scraper tool, and the Instagram scraper tool to get all that information and sort of create a little report on it. So Now we can obviously hit Save Changes and then we can test this agent out. So for this first one, we're just going to give it a company name and see if it uses the 3 tools and see what it gives us. So we've been using Gymshark for this. We're going to switch out, we'll say something like OpenAI. So I want to find more info on OpenAI. Obviously this is a very large company. It does work for smaller companies, but I just want to give you a company that everyone's going to know. So in the background, it's used the web scraper tool, should use the other two tools here. Okay, so it's used the three tools. That took less than a minute, which is nice. This is what it's given us. So the website information, a link to their website, and then a short little summary here. And then their LinkedIn profile with a link to it. So founded, headquarters, employee count, uh, some of their recent LinkedIn posts, which is cool. Then their Instagram profile. So a link to their Instagram here, and then their bio, their followers, their posts, and then a summary on the company. So OpenAI is a leading organization in AI research dedicated to creating safe and beneficial AGI. So really, really cool. Now we're going to try and use some of these other tools. We'll try and use the Perplexity tool. So we'll say something like, what is the stock price of Tesla? Right now. So I said, what is the stock price of Tesla right now? Obviously you can ask it absolutely anything, which is cool. We're just going to ask it this to try and get it to give us some real-time data. So yeah, as of Friday morning, December 13th, 2024, the Tesla stock started trading at $420.11. It's given us the previous closing price. So yeah, really, really cool. And obviously That's up to date. Now we're going to ask it something about the Google Maps. We'll say, I want to find marketing agencies in— so I want to find marketing agencies in London. Again, this could be an industry that you'd like to reach out to. They could also be your competitors as well. So let's see what it comes out with here. So it's using the Google Maps scraper tool. Okay, so this is what it's given us. It's given us, uh, The Good Marketer, digital marketing agency in London. Their rating, the address, all of these different marketing companies. Let's click View on Map for one of them. And yeah, it's giving us their location on the map. This is in London. So yeah, really, really cool. And it's managed to get all of this data in sort of less than a minute, which is really cool. So now you should have an agent that's able to research pretty much anything— leads, competitors, stock prices, Google Maps, anything. For me, I'm going to add this agent to my personal assistant agent in my multi-agent system, but obviously for you guys, you can use it for anything. You enjoyed this video and you were interested in working with me, then as I said at the start of the video, I've left a link to my website in the description and you can go ahead and book in a call with me and we can talk about some ways to implement AI systems like this into your business. And also, like I said at the start of the video, all the templates that I used in this video will be available for completely free in the description. If you just go to the link, you can go and grab them for free. So thank you for making it to the end of the video. If you have any video suggestions that you'd like to see, please do just drop them in the comments and I'll try my best to get around to them.
More from Rory

Dynamic Workflows are crazy. This is how to actually use them (beginner's guide)










