Hello.
Welcome back to the course.
Today we are going to build something really exciting.
A complete human in the loop AI sales agents system using N810.
So this is going to be a game changer for anyone doing a sales outreach.
Because instead of just sending automated emails, these agents will write the first draft for us,
then send it to us for approval or feedback, and then either send it out or revise it based on our
input.
Now what's really cool?
We can do unlimited revisions until we are completely happy with the result.
So we are going to learn a new concept today.
The human in the loop methodology, which is absolutely essential for most use cases in production ready
setups.
Implementing the human in the loop approach makes our automations more production ready.
So it's what separates amateur automation from professional grade systems that you can actually rely
on in your business.
So it's the difference between a cool demo and something you can actually put into production and trust
with your reputation.
So by mastering this concept today, you are not just learning how to build one workflow.
You are learning a fundamental principle that you can apply to dozens of other automation scenarios.
So whether it's content creation, customer support or any other business process where quality matters.
This is very important concept.
By the end of this tutorial, you will have a complete system that can automatically detect new leads
from Airtable.
As you can see here.
So the Airtable is our CRM in that case.
And I have created two bases.
The first one is for leads.
So new incoming leads are saved in this base.
So as you can see the name of the lead, email the company name, intent, budget and the project they
want us to build.
So in that case, looking to streamline internal ops using agents.
And we also have a timeline.
And the second base is for projects.
So here we can include the projects we've built in the past.
So the first AI agent can write more personalized and convincing emails based on this project.
Because based on this information can refer to the projects and the results we are able to achieve.
So the first agent is the sales agent, which writes personalized sales emails using the large language
model of of our choice.
In that case we are using cloud from anthropic, then sends drafts to you for a human approval.
So that's why it's called human in the loop.
And as you can see here, this is the email I received.
And I can either approve it or request a revision by clicking on respond.
Here I can I can give a feedback.
So for example please make it more concise and submit.
Yes.
So the revision agent accepts feedback and revises the emails and loops back for more feedback.
Until until you are satisfied and finally sends the perfect email to your list.
Now let's do a quick demo so I can show you how this setup works in action.
So as you can see, the workflow is currently active and this node will trigger.
Node is watching for a new lead coming to our table.
So our CRM.
Now when I go to this base and adding lead let's say Raymond Dunn.
Email Nathan demos gmail.com.
Company.
And ah it should be here.
Just copy and paste it here.
And intent.
The client is looking for an agent.
And the budget is.
One project description let's say, is going to copy this.
So need an agent to handle inbound service requests and book technician appointments and paste it right
here.
And this project is urgent.
And now when I go back to our workflow and hit test.
As you can see, this node detects Anglet.
And our sales agent is preparing a personalized email based on the inputs.
And now the system sends the draft email for our approval.
When I go to my Gmail inbox.
And refresh it.
As you can see, approval required for delete from company 1 to 3 is looking for an agent.
The budget is 5 to 10 grants with an agent.
Next 1 to 3 weeks.
Timeline.
Please approve or decline the sending of this message generated by our agent.
Subject.
Transforming your Service requests with Agent Adaptive AI.
The company 1 to 3.
I hope this finds you well.
Thank you for reaching out to adaptive AI regarding your AI voice agent project for handling inbound
service requests and booking appointments.
We are excited about the opportunity to work with you and deliver an exceptional solution within your
Argent timeline of one two weeks as adaptive AI.
We specialize in developing cutting edge solutions tailored to our clients specific needs.
Your project aligns perfectly with our expertise and we are confident that we can exceed your expectations.
Let me share relevant success story that demonstrates our capabilities.
Recently, we developed an invoice agent for appointment booking for a client in a similar industry.
The results were impressive.
So we have 65% reduction in missed appointments, 28% boost in lead to booking conversions and seamless
handling of incoming calls.
Lead qualification and appointment scheduling.
And now when we check our second base.
So the project base and we check the project I was agent for appointment booking.
As you can see, you have the same information here.
So build a voice agent that answers incoming calls, qualifies leads and schedules consultations.
Results 65% reduction in missed appointments and a 28 boost in lead to booking conversions.
So our AI sees agent based on the request from the client.
So based on this product description.
Checked for us the second base.
So the projects.
On the relevant project.
So AI voice agent for appointment booking.
And based on the details and based on the projects details crafted a personalized emails which can be
sent to our lead.
So now you can either Approve this email or ask for any improvements.
So for the project, we envision crafting a sophisticated AI voice agent that will efficiently manage
inbound service requests intelligently book technician appointments, improve customer satisfaction
through quick and accurate responses.
Optimize your team's workflow and productivity.
So, given your urgent timeline, as you can see in the list base, the project timeline is urgent.
So next 1 to 2 weeks.
We prepared to fast track the development process without compromising on quality.
Our agile methodology allows us to deliver high performing AI solutions within tight deadlines.
To discuss your project in detail and provide you with a tailored proposal, I would like to invite
you to book a call with me.
You can use this link to schedule a time that works best for you.
So I included the link to my calendar in the prompt in the system prompt for our sales agent.
As you can see here.
Right here.
Include the link to book a call using this link.
So this is the link to my personal calendar.
And when I open it.
The potential customer is able to book a call with me.
So thanks to that, you will never miss a warm lead.
And during our call, we'll dive deeper into your specific requirements, discuss potential features,
and outline a clear roadmap for delivering your voice agent within the next one two weeks.
You are eager to help.
Company 1 to 3 Revolutionize its service request handling and appointment booking processes.
Let's work together to bring your vision to life.
Looking forward to speaking with you soon.
Best regards.
Damien SEO.
Adaptive AI.
So I believe this email is quite good but is a bit lengthy.
So I would like our revision agent so the second agent to improve it.
So I want our revision agent to make it shorter.
So when I click on respond button.
I can request something like please make.
Shorter.
Thanks.
And now when I click when I hit submit.
As you can see, our revision agent is working on a revision, and this agent is also using a cloud
model.
By the way, I believe that the cloud model is the best on the market for writing emails because it
sounds very natural when it's prompted properly.
And now I should receive a new email.
So let's check my inbox.
Let's refresh it.
Yep.
So, so from company 1 to 3, please approve or decline the sending of this message generated by Jim.
Elevate your customer service with a voice agent.
Adaptive AI's expertise.
The demon.
Thank you for your interest in adaptive AI services for company I was agent project.
We are well equipped to meet your 1 to 2 week timeline and 5 to 10 K budget for revolutionizing your
inbound service requests and appointment booking.
Our recent successes demonstrate our capabilities.
A Vos agent for appointment booking.
The same information.
So the numbers and the second example.
As you can see, our sales agent was able to retrieve this information from project database.
So the second base from our Airtable.
So customer support automation for eCommerce delivered a 24 seven AI chatbot for customer support.
It handled 82% of incoming queries without human escalation and improved response time by 70%.
Is correct.
So these results showcase our ability to deliver efficient, high impact solutions quickly.
I would like to discuss how we can tailor our agents for company.
I think it's great.
I'm really happy with that.
So I'm going to approve it.
Respond button.
And just type approved.
And hit submit.
As you can see workflow successfully executed successfully.
So the email has been sent.
And it should be sent to the email our lead provided.
So let's check.
All right.
Okay, so elevator customer service.
With voice agents.
And now we can see the formatting.
The.
Damon, thank you for your interest.
All right.
Amazing.
I think it's I think this email is convincing and it's a good example of a good sales email.
You also have a link to my calendar to not to not miss any opportunity.
Okay.
Great.
So now I'm going to show you how to build this setup step by step from scratch.
So let's dive right in and build this step by step from scratch.
All right first things first.
We need to set up our Airtable base because this is where all our lead data is going is going to leave.
So I'm going to create two tables.
So the first one is going to be called leads.
And this is where new form submissions will go.
So basically you can create forms with all these fields.
And then when a new lead submits a form all the data will be saved in this table.
And the second table will be projects.
So this is going to be our database of past work that the I sales agent can reference to make more convincing
sales emails.
So let me show you how to build it from scratch.
So first you need to go to Airtable.
Com.
Or just simply Google it.
Table.
And you need to create an account.
If you don't have one yet.
Then please log in and what you need to do.
You need to create a workspace by simply click on this plus button.
Let's say human in the loop.
This is our project.
And we want to create this workspace from scratch.
So start from scratch.
Build your ideal workflow starting with a blank table.
All right.
And let's call this base.
Human in the loop.
Let's change the color to orange.
Or maybe blue.
And now the first table.
As you can.
If you can remember, it's for storing list details.
So let's and hit save.
All right.
So now we need to create all the fields.
So first we have a name.
When we double click on it you can choose the type of the field.
So in this in this one we want to be uh.
So for this one we want it to be single line text.
Then uh let's remove this one.
So delete field.
Actually let's remove all of them.
Okay.
So the next one will be will be the least email.
So let's search for email.
And you can as you can see automatically we have an email type.
Let's call it email create field.
The next one.
We want to include company name.
So it will be single line text as well.
So company name.
Create field.
Then intent.
So basically what they are looking for.
So again single line text.
Intent.
Create field.
The next one budget.
So it will be single select.
So you can include different budget ranges.
Budget create fields.
Of course as always I'm going to provide the copy of this base.
So these two tables in the resources section of this lesson.
But I want to show you how to create the tables in Airtable from scratch.
So then you will be able to create tables from scratch yourself and use Airtable as a CRM for your future
automations.
All right.
So now we have budget and we need to provide some options.
So you need to double click on the first field.
And as you can see there is no option to choose I'm going to check what you have here.
We have in progress to do.
Done.
So let's add the three.
So to do in progress.
Done.
So double click and just start typing to do and hit enter.
Now let's add in progress.
And hit enter to add option.
And now when you want to check what budget options there are to choose from in the second field.
So for the second lead it has been saved.
So let's add done.
We also have 5 to 10 k.
210 K.
0 to 5 k and ten k up.
I create.
The next field is product description.
The long text.
So looking for long text.
Project description.
Create field.
And timeline.
This is single select.
Swell.
To do in progress.
Done in Argent.
So let's add all of them.
Okay.
So it's a single select.
Timeline create field.
Let's add all the options.
So again you have to do in progress.
Done.
Double click type to do save.
In progress.
And.
Done.
Enter.
And also Argent.
Next 1 to 2 weeks.
The last option.
1 to 2 weeks.
Okay.
Great.
And the last field created will be automatically created once the new lead comes in.
All right.
So now is the time to create the second table.
So yeah our sales agent will be able to check this table and collect better emails.
So you can click on this drop down at table.
Start from scratch.
And name it projects.
It's safe.
We don't need attachments.
Status.
Right.
Now, in the projects table, we have project and details.
And this is single line text.
And this is long text.
Project single line text.
Save and long.
You can also search it right here.
Text.
And details.
All right.
Amazing.
So now let's move on and jump into an item to create our system.
Again, you can easily download this template from the resources section of this lesson and simply import
it by clicking on this three dots import from file and so on.
But I'm going to show you how to build the setup step by step from scratch.
So now let's create a new workflow.
Now we want this system to be activated when a new lead comes into our Airtable.
So our CRM.
So first we are going to add a table sugar node as a first step.
So at first step search for a table.
Press on that.
So our workflow will be triggered on new Airtable event.
Now what we want to do.
We want to connect our table account and the tables we just created to our workflow.
So we need to set up credentials.
So simply click on this dropdown create new credential.
And as you can see API key this type of connection API key was depreciated and can be used anymore.
Please create a new credential of type access token instead.
So we can't use this option anymore.
We have two access token.
And you have to make sure to enable the following scopes for our token.
As you already know, N810 has a brilliant documentation, so you can open docs and follow the instruction
from here.
Step by step, just go through it.
And you will find exactly the same information as I'm going to provide you in this part of this lesson.
But I will show you everything visually so you can follow me.
All right.
So now let's go to our Airtable account.
And I can't press on that.
Scroll down, click on go to Developer Hub.
Click on create token.
Create new token.
Name it somehow.
Let's say human in the loop.
Now we need to add scope.
So let's go back to our workflow.
As you can see we have to add data dot records read write and schema dot read.
So add scope data records read.
Data records right.
So basically this node will be able to create, edit and delete records in our table.
And the last one we want it to be able to see the structure of a base like table names or field types.
Right.
And also this token.
Should access the following bases and workspaces.
So you can only grant access to bases and workspaces that you have access to.
So add all resources.
So by doing this the connection we are setting up now will allow access to all the bases we have created
and will create in the future.
But you can restrict it to just one base.
So basically the human in the loop base just created.
So I'm going to leave it like that and click on Create token.
Copy our token.
Confirm.
Go back to our workflow.
Paste it right here and hit save.
As you can see credentials successfully created.
Great.
Now we want this trigger note to watch our table.
So the this table every minute.
But it's completely up to you.
You can change it to every hour, every day, every week, etc..
Now you want it to.
Check the base by ID.
So go back to your base.
And after this slash this is your base ID.
So up everything after up.
All right.
Great.
So let's copy it before the second slash.
And let's paste it right here.
And you also want it to search by ID for a table.
So the same table is the second piece of this URL.
So table copy it and paste it right here.
Now the trigger field.
As you can see I created time or last modified time field that will be used to sort records.
If you don't have a created time or last modified time field in your schema, please create one because
without this field trigger will not work correctly.
And when we go back to your Airtable.
table.
And now when I add a new field.
So create created time.
Name it created.
Hit create field.
As you can see, this field is automatically populated.
Alright, great.
Let's go back to our workflow.
And type the same name so created.
All right.
Amazing.
So that's it for this note.
We have done all the configuration.
Now let's move on.
Excellent.
Now we're gonna get some data into the flow.
So make this workflow active.
Confirm.
Now let's go to our tables.
Let's provide some dummy data.
Damon.
At gmail.com.
Company name.
Was agent.
Let's sign this one for the project description, let's say.
AI voice agent.
Handle.
Calls.
Timeline.
Agent.
All right.
Great.
Now let's go back to our workflow.
And click on Test Workflow.
Let's open the node to see the output.
And as you can see we got all the data we just inserted into the table.
So the name the email the company name intent budget project description agent to handle inbound calls,
timeline and created.
Of course you can also switch to schema and to JSON format.
All right.
Amazing.
Let's move on.
Now in the next step we want to add our sales agent, which will be able to process all this data and
push it to the next node.
So let's add an agent.
Let's define below.
So use an expression to reference data in previous nodes or enter static text.
And for the prompt we want to inform our agent that this is incoming lead.
So let's say let's switch to an expression mode.
Let's explain it.
Coming.
Lit.
And you have to list all these fields.
So the first one name and simply drag and drop.
Then email.
Next we have company name.
Intent.
Budget.
Description.
Timeline.
And created fields.
So thanks to that, our agent will be able to retrieve this data dynamically.
So it is not hardcoded.
Like right now we require specific output format.
Right.
And now we want to add the system prompt.
So at option System message.
Let's switch to expression and expand it.
Now I'm going to paste the prompt I prepared.
And again when you import the template into your canvas it will be already set up for you.
But you can easily modify it if you want to.
So the prompt is overview.
You are an expert salesperson for an agency that delivers solutions.
Your job is to respond to incoming leads by addressing their needs in a professional manner.
You will receive information like the leads, project description and timeline, and your goal is to
convince them that we are the best agency on the market.
But the tools.
We have a project database.
So we are going to connect our second table.
So the products table.
So the agent will be able to reference to that.
So the product database is to use this tool to search through previous projects.
We have completed rules.
You will receive information about a lead and you need to craft a concise and professional email.
Your main objective is to convince the lead to book a second call.
Make them believe that we can deliver the project and exceed expectations.
Retrieve information about relevant past project to include as proof of capability.
Mention the client outcome or results we help them achieve and here include a link to book a call using
this link.
So here you can paste the link to your calendar email signature.
Sign off emails as Damien CEO at adaptive AI.
And here we are providing the current date and time for our agents to make sure it will not make mistakes.
Of course, you can modify and change this prompt to meet your needs for your specific use case.
Alright, great.
Now let's move on.
So we've done the configuration of this node.
So you can just carry on.
Now as you can see you have some issues.
So no node connected to required input model.
So we need to provide brain for our agent.
So in this workflow we are going to use code from our topic.
But I'm going to show you how to do it later.
For now let's add the tool.
So we are going to add the second table we've created earlier.
So the project table.
So let's search for a table.
Alright, great.
Just make sure we are connected to the correct Airtable account.
So in my case it was a table.
Account two.
Of course, you can rename the name of the connection.
By setting it up.
Alright.
Great.
So two description set automatically resource record.
Because we want to retrieve a record operation, we want to search for specific records or list all.
And we want to retrieve a base from a list.
So we want to connect to the human in the loop base.
As you can see.
And table.
We want to use projects, not least because we want to give our agent access to the previous project
we've done in our business.
We want to retain all.
Right.
Great.
Yes.
So leave the search criteria empty so all the records will be returned.
We don't need to add any option and to add any sort rule.
Okay.
Great.
Let's let's move on.
And let's rename it.
Project database.
Confirm.
Okay.
Now we don't want to add a memory for our agent in this workflow.
So now let's add chat model.
So basically we need to set up our large language models.
So we are going to use two different models in this workflow.
First drag in an anthropic chat model.
So this is going to power our main sales agent and revision agent.
And I'm using cloud because it writes really human like emails.
So we'll need to add your anthropic API credentials here.
So let's drag the search for anthropic actually by clicking on this plus button to add the chat model.
Anthropic chat model.
Okay great.
Now if you don't have an account connected to an A-10, I'm going to quickly show you how to do it.
But you can also find a dedicated tutorial in the How to Set up credentials section, where I provide
more information.
First thing first you need to create an account.
So head over to console.com.
Provide an email address.
Go to your email inbox to get the verification code.
Sign in to entropy console.
Just wait a moment.
Provide your name.
Continue.
What type of account?
Sounds right.
Individual?
Not from a company.
Now this is really important to use API key.
So to make API calls to any of the Anthropic's models you need to add some credits.
So you need to buy credits before you can create the API key.
And because I already have multiple accounts, I'm going to login to my different account just to show
you how to create an API key.
All right.
So once you top up your account click on get API key and you can press on this API keys icon.
And here you can see all the billing details limits API keys etc..
So I'm going to create a key.
In the default workspace.
The human in the loop.
To know how much it will charge me for API calls for this specific workflow.
So add copy key.
Go back to the workflow.
Click on the dropdown Create new credential and add API key.
Press Save and Credential successfully created.
And now you have access to all the models.
So cloud 3.7, sonnet cloud sonnet four and so on.
All right.
Amazing.
Now let's move it a bit right here.
And hit save.
Now we are gonna set email node.
And this is a crucial node that many people miss because we need a set node to store the current version
of the email as we go through revisions.
So let's search for set node and configure it.
So set node.
Now let's name this email.
As the value let's put output here.
Now as you can see here the agent gave us a great email response.
But everything is packed inside a single output object as a plain text.
So we don't have separate fields like subject and email, which makes it harder to map or reuse this
content in other steps, like sending an email automatically.
And that's because we haven't added the structured output parser node.
As you can see here.
So that's the tool that tells the AI model hey, returned your output in clean structured JSON format
so we can easily work with.
So before we go any further.
We need to add this node to fix that.
By adding this structured output parser and updating our system prompt to return a proper to return
a proper JSON object.
All right.
So let's close this node for now.
And here we need to add output parser.
So select this one structured output parser.
Return data in a defined JSON format.
Defined below schema manually.
And I'm going to paste this code snippet.
As you can see subject and email.
So it will be formatted as you want.
All right great.
Now let's hit save and test the workflow again.
Now let's open Edit Field.
And as you can see now we have two separate fields inside this output object we have a subject and email.
So here let's remove this and let's drag and drop the email field.
Alright.
Brilliant.
That's it for this note.
Hit save again.
Now when our draft is ready because our SAS agent was able to prepare it for us.
We need to get human feedback on the email.
So we are going to use Gmail's send and wait functionality for this.
So let's search for a Gmail node.
I want to send a message and wait for a response.
Now connect your Gmail account.
As resource we have a message operation.
Send and wait for response.
Here you have to specify.
Here you have to specify which email you want this draft be sent to.
So enlightened demos.
Dot com.
Now for subject let's say.
Make it capital.
Required.
Uh.
And let's expand it in our name.
Let's grab our new nickname and paste it right here.
Make sure to switch over to Expression mode.
And now for the message.
And now for the actual message.
Let's grab the name again.
So the name of the lead.
Make sure to switch to expression.
From a company.
So drag and drop this company name field to make it dynamic.
It's looking.
For.
And let's grab an intent.
We can expand it to make it easier.
Um dot the budget.
Is.
And let's get a budget right here.
With a specific timeline.
And timeline here.
Now please approve.
Or decline.
The sending of this, uh, message.
Generated By Carl.
Auer.
SS agent and the subject field we can grab from the a agent node.
Okay, great.
And the email.
From the edit fields node.
Okay, perfect.
Now let's close it.
And for the response type we want to change it to free text.
So user can submit a response via form.
But you can also choose approval.
So user can approve or disapprove from within the message or custom form.
So user can submit a response via a custom form.
Okay.
So I'm going to stick with it.
And hit save.
Just to clarify, this is really important step because, uh, setting the response type to free text
allows you to give detailed feedback, not just approve and decline.
All right.
Great.
So now let's just rename this node to get feedback.
Confirm.
Uh resetting email.
So set email.
Okay.
Great.
Now we need to determine whether the human approved the email or wants revisions.
So we'll use AI to classify the feedback.
So now drag in a text classifier node.
So let's search for text classifier.
Yes.
So basically at this stage we are classifying the feedback I'm going to show you this example.
So the human the human can either approve the result or decline it.
So we need to create two categories of feedback.
So two branches.
So we are going to classify the text from the feedback.
So the data.
So we need to drag and drop this field this object and add dot text because we want to change it to
this form.
So adding the text because we want to extract just the feedback text from the data object for classification.
We don't need the content from the entire object, just the text.
Now we need just two categories.
So approved or declined.
And I'm going to paste the description I prepared.
So in that case you don't need to switch to the expression mode.
Because we don't we are not going to include any.
So any dynamic variables.
I'm going to place it right here.
Just expand it to show you.
So the email has been reviewed and accepted as it is the human explicitly or implicitly expresses approval,
indicating that no changes are needed.
And here we can just do the formatting.
So example phrases include looks good.
Go ahead and send it.
This works for me.
Approved.
No changes needed.
So of course you can add more phrases.
I create and the second case is the client.
I need to provide description.
So describe your category if it's not obvious.
Now let's type it from scratch.
I'm going to expand it.
Okay, so the email.
Has been reviewed.
But the human.
Requests modifications before.
And.
Before it is sent.
Like tweaks.
Removing.
Some parts.
Wording.
Etc..
This could include suggested edits.
On major revisions.
Sample phrases include.
For example, can we tweak this part?
Please make it shorter.
I would like to.
Be rewarded.
For this.
Mm.
Let's revise it.
Don't mention.
That.
And so on.
Basically what we've done, we provided the clear instruction for the large language model, how to
classify the feedback.
So now you should have two branches.
As you can see approved and declined.
Yes.
So this classifier node we wrote the workflow to either send the email or revise it.
So now we need to connect this node to the LM model.
So this is essential because without it the text classifier has no AI model to actually process and
categorize the human feedback into.
Approved or declined.
So in that case we are going to use Google Gemini chat model.
So again I'm going to show you how to set up the connection step by step now.
But you can always refer to the dedicated tutorial in the how to set up credentials section.
If any time you need to refresh the credentials or set up the connection for different scenarios.
So simply click on Add Model button.
Choose Google Gemini chat model.
Click on the drop down creating credential.
And as always you need to provide API key.
Now before you can generate an API key for Gemini, you will need to have a Google Cloud project.
Let me show you how to create one.
First, go to console.cloud.google.com and login with your Google account.
I will leave all the links in the resources section.
Once you login in the top left corner, click the project drop down and you will see an option that
says New Project.
So click right here.
Give it a name.
You can assign an organization.
Hit create.
Then select project.
Alright.
Great.
Now here you can see the project number and project ID.
Now let's generate the API keys for Gemini.
Now you can go to Google AI studio.
Again I will provide the link to the web page in the resources section.
And just login here you can get API key.
So click on it.
Click on this button create API key.
And here you can search your Google Cloud projects.
As you can see, the project I created just pop up.
So click on it.
And create API key in existing project.
Confirm.
Now let's copy our API keys.
Let's go back to anything.
Now paste the API key here and click save.
Okay great.
This successfully created.
Now we have access to all Google's models.
There is plenty of models, as you can see, with a flash model.
All right.
Awesome.
So now we have a brain for our text classifier.
It's safe.
Perfect.
We are nearly there.
So just to let two notes left.
So bear with me.
So for emails that need revision, we need, um, another agent.
So this agent will be specifically designed to take feedback and improve the original image draft.
So we want to add the revision agent to the declined branch.
So search for agent.
The one defined below.
So use an expression to reference data in previous nodes or enters a text.
Now let's test the step.
Okay so the workflow has issues.
So we have to define prompt.
Yes.
So first we need to get some data as an input to this node.
So let's close it.
Now let's check if you have some data in a table.
Trigger node.
Yeah.
Let's pin it.
All right.
Now let's test the workflow.
Okay.
So first let's delete this node.
All right.
Let's test again.
Because we need to get some data into the decline branch.
So we need to provide the feedback.
So let's open my Gmail.
So I'm going to check my Gmail inbox.
All right.
Respond.
Let's say.
Eight more size submit.
All right.
So we have some error.
Oh yeah I forgot to specify the large language model inside the node.
So this model is not supported for this um.
API version.
So let's change it to.
Gemini 2.0.
Flash X Dash.
Experimental.
Test workflow again.
So now our AI agent is preparing the image draft.
Respond.
The same feedback.
I'm going to give it the same feedback, so please make it more concise.
Nice submit.
Okay.
As you can see workflow executed successfully.
And now we have data the Declined branch.
So now when we add our revision agents.
So search for agents.
We have data in the flow.
So we can carry on with the configuration to define below prompt.
So as an input data for our revision agent.
So let's rename it to revision agent.
We want to include in the prompt the email the actual email.
So from the from the email node let's drag and drop email.
But let's switch to an expression mode.
And drag and drop actual email.
We also want to provide the feedback.
From the get feedback node.
We want to make it clear for our agent.
What is the email?
What is the feedback?
Is the text right?
Awesome.
Now we require a specific output format.
And we want to add the system message.
Let's switch to expression mode.
Expand it.
Okay great.
Now let's write a prompt overview.
And maybe a role.
Yep.
You are an Expert.
Narrator.
Your job is.
To tag an incoming email.
And revise it.
Based on the feedback to human.
Based on the feedback the humans submitted.
The rules.
Sign.
Sign off.
Image as they.
Identify.
I.
Also want to provide the current date and time.
So here is the.
Current date.
Time.
Double braces.
Dollar sign.
Now.
Perfect.
And that's it for this note.
Our revision agent is ready.
Now, I forgot to rename the first agent.
Let's call it sales agent.
All right.
Awesome.
Now, we don't need any tools for this for this agent.
So we don't need to give it access to any tool, but we need to give it a brain to connect the large
language model.
So we are going to use the same model.
To connect it to the anthropic chat model.
And also we want to use the same output parser the same format like that.
All right.
Perfect.
And now the last final step we want to send the approved email to our lead.
So let's add the email node to our approved branch.
So search for Gmail node as an action.
We want to send a message.
Make sure you are connected to the Gmail account the resource we have a message operation sent.
We want to send the email to the customer.
So.
From the Airtable.
Drag and drop email field.
Perfect.
As a subject, we need to open the sales agent node.
And get that.
Awesome email type.
We want to switch to text.
And as a message.
This is our actual email.
So from that email.
Drag and drop this field.
Perfect.
And the last step we want to add that option.
And switch off the attribution.
All right.
Perfect.
I think we've done.
Let's rename the workflow to human in the loop.
It's safe.
Unpin data.
Make sure your workflow is active.
Save it again.
Actually, we need to connect the output from the revision agent node to the set email node.
So this creates the loop where revisions go back through the set email node and get feedback nodes until
approved.
So let's do it like that.
Perfect.
It's safe.
And now the setup is production ready, so you can use it for and tweak for many use cases.
Now, when our workflow is active, we need a way to capture leads that will trigger our workflow.
So let's set up an Airtable form.
So go to Airtable Base.
Click on forms.
Then click on Create Form.
Add a new form table.
We want to use leads table.
Give it a name.
Create form.
And here click Publish Form.
So make it live.
And now you can share the form anywhere.
You can add the embed code to your landing pages.
You can share via email social media LinkedIn.
So once someone submits this form it adds their info to Airtable base.
So to the list table.
It triggers your editing workflow automatically.
And our ice agent crafts the personalized emails using the requirements.
Also checks the project database.
So the second table projects to find similar projects to make any more convincing.
And then you get the draft for approval.
And when you approve it, you get sent to your prospect.
Otherwise, it will loop through for a revision until you approve it.
So now you are capturing leads 24 over seven, with your sales team handling the personalized follow
up.
So just share your form link and let your sales teams work.
Alright, that's it for this tutorial.
I hope it was helpful.
This is production ready solution so you can use it for your business or sell it to your clients.
Congratulations!
You now have a complete human in the loop AI sales system that's going to transform how you handle leads.
Thank you for building this with me and see you in the next tutorial.