Introduction to AI Persona Chatbots
AI Persona chatbots are one of the most popular and lucrative opportunities in the AI chatbot space right now and best of all, you don't have to be a developer to build these Bots either. Using tools like Flowise, we can create a virtual copy of a celebrity or influencer that can be used as a personal assistant or coach. In this video, we will create a Persona chatbot of Mr Beast that we can use to get instant and personalized advice on content creation and growing a YouTube channel. We will set up Flowise from scratch and I will show you step-by-step how to create your very own AI Persona chatbot. Let's get started.
Installing Flowise Prerequisites
In order to install Flowise, you will need the following. Go over to this website and download and install git for your operating system. Then go over to this website and install the LTS version of node as well. After installing git and node, go over to the Flowise repository on GitHub. On this page, click on on code, then copy this URL. Then create a new folder on your machine and open the command prompt. On Windows, you can open the command prompt by clicking on the address bar and typing CMD and then press enter. Now in the command prompt type git clone and then paste in that URL and press enter. This will now download Flowise to your machine.
Setting Up and Building Flowise
Next, we need to open the Flowise folder in the command prompt. I'll do that by entering cd flowise and pressing enter. Alternatively, you could simply open the Flowise folder and again run the CMD command in the address bar. Now we need to install the dependencies for Flowise. We can do that by typing yarn install and then pressing enter. If you get an error message stating that yarn is not a valid command, then you can install yarn on your machine by running this command: npm install -g yarn and that should resolve that error. After installation is complete, we just have to run one more command and that is yarn build and this will take a minute to complete. After build is complete, we can now finally go ahead and start Flowise. To start Flowise going forward, simply open the command prompt in this Flowise folder and run yarn start.
Sourcing and Preparing Your Persona's Data
We can now run Flowise in our browser by going to localhost port 3000 and you should be presented with a dashboard like this. Now that we have Flowise up and running, we need to start preparing our data for our personal chatbot. There are many ways to source this information, whether it's from blogs, articles, podcasts, or YouTube videos. For this example, I'm simply going to search for Mr. Beast advice videos on YouTube. And here we can find a video that is a compilation of Mr. Beast advice videos. So what we need to do is to download the transcript of this video, and we will add that transcript to the knowledge base of our chatbot.
To download the transcript of any YouTube video, simply copy the URL and then go over to youtubetranscript.com and paste in that URL and then click on go. We will now have access to the full transcript of that video. So to copy this text, click on copy entire transcript. Then create a new folder on your machine for storing these transcript files. And then create a new text file and paste in the transcript text and let's go ahead and save this file. We can then simply repeat this process for all other sources. I'll go ahead and grab one more video. Let's use this one over here. I'll simply copy the URL, head over to YouTube transcript, paste in that URL, and hit go. Let's copy this transcript. Let's create a new text file, paste in the transcript, and let's save this file. For this demo, I'll stick with these two files only, but you can go ahead and add as many files as you want.
Building the Basic Chat Flow in Flowise
Now let's go back to Flowise and let's create our first chat flow. Let's click on add new and let's save our chat flow. I'll call mine AI Beast and let's save this. We now need to add a node that will allow us to chat to an AI model which also has access to a knowledge base. So for this, I'll click on nodes, then I'll click on chains, and within chains, let's add the conversational retrieval QA chain, like so. Now, let's attach an AI model to this chain. We can do that by clicking on nodes, then let's open chat models, and within chat models let's add the chat open AI model like so. And then let's attach our model to our chain like so. For the model, let's change the temperature to 0.4. We'll come back to the credentials in a second. Next, let's add a vector store retriever. If you would like to learn more about vector stores, then please have a look at this video in this series, but I'll also briefly explain these in this video.
Configuring the Vector Store and Embeddings
To add a vector store, let's click on nodes, then go to Vector stores and let's simply add the in-memory vector store. Effectively, the vector store is a database and the contents of those text files will be stored in this database. So when we interact with our chatbot, this chain will look up the information from this database. Let's connect our in-memory Vector store to the chain, like so. We're not going to spend any time on the memory node in this video. The vector store requires two inputs: the documents, like our text files, as well as the embeddings.
Embeddings can be quite a tricky concept, but effectively the text files that we load into this Vector store first need to be converted to embeddings. So to specify the embeddings model, click on nodes, open embeddings and add the open AI embeddings node to the canvas. And let's go ahead and connect this embeddings node to the vector store. The embeddings node also requires credentials, but we will come back to that in a second.
Loading and Splitting Documents
Now finally, let's load our document loader. Let's click on nodes, then under document loaders, go to folder with files and add that to the canvas. And let's connect this node to the vector store as well. Now we need to specify the path to our text files. So let's go over to that folder and let's copy this address. And just a quick side note, this folder can contain different file types. It does not all have to be text files, you are welcome to mix it with text files, PDFs and Word documents. And in Flowise, let's paste in that address. There is one more node that I would like to add to this and that is the text splitter.
So instead of uploading the entire content of each file, we will split that content into chunks that is a bit more manageable for the AI to process. Let's click on nodes, then click on text Splitters and let's add the recursive character text splitter and let's connect this to our document uploader. Let's leave the chunk size as 1,000 but let's add a chunk overlap of 200. So zooming out, we now have a view like this. First, we've added a document loader and specified the folder containing our documents. So this node will load all of those documents and then pass those documents over to this node. The contents of those documents will then be converted into embeddings using this node and then stored in the vector store. So when we interact with our bot, the chatbot will try and find the answer to the question in this Vector store and then return a response.
Adding OpenAI API Credentials
All that's left to do now is to add our open AI credentials. To get your open credentials, go to platform.openai.com, create your account, then click on personal, view API keys, and you will be presented with this screen. Click on create new secret key, give your key a name, and click on create secret key, and go ahead and copy that key. Then go back to Flowise, save your chat flow and click on back. Then click on credentials, then click on add credential and search for open AI API and paste in your API key. Also give this a name, I'll just call it open AI, and click on add. Then go back to your chat flows, click on your chat flow, and let's add these credentials. Let's start with the chat open AI node. Under connect credentials, click on the drop down and select open AI. Then go to the open AI embedding node, click on the drop-down and also select open AI.
Initial Testing and Troubleshooting
We should now be ready to test out this bot. Let's click on save, and then click on this little chat bubble on the top right. This will open up your chat window. Let's test this by sending a message like, 'hello'. The first time you run this, it does take a second because the document loader is first processing your documents and adding it to the vector store. After that, the chat responses should be quite quick. And we do get a response back from the bot saying, 'I don't know the answer' which is fine because it can't find an answer for 'hello' from the vector store, but at least we are getting a response back from our bot. Now let's fix this.
Crafting the AI Persona with a System Prompt
Let's close the chat window and let's tweak the personality of this chatbot. We can do this by clicking on additional parameters and now we can provide a system message. And this is how we can control the personality of our chatbot. In order to get this chatbot to mimic Mr. Beast, I'm going to enter the following prompt: 'You are Jimmy Donaldson also known as Mr. Beast, a YouTuber and content creator.' I'm not going to read the entire thing in order to save time, but you can be as specific as you want at this stage as this will greatly affect the responses from the bot. Effectively, I'm just describing the personality of Mr. Beast. What is important here though is this section: 'Answer the user's questions as if you are Mr. Beast.' So that will force the AI to respond in the first person and 'only answer questions found in the context.' In other words, only provide an answer if the answer was found in the vector store. 'If you don't know the answer, then respond with something like, 'I have no idea' or 'could you rephrase that?'. Do not make up your own answers if you don't know the answer.' Let's go ahead and close this and let's save this chat.
Final Demo and Conclusion
Let's try this again and let's say, 'hello'. So we're getting a message saying, 'Hello, how can I assist you today?' Let's do this, let's ask, 'Who are you?' and now the bot is saying it's Jimmy also known as Mr. Beast. Let's ask it a few questions like, 'How can I improve my thumbnails?' and it's giving us a very useful answer indeed, and this is information that was provided in those YouTube videos. Let's ask it something like, 'What is your worst video?' and this is a very Mr. Beast type of answer. I hope you found this useful. Adding more content to this bot is just greatly going to improve the type of answers that I get back. If you enjoy this content then please like this video and subscribe to my channel. Please let me know in the comments below who you plan to clone as an AI persona. I'll see you in the next one. Bye-bye.