This AI Agent Ranks Your Leads While You Sleep!

Maxime Warnault builds an AI lead-qualification agent on NLLM that connects to GoHighLevel via webhook. The agent asks qualifying questions, scores leads, and updates contact fields automatically. It uses OpenAI's 4o Mini model with memory to retain conversation context across interactions.
Chapters
In this video, I'm going to show you how to create an AI agent that qualifies your leads and gives them a score so that you can send them to other AI agents. For example, a scheduling agent to book calls or a sales agent to sell low-ticket products for you. So I have a clean instance of NLLM, and so I'm going to show you the process. Step by step on how to use NLN using GoHighLevel as well. And let's get started. So we're going to start from scratch, and what we're going to need first is a webhook. So webhook here, we are going to— We can rename this webhook. I'm going to name it ai-seller. We can test this webhook, and what we're going to change here— so we're going to add an authentication after, but we want to use the Respond to Webhook node. Okay, so what this does is it receives the webhook, it does some work, and then it responds with JSON or text or whatever we, we want. To respond with. Okay, I think it's JSON. So, um, use— using Respond to Webhook, and we're going to need to insert Respond to Webhook node to control the response. Okay, so we don't need anything else here. Later we'll add some authentication, but as of right now we don't need anything else. So Let's do that. So we added the webhook here. Now what we need is we are going to add an AI agent. So I think it was here, Advanced AI, AI agent. And this we're going to define below and we're going to say message. So we're going to need to execute this once. So, I'm going to do a test and I'm going to copy the test URL here into my iLevel. And basically, I'm just going to copy and paste this. And basically, here what I use is a custom webhook and I pass some variables from Go iLevel into my webhook. We have the right URL, we POST, so the method is going to be POST. This is something I have not changed here. HTTP method is POST. We're going to start listening for events. Please resolve outgoing-incoming before activating it. Okay, so we're just going to remove this for now, and we're going to add Respond to webhook, first incoming item, it's fine. So now we have the both scenarios. Okay, so test workflow is going to wait for an event and we are going to test using—
We can use mine.
Send test request. And here you will see that this has been executed. Okay, so what we send is going to be— so these are all the headers, and this is what we send from here: ID, first name, email, phone, message, location, and source. Okay, so the message is null here, but this is what we're going to use for our AI agent. Okay, so AI agent What we're going to do is define below message is, and then we can drop that in here.
Message is nil, and we can say if it's nil, then we're going to say hello.
So here we're going to need to add a chat model. So I'm going to choose ChatGPT for this one. So OpenAI chat model, we're going to need to connect to ChatGPT. So I'm going to need to get my API key and my organization ID. Okay, so to do that, let's go to platforms.openai and we're going to log in.
Uh, Settings.
We're going to need an API key. It's fine, let's just create a new one.
Um, and then default project, create secret key.
We're going to copy this and we're going to paste it in here. That's all we need. Uh, we can save it. OpenAI account credentials successfully created. And now we should be able to connect to OpenAI. Okay, so from the list, we're going to start with 4o Mini, and what I want the response format to be is always JSON. Okay, if you are using JSON format, you must include word JSON in the prompt in your chain or agent. Also make sure to select the latest model released. Okay, um, that's fine. That's all we need in here. And memory, we're going to use SimpleMemory for this, and we are going to use the ID of— no, I think I need to define below. We're going to need the ID of the user that we pass. And here we're going to put 100 as the length. So now it's going to use the user ID that we use, uh, to store all of the memory. Okay, and finally, we're going to need to add a prompt to this agent, and we're going to need to add some tools as well to this agent. Okay, so let's start with the prompt and require a specific output format.
System message here.
So, "You are helpful assistant." So, I'm going to copy and paste the prompt that I have in here. So, "You are seller, bum bum bum." expressions. Let's see what it looks like.
So we need to rename, uh, it's good.
All right, this one is good, and we just need to rename the webhook because before it was in all caps. Uh, This one is not here. We're just going to ask a question.
Would you be open to some ideas?
Okay, cool. So this is the prompt that we have so far. We're going to save this and, uh, let's see, do we ask their first name? Okay, so what we can do now, I want to show you some, uh, things as well. So output parser, we can have this, uh, any of So this is to parse the output in JSON and verify it. So generate JSON from example. Now we're going to use define below and we have this in here. So basically what it says is it has an object and the object contains question, or lead score, lead score reasoning, next step. And sometimes what the AI does is it adds outputs. So I want to have an object that has outputs, and this output includes the question, next step, next step reasoning, and the lead score as well.
Okay.
Um, so we are good to go on that. And what you can do is you can select everything and like restructure. You can rename this. OpenAI.
I just want to make them shorter so they don't jump onto each other. And output. Okay.
And so this is going to reply to the— All incoming items binary file. I think it was just text.
Yep.
Text. And we want what the AI agent is giving us. So we're going to do another test here. We're going to do all incoming items for now. And basically, another thing I want to do and want to show you is a very simple One, we're going to connect to iLevel API V2. So, we're going to create a new credential.
Okay.
We're going to use the white label, and then what we need to do is go to marketplace.golevel.com. Sign in. So basically what you need to do here is create a new client key. So add a key, you can name it N8N, and add. And it's going to give you a client ID, client secret. And I'm just going to remove this because I already have one, but this is what you need to do to generate that. And then what you need is to copy all of this scopes in here.
Separate scope by space.
And I think there are double spaces. So what I'm going to do is go to Visual Studio Code and I'm going to replace the double space with only one space. Okay. So now we are good and we can paste this in here. Connect to my account and it should work properly. So, please log into your CRM. Connection successful. Okay, so I had some issues because I had a whitespace here at the end, but now it's connected to my client ID, my client secret, so we can keep moving forward. Okay, so in here what I want to do is actually update a contact, and the contact ID is going to be the one that we get from the webhook, and the field we're going to update is going to be the first name. Okay, and we're going to let AI define automatically by the model, and we're going to rename this update first name. Okay, rename. Okay, so now we can clean this up. Update first name. And basically what we need now is we can update the prompt, telling it, uh, the goal. So we're going to add zero.
So if first name is empty, and we're going to do FirstName is empty.
Okay, so now we have Maxim, so it says Maxim, but if we didn't, it would say FirstName is empty.
Then we would need to ask a Hey there, what's your first name?
And then we would need to, uh, so basically what we can do is we can change this here. We can add First message, if first name is empty. Hey there, what's your first name? So we can start at one like the other.
If first name is not empty. Start the qualification flow.
Okay, so we're gonna start this, and everything is hardcoded here. It's not complicated. First message, you, you saw I wrote this. It asked us to get JSON in the prompt, so that's what I've done here. JSON. What's your first name? So we can remove this one because it's redundant. And basically ask a series of questions and at the end score the lead, give a reason for the score. And so let's test this. We're going to test using the same person. Boom, boom, send request. And if we go here, it's going to talk to the agent, respond to the webhook, and then we can see, hey Maxime, so you're looking to scale your coaching business, right? So now we have the AI agent to work, and it is going to keep doing this until we reply. And for example, here, if I do the message, if I hardcode this, we're going to say yes. So we're going to test again.
So we need to turn it on.
We're going to say yes. It's going to remember that this is the reply to the previous message. So memory You can see chat history. Hey Maxime, so you're looking to scale your coaching business, right? And now I say yes, so it is going to reply with, cool, I appreciate you sharing. What client acquisition method have you been using so far? Ads, outreach, blah blah blah blah blah blah. Okay, so all of these questions are hardcoded now, but if you want to, change this, you can change it. Like, I've hardcoded this to make it easier, but, uh, generally what you want to do with an AI agent is to make it ask questions and flow the way you want.
Okay.
Oh, one thing I didn't do is actually call the update first name, so we're going to update the first name So we're going to do it like this.
Then call updateFirstName to update. Then call updateFirstName.
Okay, so now what we're going to do is we're going to do a test with the first name being empty.
Okay, so let me revert back to this.
We're going to test again. Okay, we need to turn it on, test the workflow, and now it should give us— send test request. We already have, if you don't mind me asking. Okay, so we already have the history of the conversation here. So let's just remove the memory just to make sure that it's doing the process properly. So we're going to test again without the memory because that's going to be the first message.
So, Maxime, send test. Boom!
And it should have asked us, "Hey there, what's your first name?" Because you can see here the first name is empty, and now it's asking us what's our first name.
So we're going to reply with Max. Test again.
We can say Maxime. Okay, so we're gonna reply with this, and it should use the update first name to then update the first name. Boom, you can see it did it. First name is Maxime, and item exists but there Empty. So it worked. And then, so you're looking to—
then it asked the person.
So contact first name, body. So it's back to normal. Now I need to remove this to not be in test. Save action. Save. And we have our AI agent qualifying people based on a series of questions that are hardcoded, but that you can update the way you want. One thing I've done as well is a little bit more advanced, but I added some steps here to have the full conversation from GoHighLevel because I use the conversation from GoHighLevel then to remind the AI agent things that we said in the past. Even if you have the memory here, it's not going to remember everything. And it's actually, we feed the AI agent with the full history before we call it. So we can have access to the full history inside of the prompt as well. So that's it for this video. Let me know if you guys have any questions and I will see you guys In the next one. Peace.
Peace.
More from Maxime

I was talking to one of my clients' husband today and she's very not tech savvy and her hu

Most of the time we undercharge in the marketplace because we feel we do is not valuable e









