Thumbnail for How To Create an AI Avatar IT Support Agent | Livekit & Beyond Presence Tutorial by Thanh-y David Nguyen

How To Create an AI Avatar IT Support Agent | Livekit & Beyond Presence Tutorial

Thanh-y David Nguyen

22m 55s3,837 words~20 min read
YouTube auto captions
Transcript source

YouTube auto captions

This transcript was extracted from YouTube's auto-generated caption track. The transcript below is server-rendered so it can be read, searched, cited, and shared without opening the original YouTube player.

Timestamped outline
Pull quotes
[0:00]In this video, I'm going to show you how to create an AI avatar IT support agent.
[0:00]We're going to develop this agent in Python, and I'm going to walk you through everything step by step.
[0:00]I'm also going to show you how to integrate the agent into a custom front-end, and I'm also going to show you how to make the agent perform tasks with the usage of tools.
[0:35]It should actually start with a backslash followed by the domain and then another backslash.
Use this transcript
Related transcript hubs

[0:00]In this video, I'm going to show you how to create an AI avatar IT support agent. We're going to develop this agent in Python, and I'm going to walk you through everything step by step. I'm also going to show you how to integrate the agent into a custom front-end, and I'm also going to show you how to make the agent perform tasks with the usage of tools. Hello, how can I help you today? Hi, I'm having trouble logging into my account. Can I share my screen with you so you can have a quick look at it? Of course, please go ahead and share your screen. I'll take a look and guide you through the steps to solve the login issue.

[0:35]Can you see my screen now? Yes, I can see your screen. I noticed that the username format you're using is not quite right. It should actually start with a backslash followed by the domain and then another backslash. You mean like this? Exactly. That looks correct now. Now, go ahead and try signing in again. Okay, let me try this one more time. Ah, looks like I tried to log in too many times incorrectly. Now I have a different error message. Can you see it? Yes, I see the message saying your account has been blocked. I'll unblock your account right now, so you can try again.

[1:14]Your account has been unblocked. You should be able to log in now. Okay, let me try this one more time. Yeah, it works now. Thank you. My issue is resolved. I'm glad to hear that! Now, to wrap things up, I'll create and close a support ticket for this issue. Could you please provide your email address so I can send you a summary of the solution? Yeah, sure, let me type it into the chat.

[1:41]I've sent you a summary of the solution to your email, and the support ticket has been created and closed. Thank you. Bye-bye. And here we have the email of the support ticket with all of the summary what we just did with the agent. So let's get started. So firstly, we would need to set up our development environment where we develop our AI agent. And for that, you can either use VS Code or cursor. If you already have this set up, you can skip this part, but if you don't, you can simply Google VS Code or cursor and then download and install it. I'm going to use cursor, so I'm going to Google cursor and then click on the first link. And then over here you can simply download and install that. After you installed it, you can then open it. I already have it open here, and then you can create a folder somewhere and then you can open it simply by clicking file, open folder, and you can open it and I already have it open right here. All right. The next thing we need to do is that we need to set up our voice agent part of our AI avatar agent. And for this, I'm going to use LiveKit as always. For this you can simply Google LiveKit and then click on the first link. If you're a regular viewer of this channel, you already know how this goes, but if you're not, LiveKit is a very comprehensive development kit in order to create AI voice agents. And the next thing we need to do is that we need to click on this Start building button. And here's where you would need to create an account. I already have one, and don't worry, you don't have to pay anything to use this. There's a free tier. And the next thing we need to do is that we need to create a project down here. We need to click on this dropdown and then click on Create new project. Then you can give it a name, for example, support agent, and then you can click on create. I already created this project, so I'm not going to create a new one. Then you can select it by clicking here and then selecting it like that. Then we can click on this button over here that says voice AI quick start. Here we have a very comprehensive and very easy to follow tutorial how to set up your first AI voice agent. And there are a couple of requirements that you have to meet in order to set this up. First of all, you have to have Python installed that's equal or greater to the version 3.9. If you don't have Python installed, you can simply Google Python download, click on the first link, and here's where you can select a Python version. Again, anything that's equal or greater to 3.9 is fine, you can click on any version over here to download and install it as well. it's actually here. The next thing we need to do is that we need to set up UV. Here you can click on the website in order to see the installation guide. And if you're using Windows, you can simply copy this command over here to install it, or if you're using Mac OS or Linux, you can click over here and then simply copy these commands and then put them in there into a terminal. I'm going to use Windows, or I'm using Windows, so I'm going to copy this link. And then we can go back to cursor. And here's where you can open a new terminal for the installation. What you can press is control shift P, and then you can type in create new terminal. I'm going to select Power shell. And down here now you have a new terminal. And then you can simply right-click in here to paste it into the terminal, and then you can press enter. Now UV is installed. After that's installed, we can simply follow the next step of the guide. We can go back to the guide.

