Okay, so here we go.
I'm going to get rid of the logs.
I'm going to add a first step.
It's going to be on chat message.
We'll keep it simple to start with.
We'll come back later and juice it up.
Let's add in an AI agent.
It's like the stuff is so old hat to you.
We'll we'll also tidy this up at a later point.
We'll add in a chat model.
I'm going to use OpenAI.
You can use whatever model you like.
We'll use deep seek earlier in the week.
You could stick with that.
I am going to pick like a top frontier model.
I'm going to pick GPT 5.2.
Uh, and uh, that's that's definitely the one that, that I'd like to, to pick for here.
Um, but you can, you can feel free to, uh, to use whichever one you want to use this.
This should be very cheap, but obviously a mini would be, would be even even cheaper fractions of
a cent.
Um, and I'm going to add the option reasoning effort low because I want it to be quick and relatively
cheap using 5.2.
So that is a sensible choice.
That is our model.
We're not going to bother with memory because this isn't going to be a conversation.
It's going to be one message in and then the results come out all right.
And now it's time for us to think about what we want to do with Pipedrive.
And so let's go to tools as that.
It would be the most natural.
First choice would be let's equip our agent with tools that will allow it to take a message like, please
load this person into Pipedrive.
And then to do that in Pipedrive.
And indeed there is a Pipedrive tool.
It's right here and we can come into it.
And uh oh, it already knows my credentials, so I will wipe that so we get to set it up.
But, uh, we then would choose, what do you want it to do?
Do you want it to create a lead, an organization or a person?
And if you create a lead, which is what we want to ultimately do, it needs to be associated with an
organization with an ID.
So we would have to do that.
And similarly, if we, if we, uh, we'd want to create an organization and we'd also which, which
needs a name.
And here you'll see an example of something which is a bit tiresome, which is that there are some constraints
around some of the way that these things work.
It appears that unless it's just a current temporary feature of this tool, that you can't actually
get the model to set the name of an organization when it creates it.
However, you can do it when it updates an organization.
There you go.
Let the model define this parameter.
So we'd actually have to have a tool to create the organization and then update its name.
We'd have to create it with a with a temporary name in there.
So there would actually need to be four different tools that we need to equip the LM with.
And we need to teach the LM to take the ID that it gets back from one tool call and put it into another.
And now that's expecting a lot from an LM because it's quite fiddly.
And to be honest, it's something which lends itself really well to code.
We're simply saying, look, always call this first with the ID that gets returned from this, I want
you to call this.
So it's really a set of of workflow steps.
It's a set of steps that should happen one after another with the data from one going into the other.
And that should be a flag for you.
That should be a bit of a red flag for tools.
We don't need autonomy here.
We don't want to give the LLM that much flexibility.
It seems like a better use case for using workflow for using core nodes, not tools.
And that's why your mind should be going to to structured outputs.
This is a great example of where structured outputs and workflow is going to perform better than tools.
Okay.
So I'm going to delete this.
Get rid of it.
From there we're going to stick with this.
And we're now going to build out something which is going to need the agent to produce structured output
in a format that's going to be perfect.
So let's do that.
We're going to to come in here and we're going to say I do require a specific output format.
And once I've done that, you'll see that the output parser has appeared.
And we will choose a structured output parser.
Here we have it.
Okay, so the agent is going to be responsible for taking in some input in text that describes some
lead.
And outputting that same thing turned into something that's structured and organized based on its understanding.
So the JSON that we want is going to have something that is going to describe a lead.
So maybe it's going to have like name the name of the lead, the full name of the lead.
Company.
The company where they work.
Role.
Their job title.
Email.
Their email address.
That's it.
So we're using an LLM to take natural language as an input and output it.
organized and structured in this form.
It's a great application of llms.
They're great at taking structured data and turning it into something that's unstructured.
Uh, and the other way as well.
Uh, either way, they can they can parse and they can parse.
Uh, which is, which is part of their magic.
Uh, so this is going to be a really effective way to use GPT 5.2.
Okay.
Now I'm going to go back to the, uh, agent, and I'm going to set a system message to tell it what
we want it to do.
Basically what I just said, instead of that, I'm going to say this based on the input from the user,
you should reply with a structured version of the lead.
Your reply will be sent to Pipedrive to create a lead record.
It's a bit clear based on the input of the user which describes a sales lead.
There we go.
That seems very clear to me.
So nice.
Simple directions.
It's taking some unstructured data and it's turning it into something that can be put in Pipedrive in
JSON format.
All right.
So far, so good.
Let's come over here now.
So this agent is going to take some chat message.
It's going to turn it into that structured output.
And I'm saying that's kind of equivalent thinking of it as making tool calls.
Because what we can now do is put in in here not a tool but a workflow step.
Pipedrive of course, has a um, a node which has node operations, which includes an operation to create
an organization.
And that's the first thing we're going to do.
We're going to create an organization, uh, and we're going to I'm going to come back to this in a
second.
But when we've done that, we're then going to also use a Pipedrive node.
And here we are going to come in and we're going to create a person record.
So create an organization and then create a person.
Here we go.
Create a person.
And once we've done that we are then let's resize this.
We are then going to do another Pipedrive node.
And finally after doing all of this we're going to create a lead.
So you can see what I mean.
We're just laying out the uh the workflow here.
Here it is three steps based on the JSON that gets outputted from this agent.
Create an organization.
Create a person, create a lead.
Because we just wanted to do it in that order.
There's no point in giving that as a bunch of tools to the model.
We might as well lay it out.
Now we just have to populate these.
Well, the first step to populating it is to set the API key.
And that's pretty simple.
You can see I deleted my the one that was already there.
I press Create New credential.
I click here and I paste in the token that I've got over here from Pipedrive.
Let's go and copy that now.
Okay.
So obviously I go to Pipedrive.
I go to Personal Preferences.
I click on API.
Press the green button to copy your API key.
Come back over here.
Come in here.
Select credential.
Create a new credential.
click here.
Paste in your token.
Press save.
Drum roll.
Green.
Successful.
Congratulations.
We're connected to Pipedrive.
It automatically does that to all of these guys.
We are in good shape.
Next up we need to populate the name of this organization.
And we also need to populate the name of the person.
And we need to populate details of the lead as well and how to associate it.
For now I'm going to leave all of this blank.
I just want to kick this off and see what happens, so I can populate the data so that we can do our
drag and drop stuff.
Let's do that now.
Okay, so when we test this out we're just going to have to turn these guys off.
Otherwise they will complain because they're not populated yet.
So I'm pressing the power button on all three of them.
So they're all turned off.
Then we'll start up the chat and I'll say, please record this lead.
John Smith, CFO at IBM, John Smith at IBM.
Com.
So this is going to be just natural text.
And the other way of doing it would be for this agent to be equipped with various tools and to try and
call all the different tools, but that's not what we're doing.
Instead, we're telling it to use structured outputs to return that unstructured form and pass it on.
And this is what it returned.
And you can see it did just that.
And we can think of this as being analogous to to calling a series of tools.
But that's what we're actually going to do ourselves in this workflow right now.
Okay.
So let me just clean it up with that button.
Let's hide this for a moment.
Let's come here.
Let's reactivate this guy.
Let's double click.
In we come.
So this is creating an organization.
What name do we give it?
In the past we've said let the model decide.
But we can't do that because it's not a tool.
It's just part of the workflow.
We have to select the name.
Well look we have the name right here.
Sorry, the name of the company right here.
It's an organization.
We just drag that in.
It's of course dollar JSON output company.
There it is.
IBM is what will be populated with.
Done.
Okay.
Next.
This one over here.
Turn the power off.
Double click.
It's a little bit more involved because we can't take something from the previous node.
We have to go back one node.
And if you don't remember the syntax for that it's quite easy because over here on the left, if you
scroll down, you'll see that it has the prior nodes.
You can just expand a prior node.
The AI agent is the node we care about.
And here you'll find this is the person record the name John Smith.
That's what we care about.
Drag it and drop it.
And that is the expression dollar AI agent JSON output name.
Fine.
You can have your cunning expression.
Uh, we believe drag and drop work just fine.
This is going to work.
Thank you.
Uh, so that is the name now populated.
Okay.
Escape.
Next.
Okay.
And now the juicy part.
We want to create a lead in our database.
This is what we're really trying to do all along.
We're going to turn the power back on.
We're going to double click.
Here it is.
We need to create a lead.
The lead needs a title.
Now we can populate that with a title that we want for the for the title of the lead.
We can have this be something like, uh, we can have it be the name of the of the person, I guess.
And then, um, and then the, the, uh, the, the lead next to it.
So to do that again, we scroll all the way down, we find the name of the AI agent that is the node.
And we're looking here probably for, for the, the title of the lead should just be the name of the
person I think.
Um, and because normally the lead represents a potential deal.
So this is something that, uh, that could turn into a deal, but I think that's probably how you'd
normally do it.
We want to associate it with an organization and that has an organization ID, and this is where we
might get a bit confused because where are we going to find that organization ID from?
The AI agent didn't tell us the organization ID.
Well, I have news for you that is going to come from this node right here.
When we create an organization, it's going to output the ID and it's just going to be called ID.
And so we can actually take this ID here and drop that in here.
And we're seeing that we're getting create an organization.
That's going to be the organization ID okay.
And you know what we want to lead to be associated not just with an organization but also with a person.
And we can populate a person ID and we want that to come from this node.
Create a person that also has an ID that comes in the response.
These are coming in.
That didn't work.
Uh, expression uh, these are coming in the response back from uh from from this, this previous node.
So I dropped that in there JSON ID because it was just the last node.
And that is now going to, to populate the ID that came back from that prior node.
And we're done.
This should be it.
So I'm just going to recap in case you weren't following me there.
So we're taking all of the data that's flowing in from prior nodes and using that to populate this new
lead record.
And in fact, there are there are three things.
We're setting the title of the lead overall.
We're just setting it to be the the name field that came in from from the agent, the organization ID
and the person ID that we're populating based on the output of creating those records in Pipedrive from
from these prior two nodes, they both output an ID and we're pushing that ID in when we create the
lead.
And that's such a great example of stitching together data.
And it's I hope you I hope this is a eureka moment for you, because you see how much better suited
this is to a workflow in N810 when you're managing the data using a product that's ideally suited for
it, than trying to futz around with tools and telling the agent, hey, you've got to move the ID from
the output of this tool to the input of this tool.
That would be messy.
This is going to work great.