hey everyone leam mle here and today I've got another Super valuable tutorial for you showing you how to set up an AI agent system that allows you to chat to a database so in this tutorial we're going to be building a basic database that uses event data and we're going to be creating an AI agent and a special tool that connects the two that allows you to ask questions and the AI agent is going to query that database pull information back and this function or use case for AI and being able to chat to a
database is one of the most in demand use cases in the entire space right now cuz businesses have a lot of data and they want to be able to ask questions to it but creating a system that allows you to do this can be quite difficult and in this case I found a super low Tech way to achieve this with just a few low code and no code softwares if you're interested in starting or are currently running an AI automation agency then this specific function and the skill of chatting to a database is definitely something
that you're going to want to have in your toolkit as an agency owner and as always with my tutorials I've done all the hard work for you I've templated everything in every part of this build so it's all going to be available for free on the school Community down below where you can follow step by step and get every resource you need to get this set up and literally a few minutes before we jump into things if you're new to the channel and don't know who I am my name is Liam otley and I've been
building and selling AI Solutions like these to businesses for nearly 2 years now since I started my own AI automation agency called Morningside Ai and on this channel I teach you how to build an AI automation agency by selling Solutions like these so let's get into it right so what exactly are we going to be building today so it's a chat to database AI agent system and it's based off an example that's from a member of our community who built and sold a solution like this successfully his name is Joshua lock and you can get
in touch with him here this figma board will be available on the school Comm community and it's got all of the information you need but just a little bit of info on Josh um he built a chat database system like this for Bondi lons which is a Sydney startup to make a chat that returns nightlife events from the database to users uh Bondi Lions have nearly 200,000 followers between their Melbourne and Sydney Instagram accounts and respond to 500 DMS on busy nights a chatboard that could get an input from a user construct a Firebase query
search through their 20,000 events and their database and return the top three was made to substitute for a human where possible common queries would be I'm 20 and looking for techn or where can me and my girls have fun and Sor Hills for my 21st and he's provided a link to a beta version here that he's built I think this is an awesome use case for generative Ai and that usually with humans it wouldn't make sense to be answering 500 DMS just to point them to the right events in this case he's created a system
that allows to answer questions to people and give them recommendations to the best events within Sydney or Melbourne they have uh two different cities but I've taken this concept of this chat bot that allows you to chat to a database with events and I've converted it into a a boiled down version that you can easily set up and chat your database with yourselves thank you to Joshua um you can get in touch with him here via his agency or LinkedIn here and also if you want to be featured in other videos like this and get
your name and business in front of thousands of people then you can use the form that's linked here or also in the description if you want to submit and get featured in a video like this in future so thank you to Joshua for that but this is the build that we're going to be doing here so getting into the architecture of this particular build we are going to have the user asking questions EG what techno events are on in November that's going to be sent to an agentive agent using using my software agentive it is
free to use and then our agentive agent is going to be sending these queries to a relevant AI tool it's going to be taking information out of the the question in this example what techno events are in November it's got the start date and the end date of the start of November and the end of November and the genre of techno so it's going to basically pull and extract information out of what we're asking it's going to send it to our relevant AI tool and then that's going to query our database our superbase database so
it's not a knowledge base like you may be familiar with where you're asking questions over documents this is a proper database with rows and columns and tables so we're actually querying a database in this case and So based on the query the database is going to return some information like this through our relevance tool and back to our agent then the agent is going to provide an answer that's nicely formatted saying hey in November there's this this event and the Techno genre so not super complex but the functionality is really powerful um and to get
started I've put all of the information here there's like 15 Steps here all detailed information so if you guys get stuck at any point in this tutorial um and you go over to the school Community you can get this figma board and every step is documented if you get stuck or want to do it at your own pace and before we jump into the building this is what the end results going to be you get this AI agent you can chat away to it here but more importantly you can put it on a page that
looks like this and send this to your clients and they can have a chat to it and ask questions like what techno events are on in November and there were none in the database in this case and okay how about jazz events November and then it's going to give you a description of the event that they found and pulled back for the database and a link to go and purchase it here and this is connected to a database here that I'm going to show you how to set up using all of this dummy Sydney event
data so we're going to set up this database connect it to the AI agent so that you can chat to it back and forth like this but of course I'm going to walk you through how to do it right now so the first thing you need to do is join the free school community in the first link in the description that will give you access to this figer board which has all the links you will need also the school post if you go to the YouTube resources tab that's where you'll be able to find all
the resources for this video so first one is to sign up to my software agentive you can sign up to agentive for free here you'll come on the landing page you can click on the register button here and just sign up with Google or Apple or whatever you want to do once you've gone through the onboarding process you will need to provide your own open AI API key because we are built on top of the assistant API this is how we ensure that you getting the lowest price possible for running these agents because we build
directly on top of the open AI assistance API for you once you've registered and set up your account you should see a screen that looks a bit like this you will not have any data in it if you've got a new account then you need to head back to the figma board and you can get the second link here which is going to clone my agent into your account so when you click on this it's going to allow you to clone this agent here which is going to be the event Genie Sydney template and in
this template you'll see that I've already done all the hard work for you of creating a prompt for this agent that will make it do the things we want it to do so once you've got this agent here you've got the template in your account then we can go into the second phase of this which is setting up your superbase database so you can click this link here then it will take you to superbase which will allow you to set up a free database so you can go to start your project create a free account
and then you'll see a screen that looks like this where we can create our project so this going to create our first one we can call this uh chat to DB agent that's good enough we can generate a password here and create a new project give it a second cuz it's going to take a while to get set up now the Project's set up we want to create our first table which is going to have all of our event data in it so we can click the create new table here I'm going to call this
events make sure this is exactly as I've done it events or lowercase if you have a capital in there it's going to screw things up and then you need to make sure you've disabled roow level security this is just for testing if you put into production I would recommend putting it back on um and then we need to set up the columns for our table which you can find a screenshot of the completed example in the figma here so if you go across add the following columns to your table we have name date time venue
genre description and event link so I'm just going to go ahead and fill these out [Music] now and here we have the final setup which is name as a text field date time as a timestamp you can see these different types make sure you get this middle one here uh venue is text genre is text description is text and the event link is text as well so events as a name these are the columns you need to set up and then we can go save and while that's saving we can head back to the figma
and the next step is going to be to get this data here and we can populate this database with dummy data now so if you copy this head back over to superbase go to the SQL editor in the top left here paste this uh command in and we run it success no row return then we go back to our table and you'll see if we click on events we have a database that's populated full of fantasy events that are happening in Sydney supposedly so we have um all of the names of the events we have
the venue we have the datetime um of when the event starts we have the genre description of it and we also have an event link so the idea is that when you asking questions away to this chat bot it will also be giving you links to purchase that so you can set up either you're selling it directly or if you're building it for a client they can be making money as like an affiliate partner or you can be tracking the clicks that come from this kind of build where you you go to a business and
say hey I'll build you this AI assistant like uh like Joshua did that's going to answer questions and redirect them to the payment page and booking page for events and my only compensation is going to be based off the link clicks from this chat bot on say WhatsApp or wherever you deploy it um I'm going to be taking x% of the revenue from anything that's driven from my AI assistant which is a cool way of monetizing it if that's what you wanted to do down the line so now we have a database filled with data
we need to create our relevant AI account so you can click here to sign up and then once you've created your account you can click on this one here and that's going to allow you to clone my relevance AI tool into your account so I've already built it out for you so that you can connect your agentive agent to this database so this link here will give you access to clone this particular relevance tool into your account you can see here Sydney events DB query tool template when you get this you want to change the
template word you want to come up here and make sure you take this out because it's not going to be a template view obviously and here we have a description that's going to tell our AI agent what this tool is going to do in this case we've got it set up to say queries our database of events in Sydney and can be filtered by venue genre and date so it's important that you get the name and the description of these tools right as with you'll see here the description of each of the variables because this
is what the AI agent is going to be reading over when it is trying to use your tool so if you're not descriptive as you can see here with exactly how it should be putting data in into this when it's calling it it's going to mess it up so the descriptions on relevance here are super important to get right and I think that's something that beginners miss out on a lot and it can cause a lot of issues with your agents down the line so the way this tool works is it takes in optional fields
of genre venue start date and time and also end date and time so these are all optional Fields the AI agent can call them and add them in as necessary based on the user queries and then it runs it through a little bit of python code here that I've written then depending on which filters were pass in by the user or by the agent in this case it's going to construct a URL that we're going to add onto the end of this URL to send off to our superbase database I tried a bunch of different
ways to get this working this was the best one and most reliable way that I found but basically we have our superbase database URL here and based on the inputs from the user we're writing this special B that gets added onto the end which will tell super base what we're trying to get back from the query I don't want to make things too confusing cuz I've done all the hard work for you here all we need to worry about in your case is to replace this and replace this with your super base details which we
can do by heading back to superbase going down to the bottom left to our project settings and then on the left panel if you click API you'll see that you have your own uh URL here in this case we can just copy this part in the middle and then head back to relevance replace this uh bit of text paste that in there so it should say https a colon for/ then your unique identifier. superb. c/r Etc and then this relevance variable should just be tacked on the end like this next step is to get your
API key which can be done right here so we can copy this head back paste this in and then we all good to go we can give this a test we can put in say techno we scroll down and we can click run tool here make sure the connection between the tool and our database is working correctly and there you go you can see we're getting back um techno beat kns techno beats techno pulse which is great now the final step we need to do is connect this relevance AI tool to our agent which we
can do by Saving this up here we can go back to we can go back to here and then click on the new button in the top right then we get this custom action gpts which is what I love about relevance particularly because it allows us to easily connect in a couple clicks our tools over to our agents um very very easily so if you scroll down we just want to select um this one the one that I was just working on we change this to custom off I'm going to first go down to this
section and generate this schema going to copy this and then if we head back to our event Genie template and we go to the tool section we can click upload tool here paste in that schema click add authentication API key custom it's going to say author authorization API key we can paste in oh we need to go back to relevance scroll up and generate this API key copy this head back put it into our API key field there and then we update the authentication and create tools then we have our Sydney events DB query tool
um which is the name of the tool which is what our agent is going to know it and refer to it as and you can go back into the prompt here you can see that I've mentioned specifically at the query the database phase it's going to be using the Sydney events DB query tool to filter and retrieve the most relevant events so with that all set up we're good to publish the agent and then we can give it a spin and see what events are on in Sydney so if I go what's on at the
Sydney Opera House in November we go in November at the Sydney Opera housee you can catch the following event rock Night Out click here to purchase tickets this is going to go to a dead link because I've just used dummy links but that would you direct to the booking page if this was a real life application you built it for a client we can also give it a trickier question like uh what tech events are on next weekend if we ask what techno events are on next week the agent doesn't inherently know what time it
is for me as of writing this so I've prompted it to ask for the current day and date so it's able to construct the right query for the database given when I'm asking the question so it's a relative time that built into the prompt but if I was to build and Sell This what I would do is add another tool not just the database query tool we set up in relevance one that allows us to fetch the current date and time and I'd instruct the agent if the user asks a question that is relative timing
in this case what's on next week trigger the get current time tool it's going to fetch it and it's go okay well that's the current time now I'm going to write the query for the database that I know what window I'm trying to look for in that query so some extra features you can add on will make it a lot better and more flexible for users without having to ask a question like this so could you please let me know the current date that way I can accurately find the Techno events happening next week near
you um current date is 28th of September okay so here you can see despite having issues initially with the query it tried again and you can see we've got techno beats which is on October the 5th which is indeed next week and one of the features we've built into agentive to make it easy for you when you're building these Solutions is this show usage button here so when you hover over it it shows you the tool usage we can see the input and the output of what we've just sent so we called the Sydney events
dbquery tool here you can see that we've used a post request we've asked for the Techno genre and we've put in these dates for the start date and end date so it makes it easier for you to debug and know what's going on behind the scenes in this case it's for the 1st of October to the 8th of October which is indeed next week and then in the output tab you can see it's return just one event to us here and that's what it's turned into this nice text so that's all the core functionality built
of this application but really we're only just scratching the surface of how valuable this can be for your clients so on agentive we have deployment options so you can come here you can put it on WhatsApp a few clicks if you want to see how you could put this on and also other uh Builds on agentive onto WhatsApp I've got a video for that up here which is literally a few clicks it'll take you two minutes to take this and put it on a WhatsApp number which is one of the most valuable deployments out right
now you can also put it on messenger with a slightly trickier deployment and then you can also put it on our web chat widget and create a web chat B that goes on the corner of your client's website using our website deployment or native here on agenta if you want to watch my tutorial on how to put these onto WhatsApp or web chat they'll be linked Down Below in the description and also I'll pop them up here too um and the final step if you want to share this to a client as a demo is
to click this share button click this toggle over to make it public then we can copy this and you can see you can chat to your agent of agent and a full page uh chat bot like this so your clients can come on here and ask questions like what rock events are on at the Sydney Opera House test the functionality out so that's all for the build you can check out all of the steps needed to do it here and all of the links are going to be available on the school Community 100% free to
join um and then when you go to the YouTube resources tab you'll be able to find this video and this figma board that we're looking at right on screen here will be available on that post as well if you want to watch another video like this where I show you how to build a $32,000 AI agent system that was built by someone in our community you can check that out up here but aside from that guys that's all for the video thank you so much for watching and I will see you in the next one