How to Debug Vapi Assistants | Step-by-Step tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in a world where we can connect thousands of services together it is completely normal that things break mostly every software provider has their very own interpretation of how a web hook or an API has to be structured so in the end it is up to us and integration providers such as make.com or zapier to make sure that everything runs smoothly and exactly that is also the case with vippy creating a transient based assistant can be pretty straightforward but what if some arrow ures and you hear stuff like couldn't fetch assistant what do you do then well in today's video I'm going to explain to you the ins and outs of how you can debug INB and outbound agents directly inside of vapy in case they decide not to work and at the end of the video I'm also going to include some extra goodies on how you can debug function calling oh and in case you don't know what a transient based VAP assistant is I made a video about that right here so you can check it out and get a better understanding of how vapy actually works what the infrastructure is and how you can Implement that into your business it's definitely worth checking it out now to get started let's look at inbound agents first so if you currently try to build an inbound agent you have probably heard of The Arrow message couldn't fetch assistant exactly that happens when you try to create a transient based assistant with values that are not supposed to be there or something is wrong within the configuration this is as much of an arrow that you can get with the inbound calls but imagine and wait what you can get with an out phone call which is pretty much nothing at all well there's a little bit of something which I'm going to explain you so what it looks like at that and VY actually implemented some features that we can use for our advantage to debug and understand what is actually wrong with our system that we created so the methods to debug for inbound and outbound are fairly similar even though that outbound has a little bit of more potential for errors than inbound has all that can go wrong inside of your inbound agent is literally inside of the Json construct that you provide as your transient based assistant so right here on my screen I have a transient based assistant that I've created from one of my previous videos if you haven't seen it and you don't know exactly what that is definitely check out my previous videos on how you can create those transion based assistants easily and you can get a better understanding of them in the first place I'll also link the video up right here and in the description below so as you can see this is literally a Jason construct and it contains some information that is not accepted by VY when creating a new assistant and especially an inbound assistant that is based on a transient based assistant and to prove you that I'm going to show you that whole thing inside of a call so all I'm going to do is I'll literally just run the scenario once and I'm going to call this assistant from my phone so that you can actually see what happens when calling him couldn't fetch assistant exactly so it couldn't fetch the assistant which is the standard message that you get when the assistant couldn't be fetched or something is wrong inside of the connection and to actually figure out what happens is a little bit complex if you don't know it so we are going to straight dive into how to do that and we are going to leverage some features inside of Vy that just help us immensely on actually figuring out every single issue that is happening inside of the Json that we created and the easiest way of doing this is using a couple of tools which I'm going to show you now so obviously first of all we need the assistant Json which is this one right in here I'm just copy this thing and I'm going to run it through a Json editor so this one is called Json editor online.org it is free and it basically just allows you to validate your Jon constructs so I'm just going to paste it here and you can click on this little button to format it which I've already done so mine already looks clean which is just easier to read so in case you have a transient based assistant that is literally minified which then looks something like this you can literally just format it by clicking on the button and you're good to go so now since we already understand the assistant better I'm just going to use this whole thing with a tool called Postman which basically allows us to debug and understand requests to see what's actually happening in between and vapi has a pretty cool point which is called create assistant which basically allows us to create a static assistant on their direct platform which obviously is nothing that we would like to do right if you think about it but the beauty of it is that it actually shows you the arrow messages that you get when creating the assistant so we can use that create assistant endpoint to basically figure out what is wrong inside of our actual assistant Json that we created so for doing that I'm going to show you a couple of things number one is called Postman which is basically the tool that I was talking about which we can use to debug apis so you can simply create an account it is completely for free and if youve probably worked with apis you probably have one anyways so the first thing we do is basically click on this little plus after you've created your account which basically creates a temporary way of testing an API endpoint so now what we're going to do is we head into the vapi documentation which you can do by going to vapi and the docs which opens a new tab and inside of this new tab we're going to API reference up here and within the reference we scroll down to the assistants and click on create assistant so now you can see the whole definition of the assistant in a couple of languages we don't mind much about the language we just keep it at curl but all we're going to do is we copy that URL which is basically the endpoint that we would like to use for creating a static assistant on vapi so we paste that one right within the URL bar up here and we keep that whole thing at uh we going to change this thing to post call vapi basically requires a post request when creating an assistant and as a data you can see that they basically send over the whole assistant Json and this is exactly what we are going to do as well so from the Json editor where you basically validated your Json for better relability you simply head into your Postman request you click here on body you go to raw and it should usually select Json by default if it doesn't you can select it from the dropdown and we are going to paste that whole request right within here so if I click Send now it basically sends a request to VY which will be unauthorized because we haven't added our API key which you will see right here it says missing authorization header so we basically are unauthorized and cannot create the assistant on our account to fix that we simply go to authorization we're going to select basic off right here from the drop down and we are including our Bearer token so before clicking on basic off all I'm going to do is I head into my VY dashboard I go to organization which is a new menu item so previously the API keys they were located in the account now they are inside of the organization so we simply click on it and you can copy the API key with this little symbol right here so now we head back to our Postman we're going to select bar token and we're going to add our API key now once you selected bar token all you do is you basically paste this API key in the token field and that is all you need to do so now we head back to the body and we are basically trying to create that assistant using the send button which now in return gives us a message that tells us the exact issues that we are facing with this Json generated assistant so this transion based assistant and as you can see here it basically mentions four different issues so there are four problems inside of my Json that vapi has a problem with or does not want to see inside of the Json which is that a property ID should not exist orc ID should not exist created and updated that should not exist I specifically left it this exactly exact example because I have previously created another video where I listed a temporary or a transient based assistant that is super easy to configure using a simple make.com template which uses a similar structure like that so what I'm basically do is I'm stripping away those values which is the exact same thing I'm going to do right here so it basically mentions that ID orc ID created at and updated it are not allowed so you can see them right within your Json now since you formatted it which is ID or ID created it and updated ad so all I have to do to make it work is basically remove those values and I'm going to keep updated ad just to show you that those error messages will now disappear except of the one for updated at since I have not removed it and that is the c thing so it says not up updated AD should not exist so I'm going to remove this same thing again and now you can also see inside of vapi when I go inside of my dashboard so you're right here I currently have two assistants which are called Sarah and Lisa and if I'm going to create the assistant now you will see that it basically returns me a fully valid assistant including the ID and if I head back into my V dashboard and I click on assistants again you can see that it basically created a duplicate of that assistant so that worked just well which means now this assistant is actually functional it works and now I can basically just use the soul Json that we have here and put it back into from wherever I basically call this transion based assistant so right in here I can basically just keep it in this minified version which is okay for me obviously if you don't want that you can format it within here again and this is literally it so now we already managed and figured out how to validate those transient based assistants which is the exact same thing for the outbound calls as well so in case you do an outbound call and it might not be working this might be one option for you to actually check if the assistant itself is working if everything is configured the right way while the structure is fairly similar both for inbound and outbound agent to test and debug that assistant Json in general there is another aspect that you can test for outburn agent that basically tells you a little bit more if stuff works or not so now I'm going to show you exactly for outborn agents how you can actually figure out if something works or not and there are two Bas two basic ways way that I'm usually explaining especially to us or to my customers as well and one is usually using Postman and the other one is using make.com so if we are basically heading back into their documentation where you probably have been if you have created an outbound agent in the first place you will find an endpoint called create phone call which is this one right here and as you can see on the right you can basically send along either an assistant ID which then would take a static assistant from within your Ry assistants or you can also Define a transient based assistant right here that basically contains that whole structure of that assistant Json so to actually debug that and let and see if that works and if something works or doesn't work we are going to use uh the first example make.com to create a phone call so I'm going to use the exact same setup I'm basically just copying this URL to create a phone call I'm going to head into Postman I click on the plus I add a new add the URL the endpoint right within here and if I look into here now it basically says it also requires a post call so I'm going to switch the post method to post or that request method to post and now we have again the body where we basically need to Define all of the information before I'm going to do this I also just quickly select the bar token as an authorization header so that we have also set up authorization for this specific endpoint all right I've done that and just headed back to the body tab so now we click again on raw and we select Json from the dropdown and now we can configure the dynamic Json that we basically would use for creating an outbound call So based on the documentation as you can see here it contain contains a Json that has a couple of values it has an assistant key which basically contains the transient based assistant in our case we're not going to use assistant ID because we don't have a static One Max duration seconds I'm not going to Define I just leave it at the default and if we scrolling down to the very very end you can also see a couple of more fields which is metadata phone number phone number ID and here customer and customer ID so customer ID we don't have since we basically just call call some person that we basically have from a lead list you can also see an example for that in my previous videos so we're going to use customer which means we create a temporary customer on demand in that moment where we calling him which means we have the customer number added here and the customer name added here so what I'm going to do is I basically just copy this whole Json block right here and I'm going to paste this exact same thing into the Json editor and now I'm just removing this transient based assistant right here cuz this is one that is just from the documentation and we don't want to have this inside of inside of our resistant so this is the part I'm going to remove and all I'm going to do is I'm basically just taking that assistant that we created earlier or basically whatever outbound assistant you have and you're just going to paste it right within here so now we have a a basic demo request that I could use to send out uh custom information I'm just going to remove the customer ID and the other values that I don't want to set which are those and which is also the phone number ID or the phone number ID we can actually leave because we have the phone number so we don't need to temporarily create an assistant phone number so I'm just going to remove this part as well and I'm also going to remove that last part boom okay so now we also need to set up a phone number ID which is the one that we can get from the phone number that we have purchased inside of viy just going to head quickly over to the phone numbers Tab and I'm going to copy the phone number ID which is right here so I'm going to paste that part within this part in here and for the customer we can now set up a number in that case I'm going to use my number so I will just be hiding this number for a moment so you will not see it okay so I basically added my number to the Json construct so I'm going to copy this whole thing and I basically just added inside of Postman into the body which is right here and now since we have the assistant right within here we can basically give it a try and call that phone number which means if I click on it it should receive a call on my phone if everything is configured the right way all right that does it so it created the phone call and I should now see on my phone a call coming in from that agent which you can see right here so it works now the agent is coming through and we have a valid Json that basically works so let's say you have something wrong inside of the Json that you basically created for your outbound calling assistance like for example missing the number like I did right here I'm just going to copy copy this broken version of the assistant I'm going to paste it here and I'm going to click Send and now you can see that there comes an arrow back which is exactly what you see inside of Postman which basically defines where the problem is so you can directly see it inside of the postman response so if you basically have a assistant created on your very own platform or on a different provider where you make the phone call from whatever kind of CRM or automation platform that is this can be any kind of platform it is sometimes hard to see the responses so using a tool like Postman allows you to see the exact arrows that are coming back inside of the response so that you can get a better idea of what's going wrong now the other way I'm going to show you how you can actually figure that out inside of make.com we are going to use the same broken assistant and let's assume we have a new make.com scenario so we just ignore the fact that this one is a different scenario I'm just going to use an HTTP call to make a request where we basically want to now create the transion based assistant directly in of make.com so let's say we have a body type that is set to Raw within here we set the content type to Json we paste this whole big block right within here that basically has missing phone number and we're going to click on par response yes cuz that's always nice for you to debug and read the actual content which again helps you just to make things a little bit easier when debugging in general we're going to switch the request method back to post and inside of the URL we're going to copy the exact same URL that we used as an endpoint from within the viap documentation right up here okay I'm going to head in paste this URL and now we also need to define the header so let's say you want to create this call inside of me we will probably have a authorization header and this one is set to Bearer space and then your API key so I'm just going to paste the API key right within here and once you've done that you simply click okay so if I'm going to run this module now you basically are able to C as well a response which is what you see up in the bubble right here and if you click on it you can see at the bottom it shows a status code 400 which means there was an aror inside of the configur configuration so if you have a successful creation of a call this would show a 200 or 200 plus so something in the 200 range which basically means that the request was accepted and it was it was processed properly but if you see a status core 400 or anything above you know that there is an arrow inside of your configuration and you can click on the data button right here which then again shows you that it was a bad request and inside the messages you can again see the same message that you would see inside of Postman so that again helps you to figure out where exactly the issue is so here you can see it says customer. number must be a valid phone number and as you can see inside of the Json that we created earlier we have removed the phone number right here so that is the correct thing so this is just a little tip on how you can understand even with like no code or loco tools how to actually debug responses so that you can see what is going wrong and how you can easily fix that without spending hours inside their documentation and trying to figure things out so if you're still watching you're most likely very serious about building AI voice agents and here I'm going to drop another goodie for you that help you to understand better how you can actually debug function calling or tool calling inside of Vy so if you don't know exactly what tool calling is it is basically the possibility of giving your assistant access to extra features that they can leverage within and during the call so let's for example say you would like to get the weather during a call or you would like to schedule a meeting you can do this directly inside the call and you don't have to wait until the call is at the end and you can then take the transcript run that through open AI to figure out whatever kind of appointment they want to book which again just allows you to extend the stuffff and make the bot more sophisticated just better CU you can even tell the user back that the meeting couldn't be scheduled because there's already another meeting at this exact time so you know you just have a more smooth user experience overall and creating functions and doing function calling with VY is another whole topic that I'm going to cover in another video but for now I'm just going to show you how you can debug that and if you have worked with VY before you will know that inside of their dashboard inside the assistance you can basically head to functions and create your own custom functions right here and you can add a server URL right within this field so I'm not going to set up everything but you probably know that when you create a function you have to give it a name so let's say get weather and then you have to also Define what it does get the weather for a specific country for example or for a specific City let's say and then you can add properties so we can say something like CD name and you can give it a a more description about what the property actually is about this is the city city name so then you can basically use whatever kind of API you have to connect it inside of the server URL to get the weather for the specific City the thing is when you add your server URL right within here and you call the assistant and the assistant is not able to fetch that information because of some error that might be maybe your url is not authenticated maybe it is broken maybe something doesn't work from the server side in in the first place so maybe the server is off or you know any anything that happens in between of fetching the information like fetching the information about the weather and sending it back it is very hard to debug because it happens asynchronous during the call so you cannot exactly see what the response is so what I generally do is that I'm going to use a tool called webbook do site which basically allows me to get insights into the actual response and the data that is transferred in between if you would have a function like this so all you do is you head over to web hook. site and it will create for you a dynamic URL that looks something like this so you can simply copy this one to the clipboard you head into your VY assistant and you simply paste this one into the server URL field right here so I'm just going to test this with you what I'm going to do is I click save so we have set up the city name this whole thing is published so there's nothing to worry from my side I'm just going to change something else just going to change this I'm going to publish this whole function just to make sure the function is actually added because I had it before and wpp had some issues that the functions weren't added so I assume after refreshing this one should be there just to make sure all right so there was in fact an issue with my internet so it didn't save it so what I did is I basically just recreated this whole thing with a get weather request I set the description I set the property I edit the server URL for web. site I click save and I'm just going to edit this as well just to make sure we can publish that whole function again so let's just quickly do that and this worked so I'm just going to refresh just to make sure that the function actually has been saved okay so I basically forgot to click on ADD so I have just simply recreated this whole function with the get weather and we have a property called city which I set to the city we get the weather for so this function is now basically there I'm going to publish that whole thing which means the assistant function is right here and it should be now available inside of our assistant so all I'm going to do is I'm literally just going to give this assistant a call and try to call this function which then in return in return Whenever I Call this function sends a request to web. site where we can see the exact response that was sent over so let's give this one a try all right we just going to call the assistant and see if we actually can manage to call that function hello this is Lisa how may I assist you today hey lasa can you tell me the current weather in London hold on a sec I'm sorry but it seems that I'm unable to retrieve the current weather for London at the so as you can see we managed basically to send over the function call and web hook. site received that information including the whole information about the call so you can see here that it basically sends a function call request as you would usually get it for a function call and you can see that we get back the information that basically the properties that we defined so it said City London which is the exact one get weather is basically the function name that we gave it so until here we already know that the function is actually called and we can see the exact data that is right within here I'm not going to scroll down because there's a little bit more information about my phone number Etc but you get the hang of it so you can see the information that comes through here and now if you let's say this is one part obviously this is for the assistant to request the information for that function call but there's also the other side where you basically do whatever you do inside of that function call and then return the information back to this exact same call and to debug that you can also use web hook. site as the same as a same starting point the only re only thing that you now make different is that you actually add your very own endpoint right within the function call right here or inside of your transion based assistant and you add the web hook. site request wherever you need it inside of your very own code or if it is a make.com scenario that you use to create the function call uh response you can add it as well there so web book. site just in general helps you to understand external requests that are not directly or like not synchronous but you asynchronous so you can see them even if they don't happen at that exact time where you have anything else to debug with this is and which is exactly why I like web hook. site so much so the tool is completely for free you don't even need to create an account you simply have to web hog. site and you would get a URL that you can then use use either for the message that comes so the function call that comes from buy or even from within your own code where you basically do whatever and return that information back to the function call obviously if you use something like make.com you can even just run that scenario once and check out what happens in the meantime when this function is called which again gives you just more insights into debugging but obviously if you use make.com I assume you know that already so for now that is all I have to show you I hope this video was helpful for you and you learn something new I would definitely make more content about VY and its features so that you can make the most out of your very own assistance that you create on their platform and in case you has anything else you would like me to make for you so that you can see it and get a better understanding of it simply Drop it Down Below in the comments I'm very happy to help you out and that's it for now until next time see you soon
Info
Channel: Jannis Moore | AI Automation
Views: 1,489
Rating: undefined out of 5
Keywords: voice ai tutorial, tutorial, ai voice agents, twilio voice call tutorial, ai voice clone tutorial, ai sales assistant, how to create ai chatbots, ai voice calls, how to create an ai caller, phone ai assistant, vapi tutorial, full tutorial, full ai caller tutorial, vapi ai tutorial, assistant vocal, ai assistants, assistant, ai agency, ai agents, Synthflow, make money with ai, ai voice clone, start an ai automation agency, liam ottley, bland ai, build an ai voice assistant
Id: u-8xdblVY_4
Channel Id: undefined
Length: 22min 45sec (1365 seconds)
Published: Tue May 07 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.