How to Create AI Agent for Real Estate in 25 Minutes | No-Code AI Automation for Real Estate

Business and Beyond
6 followers
15 Video Views·Nov 26, 2024
In this video, learn how to create a Real Estate Automation work order bot using n8n, automating your tasks in just 25 minutes—no coding skills required! This step-by-step guide walks you through building an AI agent for real estate, capable of handling work orders and streamlining your workflow. Discover how automation in real estate can simplify your processes with AI agents and improve efficiency using a no-code solution. Whether you're looking to create a work order AI agent or enhance efficiency in real estate, this tutorial has you covered!
In this video, we're going to build a very basic version of an AI agent in the real estate space.
A month ago, a customer reached out to me and the burning problem was that they'd employed
two full-time people for processing all of the work orders of their tenants.
They had to work day in day out, 24 hours round the clock, on weekends and on holidays.
So I thought, why not build them an AI agent which can augment all of their capabilities
and at least cut down their workload by 5x.
And that is exactly what we're going to do in this video.
So let's get to the demo.
Okay, so I have the work order board open in front of me on telegram.
I can just go ahead and chat with it.
The main objective of this chat would be to just tell it about a problem that I'm facing.
It could be a leaky faucet, so let's just make it a leaky faucet
and try to book a work order for maintenance for my apartment.
Normally, something like this would take about five minutes for anybody who wants to do this
and then have to converse with a human and then it takes a lot of time
and a lot of maybe some frustration as well.
So let's just say, um, hi.
Okay, so number one, it already knows who I am and it says, how can I assist you today?
So if you have any questions or need assistance, so I have a problem.
I have a problem with my kitchen faucet.
Actually, let's just give it a very, very vague prompt.
Kitchen faucet is leaking.
What the hell?
I understand how frustrating it can be to deal with your leaky kitchen faucet.
I'm here to help you resolve this.
Can you confirm the severity and availability for a visit?
So you'll notice that it hasn't asked me for any address right now
and that is because it is already connected to my attendance database
and I'll quickly show you right after this what my database is like right now.
So yeah, I can just say, obviously, it's high severity
and I could just say, um, come over first thing on Friday
and at any moment, it'll just book my order.
Oh yeah, so it has booked my order and has told me what the problem description is,
what the address is.
It already had my address, the severity,
available time slot and it has also categorized my problem as plumbing.
So yeah, I mean like, if a human were to call a support agent
and explain all of this to them, they would be a lot frustrated.
They would have all of these back and forth like,
hey, the kitchen faucet is leaking and whatnot.
So yeah, I think this will save everybody a lot of time and a lot of pain as well.
So in a little less than a minute, by just sending two messages,
very vague messages, I've been able to book this work order.
It has gotten saved to my database on the back end.
I'll just quickly show you the database as well.
All right, and this is my very basic Google sheet which is used as a database.
So I have one tenant over here.
I can have multiple tenants as well.
And this is the my work orders database, also another Google sheet.
And all the work orders that I push from the Telegram chat will be just pushed here
and it can infinitely scale to as many work orders as needed.
In the future, we can also extend it to connect to vendors as well.
I've already made a small database for that as well
and it can connect the vendors with the work orders
based on their availability and the tenant's availability.
So yeah, this is basically it and let's just get to how we can build this.
Okay, now that we've seen how the demo works,
let's just get into how we can build something like this.
This is the cloud version of the end-to-end installation.
You can get a 14-day trial for free or you can just get one for $20 a month.
The reason you need the cloud instance for this is
that you need to connect with Telegram and Telegram's webhook.
If you have a local installation, you would need a public IP
or you would need a tunnel from which you would be able to connect with Telegram's webhook.
So yeah, I won't put you through all of that pain.
So yeah, I would just suggest just use the cloud version of N8n on n8n.io
and just use that to build your Telegram webhooks and Telegram-based AI agents.
Our agent has three parts.
The first one is the Telegram webhook, which will be used to receive messages.
The second one is the AI agent, which does all of the heavy lifting.
And the third one is the Telegram response that we send back to the user.
So at this point, this is very self-explanatory.
So in our previous episodes as well, we've talked about triggers
and the trigger for this workflow is a Telegram message.
So of course, every time somebody sends us a message,
we want our agent to be activated and to think about
what it needs to do next and how it needs to respond.
So yeah, we can very easily click here,
write Telegram, Telegram, scroll down, go to triggers.
And over here, you can just select the on message trigger,
which can be used as the first node of our workflow.
And anytime somebody sends us a message on Telegram,
this will get triggered and it will receive the information over here
and pass it on to the next node.
The next node after that is our AI agent.
This is what does all of the heavy lifting.
So let me just quickly create a blank AI agent
and show you what are all the moving parts
and how we can connect, how we can make it something like it is right now.
So in our previous videos as well, we've talked about AI agents.
AI agents need three things.
Number one, a chat model.
This can be OpenAI, Cloud 3.5, Grok, or any of those providers.
So you can see on the right, we've got all of these providers.
It needs a memory.
For all practical purposes, you should definitely just use window buffer memory.
And I will also quickly show you how we can configure that to work with Telegram.
Otherwise, you'll run into errors.
And number three, tools.
So think of tools as the powers that we can give to an AI agent.
It is kind of their weapons in their arsenal
that they can use whenever they need to.
We've got two tools over here.
The right work order tool and a return for information tool.
I will deep dive into these in a bit.
But yeah, these are the two tools.
These are the only two tools that we need.
And finally, once all of this is done,
it does its thing, books a work order.
Or even if it fetches the information or just talking to the user,
it gives us an output which we'll basically send to the end user after that.
So yeah, this is what completes our loop.
So a message comes in from here.
The AI agent does its thing.
And finally, it gives the user a response.
Okay, so now let's dive deeper into these.
The first one, Telegram trigger is very self-explanatory.
You can click on here, connect your Telegram account.
Whenever you go to connect your Telegram account,
it will ask you for the access token.
You can go ahead and find the access token from the Telegram's documentation.
Actually, let's just quickly show you how to do that.
You can go to Telegram documentation from here.
You need to have an active Telegram account.
And then from your phone, you need to start a chat with Botfather and send a new bot.
Add your bot's information.
And at the end, it will give you the access token for that specific bot.
You can just go ahead, copy that access token and paste it in here.
And that is all you need to do.
And you'll be able to connect it.
Connect your Telegram webhook with Telegram server.
Once you do this, this trigger node will automatically be configured as the webhook for this.
Normally, you'd have to manually configure that.
But yeah, these guys have already done this for you.
So as soon as you put in the access token, this will be your default receiving place
for all of the messages that get sent to whatever bot you built using Botfather.
So yeah, once you've done this, the next step is to go to the AI agent.
Whatever you get from Telegram, you send it to the AI agent.
This is a relatively complex AI agent from the ones that we've done previously.
So let me just walk you through this step by step.
Number one, we need this to be a tools agent.
We want to give it some instructions and we want to tell it what we're expecting out of it
so that it can help us in a very deterministic manner.
To do that, we need a very detailed system message.
And this is all that I'm expecting from this agent.
This is a helpful assistant which helps book work orders for tenants.
You need to talk to the user in a polite and conciliatory tone,
help guide them through the work order booking process.
You have access to the tenant's information.
I'm giving it a hint that I'm going to give you a tool
from which you can access tenant information, including their phone number, full name, and address.
So I showed you this is our database.
Yeah, this is our tenant's database.
So it has access to the name, the phone number, and the address.
And do not assume who the tenant is.
So earlier when I was testing it, it was assuming that I was one of the tenants.
So that's why I had to add it in.
Find them in your database.
Do not book orders for unknown tenants.
Do not share other tenant information with them.
And the way I tell the bot who you're talking to
is by using the first name of the message.
So we'll go ahead and just do a quick message so that you can see what data is coming in.
Let me just deactivate this.
So I just sent a message from my telegram.
And at this point, it has gone through the whole workflow.
So now you'll have access to all of it,
all of the information that got passed through this run.
And then we'll have more context on as to how this is happening.
So I'll open the agent again.
And on the left, you'll see that the trigger got triggereded.
And this is giving us all of the information that the user sent.
I sent the message text, hello.
And this is the data that I have.
Every time a user sends a message,
the text that I'm giving to the agent is their first name.
So I just basically dragged and dropped the first name from here.
And I'm giving it the message text that I sent.
And their message text is here.
This is hello.
I just dragged and dropped it here.
And that's it.
So you'll see this is what I sent.
And now the agent knows that I'm talking to Ahmed.
And this is what he's saying.
If you're talking to somebody else, just the first name will be replaced.
And of course, the text that they sent will also be replaced.
Okay, so coming back to the prompt.
And this is how the agent knows who I'm talking to.
And it knows who it needs to search for in the database.
So yeah, you have already access to the information.
When booking a work order, make sure you do the following things.
You ask them about the problem description, complete address,
severity of the problem, category of the problem, and available time slots.
In this case, we already have the complete address.
So it just picks it on its own.
Do not ask the user to fill these one by one.
Try to infer the ticket details from their conversation.
Expand on the details of the problem on your own.
And that is all I want from the agent.
And that is literally what you would expect a human support agent to do as well.
Yeah, so there's this.
On the left, you'll see the message that we got from the user.
And on the right, you'll see the output that this agent generated.
Hello again, Amit.
How can I assist you?
If you have any questions or need to proceed further, please don't hesitate.
Let me know.
So this is what it responded with after doing its own thing.
And what did it do here?
Number one, we've got the chat model OpenAI.
We've got the window buffer memory.
I'll just open it up.
So normally, if you were using chat inside NetEnt, this would just pick it on its own.
But for specifically integration with other services like Telegram or WhatsApp,
you'll need to tell it what the session ID is.
The session ID basically is the identifier against which it needs to store the message.
So for example, if it is talking to 10 people,
it needs to know which one does it need to store the value against.
So this is the message that we got from Telegram.
And the thing that is going to stay the same for Amit's chat throughout the entirety of
our interaction with Telegram is going to be the chat ID.
So I just grabbed this chat ID and pasted it here.
And that is going to be our session ID.
I wanted to remember my past four messages as a context.
That is why I put it as four.
This is our window buffer memory.
And these are the two tools that are basically doing all of the magic.
So let's go to the read tenant information tool first.
And let me quickly show you what I've done.
So this is the tenant database for us.
So yeah, let me just add in one more, right?
So let's just say I have Mike Tyson, right?
And their number would be four.
And their property address could be San Francisco Bay Area, right?
I could add this in as well.
And if I go back, you'll see that I've got the read tenant information tool.
This is a tool whose job is, like in the description, we tell it what its job is.
Get details about tenants including their phone name, address, full name.
We can use this as a source when a user asks about their information.
If we click on Google Sheets tool, you can just click on here.
You get this blank node.
I've already connected my Google Sheets account.
I click on set this up manually.
And then I click sheet within document, get all of the rows.
You can select the document from here.
Once you've connected your account, you can select the document from here.
So real estate work agent.
And then I select the sheet from here.
Remember, in our document, we had three sheets and I click on tenants.
And now it can just fetch all of the rows from that sheet
and basically use that as its database or as its information there.
So I'm going to delete this and you're going back.
So this is exactly the same thing that I did.
It shows this sheet one over here.
Let me just replace it with tenants.
And yeah, that's it.
So every time it needs information, it can invoke this tool, get the information
and then match the telegram first name with the user's first name and then just do that.
Typically, we would eventually want that the user's phone number
should be matched with their phone number in the database,
but Telegram doesn't give us the phone number.
So if you're using something like WhatsApp, we would match them with their phone numbers.
So since this is just a demo, so I think we can just do it for the case of POC.
So this is a very simple tool, very self-explanatory.
We're giving it as a read-only tool.
But now comes the harder part.
Now we're going towards the right work order tool.
And this is the tool which goes ahead to the work order sheet
and writes this complete row based on the user's input.
And we initially did this at the start of this video as well.
And this is the row that got generated as a result of that.
So now quite a lot of things are happening here.
So let me just walk you through those one by one.
So again, we don't set the tool description automatically
because we want to exactly prescribe it what to do.
So once the work order is finalized, use this tool to write it to the sheet.
This accepts the following columns as inputs.
I could also do without this, but I just wanted to mention this here
so that it knows exactly what it needs to do and doesn't forget it.
A resource sheet with a document.
Operation, we need to create a new row, append row.
Document, again, real estate work order agent.
The sheet that we're talking about.
And the sheet is work orders.
Mapping column mode.
Now this is where the complex part starts, right?
So we want to tell the AI to give us specific data against every single column
so that it can go ahead and fill it for our Google Sheet.
And I don't want it to do automatically.
I don't want it to infer it automatically.
I want to do it manually and tell it what it needs to do.
If you go to the top of this tool, you'll see this is a tool tip
or an information that we got from this Google Sheet tool.
Use the expression $ from AI for any data to be filled by the model.
And what are the fields that we want the model to fill?
Exactly these fields.
So the problem description, the address severity, available time slots and category.
And that is what we've done here.
So values to send.
If I click on map each column manually, it will find all of the columns in the Google Sheet.
Let's just quickly show you how it does this.
So I click on Google Sheet tool, right?
And I click on tools you can set manually.
We wanted to append a row, right?
We click and we get the realistic work order agent.
The sheet that we need is the work order sheet.
And we want to map each column manually.
And it will automatically fetch the columns from this Google Sheet.
The problem description, address severity, available time slots and category.
It will automatically do this.
And now all we need to tell it to do is that you need to fetch these from the AI.
So we've told the, this is our new, this is a dummy node for us, for this tool.
But initially we told it over here that these are the things that you need to fill.
Because of this, we can expect the AI to be able to fill all of these documents.
So all I need to do is write these two brackets, dollar from AI,
and give it a name like problem underscore description.
And this tells the AI agent that I am expecting a problem description from you
that needs to get filled over here.
Earlier, you remember that we were dragging and dropping things from here,
but that's not possible right now because we don't know
what the AI agent is going to do on the fly.
By writing this, we are suggesting the AI agent to do this on its own
and give us the problem description.
And do the same for the rest of the fields as well.
Let me just delete this node and just open this node again.
So yeah, from AI problem description, from AI address, from AI severity,
from AI available time slots, from AI category.
These five sentences tell the AI that we are expecting these things
from you whenever you're going to use this tool.
And yeah, that's it.
Once we've done this, we've equipped our AI agent with all of these things
and now we should be able to just book a work order.
So I can quickly go ahead and do one more run of this for you.
So let me just do that.
So I have my phone in front of me right now.
I'm just going to test some more workflows
and I'm just going to try and book another order.
Let's just do it for a broken tile, for example, right?
So I have a broken tile, right?
I'll just test it.
It's waiting for my trigger event and I'm just going to send it.
I sent, I have a broken tile.
It's doing its thing and it gave me a response message.
And it said, Telegram said, I'm sorry to hear about the broken tile.
I can book a work order.
Could you please provide me with the following details?
Severity, your availability.
Once I have the information,
I can proceed with booking the work order for you, right?
Let's just do that.
Severity is medium and visit me next Monday, right?
I just sent this in, click on test workflow.
We got the information.
It went ahead, used this tool,
went ahead to the OpenAI model and gave me a response.
Again, on the right, you'll see your maintenance work order
for the broken tile has been successfully booked.
Here are the details.
Thank you for providing the information.
And if I go back to the real estate work order agent,
you'll see broken tile, address, medium severity,
next Monday, general repair.
And it did all of this on its own without,
by me just only and only writing two simple messages
and giving it that context.
I've also added some of the text around it as well.
So it makes more sense to you.
And yeah, let me know if you liked this tutorial
and if you liked what this agent is doing and yeah,
tell me what kind of agents do you want me to build next
and I'd be happy to do those.