[5:59]And then we can go to the next command over here and then copy it right here. Then we can go back to cursor, and then we also paste it into the terminal by right clicking, pressing enter, and then you need to give this device a name. You can simply call it support avatar, press enter. This will open you a new tab in the browser, right here. And here's where we need to select a project which we give it access to. And here you can simply select the project we created in the beginning, support avatar, and then click on allow access. Now we can close this and go back to cursor. And then you have to tell it if you want to use this as your project or default project, you can select yes here. I already use the name support avatar multiple times that's why I need to give it a new different name.

[6:53]I'm simply going to call it support avatar one. And that's it.

[6:58]And then we can follow the next step, back in the guide. Here we can scroll down a little bit. And here's where you would need to select real-time model. And then we would need to follow the next step. Here, I would only recommend you to copy the first line instead of copying the whole command, because these are actually two different commands. So you can simply copy the first line and then go back to cursor, and then go to the terminal, right click in it. And this part over here is actually a name of a folder which we're going to initialize now. And I don't want to call it LiveKit voice agent, so I'm going to simply change that by calling it support agent, and then we need to write dash dash bear here, and then press enter. And over here now you have this new folder with a new file inside of it. Now, we have to navigate into this new folder by typing CD, and then support. You can actually now just press the tab button to auto complete that, and then press enter, and now we are inside of this new folder. Now we can continue with the next step of the guide. And now we have to install a couple of libraries. And for this, we can simply copy this whole command here again. But here, it breaks it into multiple lines, and if you copy this, or if you paste this into the terminal and press enter, most likely, you're going to get an error. So in order to fix that, we can simply copy this whole command, open like an editor or something like that. Entering it here, and then remove all of these back slashes in order to turn this into a single line, like that. Copy this whole command and go into cursor. And then right click in here, and then press enter again. Now a couple of libraries are installed, and you what you will also see is that now we have this new folder here, which is a virtual environment. And inside of it, we have all of the libraries that we just installed. All right. So the next step is to follow the guide again. And here's where we would need to create a dot ENV file where we have all of our environment variables inside of it. And for this we use, we are using this command here. You can copy this again, go to cursor again, right click, press enter. What you will now see is that you will have this new file here called dot ENV.local. And inside of it, you have all of the information that you need in order to connect to your support agent project that we created in the beginning in the cloud, in the LiveKit account. And these are all of the information that we need in order to connect to that. Now we can continue with the guide again. And the next step here is that we would need to copy all of the actual code of the actual voice agent. And for this, you can click on this button over here. Copy that, go to cursor, and over here we would need to now create a new file by clicking on this button and calling it agent.py, press enter. And here you can simply paste all of this code, and then pressing control S to save that. So now we have all of the actual code of the voice agent inside of here. But before we can continue, there's one more API key which we would need, because we are using OpenAI as the large language model, so of course, we would need to have a OpenAI API key. And for this, you would need to create a new account on OpenAI if you don't already have one. For this you can simply Google OpenAI API key, press enter. Then you can click on the first link. Again, you would need to create an account here. And OpenAI is not free to use, you would need to upload some credits in order to use it. Don't worry, you don't have to do anything crazy, you can simply upload like five to ten dollars or something like that just to try it out. But if you already did that, you can now create an OpenAI API key here, on this button. Then you can give it a name, let's call it support agent one, for example, and then click on create secret key.

[11:20]Here you have now your API key, and you can click on this button to copy it. Now we can go back to cursor. We have to go back to the dot ENV file again, and in here we have to type in here OpenAI API key, and then we have to enter our API key in here. Then we have to also press control S to save that. All right. So one last step, we have to go back to the guide again. Then we have to scroll down here, and then we have to copy this last command here. This command here will download some essential files which we need in order to start our agent. Now we have to go back to cursor again. Again, paste it in here, press enter. Now it's downloaded. And now, in here in the guide, there's a command which we can use to start our agent in local mode. So we can paste it in here again, and then press enter.

[12:36]Hello, how's it going? I'm here to help with anything you need. What can I do for you today? Hi, how are you doing? Hi there. I'm doing great. Thanks for asking. How about you? Everything going on your end? You can press control C to exit this call. And there you go, now you have a working voice agent. So since we are creating an AI avatar IT support agent, of course, we want it to be able to see our screen or share our screen with it. So it's has the ability to navigate us through any issue that we might have as a user, and that's actually incredibly easy to do. All you need to do is go to the section over here that says session.start, and then here you need to write video enabled true. And that's it. Now it's able to see your screen. And by the way, if you have a similar issue like I do here, where you have some warnings here, and it's not able to recognize the libraries that you installed, that's actually a very common problem that a lot of people have. All you need to do is press control shift P, and then you need to type in select interpreter, and then you need to select enter interpreter path, and then you need to click on find. And here you simply click on your virtual environment, then you click on scripts, and then you select Python and then select interpreter. And now this issue is resolved.

[14:03]Okay, so now if we want to test out our agent if it's able to see our screen, we can use the LiveKit playground for that. But first, we need to start our agent in dev mode.

[14:16]And in order to do that, you need to use the command UV run agent.py dev.

