Hey everyone, Liam Motley 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 because 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 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 in 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 two 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.
Righto, 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 Locke and you can get in touch with him here.
This Figma board will be available on the school community and it's got all of the information you need. But just a little bit of info on Josh. He built a chat to database system like this for Bondi Lines, which is a Sydney startup to make a chat pod that returns nightlife events from the database to users. Bondi Lions have nearly 200,000 followers between their Melbourne and Sydney Instagram accounts and respond to 500 DMs on busy nights. A chatbot that could get an input from a user, construct a Firebase query, search through their 20,000 events in 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 techno, or where can me and my girls have fun in Surrey 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 in 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 two different cities. But I've taken this concept of this chatbot that allows you to chat to a database with events and I've converted it into a boiled down version that you can easily set up and chat to a database with yourselves. Thank you to Joshua. 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, e.g. what techno events are on in November.
That's going to be sent to an agent using my software, Agentive. It is free to use. And then our agent is going to be sending these queries to a Relevance AI tool.
It's going to be taking information out of 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 relevance AI tool, and then that's going to query our database, our super-based 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 event in the techno genre.
So not super complex, but the functionality is really powerful. And now 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 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 result is going to be. You get this AI agent and 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 in 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 figure 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 better 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 OpenAI API key because we have built on top of the assistance API.
This is how we ensure that you are getting the lowest price possible for running these agents because we build directly on top of the OpenAI 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 super base database so you can click this link here then it will take you to super base 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 it's going to create our first one we can call this chat to db agent it's good enough we can generate a password here and create a new project. Give it a second because 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 row level security. This is just for testing. If you put into production, I would recommend putting it back on. And then we need to set up the columns for our table, which you can find a screenshot of a 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 now. And here we have the final setup, which is name as a text field, date, time as a timestamp. You can see there's different types.
Make sure you get this middle one here. Venue as text. genre is text, description is text, and the event link is text as well. So events is 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 command in, and we run it. Success, no rows 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 all of the names of the events, we have the venue, we have the date time 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're asking questions away to this chatbot, 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 go to a business and say, hey, I'll bid you this AI assistant 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 chatbot on say, WhatsApp or wherever you deploy it. I'm going to be taking X percent 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 a 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 agent of 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 actually take this out because it's not going to be a template for you, 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 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 an 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 passed 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 bit that gets added onto the end, which will tell Superbase what we're trying to get back from the query. I don't want to make things too confusing because 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 Superbase 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 URL here. In this case, we can just copy this part in the middle and then head back to relevance, replace this bit of text, paste that in there.
So it should say HTTPS colon forward slash forward slash, then your unique identifier dot Superbase dot co slash rest. 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're 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 techno beat nights techno beats techno pulse which is great now the final step we need to do is connect this relevance ai tool to our agent of 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 actions 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 very very easily so if you scroll down we just want to select this one the one that i was just working on we change this to custom auth I'm going to first go down to this section and generate the schema. I'm 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 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, 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 of 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. There we go. In November at the Sydney Opera House, 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 send 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, what techno 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's 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 ask 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 go okay well that's the current time now i'm going to write the query for the database so 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 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 call it the Sydney events DB query 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 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 returned 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 Adjentive, we have deployment options. So you can come here, you can put it on WhatsApp in a few clicks. If you want to see how you could put this on and also other builds on Adjentive 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 bot that goes on the corner of your client's website using our website deployment all native here on Agenda.
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. And final step, if you want to share this to a client as a demo is to click the share button, click this toggle over to make it public and then we can copy this. And you can see, you can chat to your agent of agent in a full page chatbot 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 at all of the links that are going to be available on the school community, 100% free to join.
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 hour. 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.