Okay.
That was the first of our two agents and the bigger of the two for sure.
And very satisfying, I have to say.
And now for the second one.
The second one, the first one was the outbound sales.
The second one is the account executive.
The person that takes inbound calls.
The account executive agent is going to have just two subagents, one of them that is able to record
that a deal is in progress and the other is able to book a demo.
These are the two activities that will be carried out by Subagents under the watchful eye of the account
executive.
Let's go and build them.
Okay.
Here we are in our amplify project.
I'm now going to go and create a new folder and I'm going to call it Account Executive.
There we go.
So we now have our business development and our account executive folder.
Nothing in there just yet.
Let's go in and create our first workflow.
And our first workflow which is going to be called the deal according Subagent.
Okay.
What is this deal recording subject going to do?
Well, let's begin with it.
Having a trigger of a chat message, uh, which we will change later.
And it's going to, as usual, go straight in to an AI agent.
There it is.
Okay.
What are we going to do with this agent?
Well, I'm going to start by having it use the usual OpenAI chat model.
You may pick your own.
I'm again going to go with my favorite GPT 5.2, which will give me nice and strong model.
There it is.
And but I am going to tell it just to have the low reasoning effort, uh, just so that it's nice and
quick and doesn't take too much.
There we have it.
Uh, we, uh, we we won't need memory because we'll just be giving it one instruction at a time.
And now it's time for us to look at the tools.
So what's this agent going to do?
It's going to be informed that some customer is interested in having a demo, which means that it's
time to record that this customer is potentially in a deal flow in our CRM in Pipedrive, you say that
you've got a deal.
And in something like Pipedrive, not necessarily because you've yet won the business, but because
there's somewhere in the deal pipeline that hopefully will close and become a deal in the future.
So that's what we want to do, which means that really, this AI agent needs to have the ability to
read from Pipedrive, to find out the people who've got in Pipedrive to identify a person and then to
be able to create deals.
Now, here's the thing.
I'm actually going to use tools and structured outputs.
In this case, I'm going to use a tool to read all of the people, but I'm going to use structured outputs
to write the new information so that we can be crisp and and bulletproof about it.
And that seems like a good balance to me.
Now, of course, you might say, how did I come up with that?
And the answer is you should experiment and you should see what works best.
I know you know this saying, shut up and get on with it.
All right.
So we're going to add a tool which is going to be a Pipedrive tool, which is going to be the tool to
get people.
We're going to want to have a resource will be a person.
And I'm going to make this to be get many.
And as I say, if you were building this to be something that's ready for prime time, you'd want to
put in filters here and have the model be able to filter on the people it's looking for, but I'm just
going to have it return all for for this so that we don't get bogged down.
And that's going to be fine up until a reasonably large number.
Uh, so that's how it's going to work.
It's going to get all of the people, and that should work just fine for this.
And now we want the agent to output structured outputs okay.
So I open up the AI agent.
Here it is.
I am going to first give it a system prompt so we know what it's going to do.
Here we go I'll paste one in.
You're provided with a potential name of a person in the Pipedrive database.
You use your tools to see whether that person is already in the database.
If there are duplicates, you pick one reply with the details.
You find a deal will be created in Pipedrive as a result.
That's super clear.
So now we need to require a specific output format.
Let's go back.
Now we've got this here and we're going to say structured output parser and define the output we want.
And here we go.
I'm going to have it be a JSON object with four fields found.
Whether or not the person was found in the people, the id the person ID goes there, the company,
the company name goes there, the name, the person's name goes there.
Very simple, very clear.
That is going to be our structured output.
And then based on that output we can then create the records in Pipedrive.
Okay.
So from what comes out of here let's put in an if node.
If node, because we know that that this is going to come up with an output.
Uh, let's make this an expression.
And we know that what comes out of the previous cell dollar JSON output dot.
And then one of the fields is called found.
And if that's true then we have found a record.
If it's false we have not.
So now to not make the mistake I made before we go Boolean is true.
There we have it.
JSON output is true.
That's the Tesla we want to make.
We are either going to go true or false.
If we go to true, then what we want to do is we want to carry out a Pipedrive node, a node action.
We want to be to create a deal.
Create a deal.
All right.
So what's the deal title going to be.
Well, we'll have the deal title be this Jason name which is the name thing coming from from the the
AI agent followed by the word deal.
So if the person's name is John Smith, it will say John Smith deal.
That will be the expression we'll use there.
Uh, and we can associate it with something.
Let's associate it.
We choose between either associating a deal with an organization or with a person.
Let's associate it with a person.
We have to provide a person ID.
Well, we have one of them.
An expression uh, the expression should be dollar JSON
output.id.
That was the field coming out of our AI agent that is populated with the ID.
So now we have called it John Smith deal, and we've linked it to John Smith's ID, and John Smith is
the person who was found by the AI agent and outputted in the structured outputs.
Right here.
You see found is true.
That's the ID and we've taken, uh, their, uh, their name and put the word deal at the end of it.
Okay.
So this let me tidy it up for you.
There we go.
So this should create a deal for a person if they are in the database.
Time to give it a try.
Just before we give it a try I did some tidying up.
I just added to stickies and then I added a couple of push notifications just so that we we are kept
informed about what's exactly is going on.
Uh, make sure my phone is not on silent.
Uh, okay.
And with that, we can now give it a try and have some, some visual to it.
Okay, so I bring up the chat and what I'm going to say is if we look in Pipedrive, let's look at one
of our leads, Rob Carter.
Uh, let's now come back here again and say, uh, record that Rob Carter has become a deal.
And let's see what happens.
Off it goes to our chat model.
It's reading people from Pipedrive.
It's done something and I got it.
Did you hear that?
I got a push notification and it created a deal.
And if I go back to my leads inbox here, there is a section on deals.
And there we have Rob Carter in there as our deal.
We have our first deal in Pipedrive.
That was pretty easy.
Uh, excellent.
Onwards.
Okay.
So now what we're going to do is turn this into a subagent, remove this chat received and add a new
trigger node.
And in the past we've, we've put in here when executed by another workflow.
I'm going to do it differently this time for reasons that will become clear.
But I'm going to have it be on webhook call.
So the way that you trigger this is by hitting a URL, and we'll hit it with http post as we did before,
which means we get these URLs that you can hit if you want to do it.
Um, and, uh, this all looks fine to me.
I think everything's good.
We'll have this one respond immediately.
We won't make it.
Wait and then respond later.
We'll just have it respond back immediately.
And that's what we will do.
That's going to be connected in here and in here.
We just have to come in here.
It's no longer expecting this.
It's now needs to be defined.
Below we'll have an expression.
And so an expression needs to be in double curlies.
And you may remember that it's it's got to be dollar Jason.
That's the name of what comes in.
And we'll assume that name that will be populated with name, which is going to be the name of the person
in the in the Pipedrive database.
So that is, uh, is what we're after.
And that has now set this up to be a, uh, ready to be called as a webhook.
And what we can now do is save it as already saved and publish it.
And that will now be published out there waiting on its webhook that we can take later.
Excellent.
Now, on to the next Subagent.