[14:26]Now it's up and running. And now we can go to the browser, and then we can Google playground LiveKit, and then click on the first link. And here's where we need to select the project that we created the beginning, and click on connect to support avatar. Hello, how can I help you today? Hi, how are you doing? Hey, I'm doing great. Thanks for asking. How about you? Everything going well on your end? So down here, you can actually go ahead and have all of these elements that you can use to interact with this frontend. So for example, I can turn off my, my microphone here, or I can also share my screen with clicking this button over here. And then I can select, for example, cursor, and then share that.

[15:16]Oh, wait a minute, I also have to enable my microphone again. Hi, can you see my screen now?

[15:26]Yes, I can see your screen now. It looks like you're working on some code and I can see a terminal with some logs at the bottom. Let me know what you'd like help with. Great, so now it can see our screen.

[15:41]So the next step is to give our AI IT support agent access to a back end of any software that we might have. So it can basically play the role of an IT administrator, so for instance, it can unblock a blocked user for us automatically. And for this, I actually created a dummy app that is a stand-in for such a software, which I called the generic corporate app. Over here I added this folder. And don't worry, I will put this folder or this app into this video description down below, so you can also download it and then put it into your support agent folder as well, so you can also follow along. And I can show you how this app actually looks like. So for this, we can go to the terminal, and we can type in CD and navigate into this folder. Generic Corporate app, and then we have to start this app by typing NPM dev. And over here now you have this link where you can click on to, and then that will open a app here in your browser. For this, you will have to have Node.js and PM installed, and don't worry, I will also link a video in the video description that explains how to install these two things. But for now, I can show you how this app works. So this app is actually just a login screen, so if you put in some correct credentials, you can actually log into a dashboard of some sorts. And the correct username for this would be Vienna Maxman 123. And the password here is simply password actually, written in this format, password with a zero as an O. We can copy this, we can put it into the password field, try to log in. And here you can see this dashboard over here. Of course, if I type in something incorrectly, for example, an incorrect password with this username again, I will get this error message saying that my username or password is incorrect like in any other software. So we can try this again with the correct one. Again, we can log in. And what I also added was the functionality to be able to block users. So if we go back into cursor, and we go into the generic corporate app folder here, there's a public folder in here, and then a TXT file saying blocked users or blocked users. And if I type in here Maxman 123, and I save this file. And I go back to the app, I try to log in correctly again, I will now get this error message over here saying that I have been blocked.

[18:18]That's basically just a dummy function of being able to block users. So now if you want the AI agent to be able to perform the task of unblocking the user for us, we can now create a function tool for that. But first, we would need to add some new files in our folder. For this, we can click on this button again, and then type in tools.py, and we would also need to add a prompts.py. Inside of this tools.py, we are going to define the actual function tool, but first I would need to add some new libraries in here. That I'm going to use. And I also need to add some code, or the actual code of the function tool itself that I already prepared. And don't worry, I'm going to share the code of this whole agent in the video description down below so you don't have to type this yourself. But for now, let me explain what this does. So first of all, I create, I created a function that is called unblock user, and it is very important to pass this parameter called run context. That is important for the function tool itself. But after that, you can pass actually any variable that you want. In this case, I simply pass the username itself. And here it's very important to give this function tool a fitting description, so the AI agent knows what it actually does. In this case, it simply says unblock users so they can log in again. And this function tool is actually very simple. So all it does is that it simply goes into the folder Generic Corporate app over here, and then it goes into the public folder over here, and then it goes to the, or access is the block user.txt. And all it does after that is it simply clears the content of this file.

[20:08]So if you remember, we are only blocked if the username of the user is inside of the file. If it's cleared, then of course, we can log in again. And that's it, that's all it actually does. So another thing which we would have to add is inside of the prompts.py, a description when to actually use the tool properly. So for this, I already prepared a fitting prompt right here. So here's a very simple instruction what the agent should actually do. First, I tell it what it actually is, so it says that it's a helpful voice AI support assistant. And then I define a task for it to do, so it simply says that it should help the user. And here's a step-by-step instruction how to do that. So first of all, it should actually start by asking the user what the actual issue is, and then it would either try to resolve your problem by either answering questions, or guiding you step by step while you are sharing your screen. And the thing it will also look for is actually if you typed in your username correctly. If you remember in the beginning, I showed you that the username should start very specifically. It should start with a backslash with followed with the domain and then a backslash again and then the actual username, so like this. So if you have a typo in it, or you uh misspelled it somehow with a forward slash, for example, it will also be able to spot that error, and then will tell you that you should change that. As well as now comes the important part, unblocking the user. So if it sees on your screen that you have the error message that you are blocked, then it will use the tool unblock user, of course, to, of course, unblock the user. All right, so now we can save this. Now we can try this out again by going to the playground again.

[22:08]And then we can simply connect to this, and connecting to this again. Hello, how can I help you today? Hi, how are you doing?

[22:20]That's great to hear. Let me quickly create a ticket and send you a summary of the solution by email. Could you please provide your email address? Yeah, sure, let me type it into the chat.

[22:36]I've sent you a summary email and the ticket has been created and closed.

[22:46]If you need any more help, feel free to reach out. Have a great day. Bye-bye. Thank you. And there we go, everything works now.

Need another transcript?

Paste any YouTube URL to get a clean transcript in seconds.

Get a Transcript