How to call API/Webservice in Copilot? | Using Power Automate | Microsoft Copilot

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys in today's video we are going to see how to use or how to call a web service or a API from the co-pilot okay and for this we are going to use the power automate so in this we are going to create many things uh along with the calling the web service right we are going to pass the Json we are going to call and power automate to input and output a variable and also maybe in the future we will I will show you uh how to use the conditions like if and else okay okay so where we were yeah last time is we created this bot we when we ask ticket status not the ticket status sorry uh flight status uh is it flight or flight is typo let's see if it takes yes okay so if I give any garbage thing right now it is not validating anything and it display the status right so let me click over here so that we go to that flow automatic now once we take the flight number uh we are displaying over here the status right so now what we want to do is call the actual API that we have over here right and let's see if it is working okay so what I will do I will click or click add an action call an action sorry and what we will do is we will create a automate uh Power Auto automate flow in that we will create or call the HTTP we will pass the Json and then we will get the response back okay so it may take time because this is the first time I'm loading the power automate in this platform or this uh environment so let me pause the video for that okay so it has been loaded so this is what you will see something like so this is uh Power automate where you can create the automation flow right and make an API call through Power automate gives her give us more flexibility with respect to creation of variable passing of the variable and the Json or the XML calling HTTP and also you can add many things uh like you can uh [Music] call uh various built-in functionalities when connectors are there Excel mail and all this thing right so but we will not go over there we will start from here add an input so right now what we are expecting this power automate to get a uh flight number right so that is what we are expecting we will leave this field as a blank okay you don't have to worry about that now what we will call next add an acction is HTTP so let's see if it finds the [Music] HTTP send an http H is this is the one why is showing premium it's not a premium okay now over here what method we are going to call we are going to call the G method what exactly the is the URI so this is the URI that we are passing right and this lasting is the flight number so that we will do and plus we will add expression and uh where is my variable sorry Dynamic content yeah flight number so once I do that it will be appear like this okay do I have to pass any header are you passing any header uh no nothing so no header need to be pass body is empty and we are supposed to get the response okay so now what I will do is I will do a pass pass J okay now what we are expecting over here the content will be inside of HTTP body right so my HTTP body is the content and the schema so generat a schema what I will do is I will go over here select my response that we have based over here and click done okay and that's it nothing we have to do with respect to the the par now before doing anything else right what I want to do is I want to identify what are the variables which I will return back to my uh bot copilot right so what I want to return return is flight date okay something like this I will create so what I have to do is create a uh variable right so I will search for variable over here and initialize a variable and variable name will be something like flight date okay and let me pass it as a string okay uh just do that no need to initi sizee any value similarly again what variable I will again uh what I will pass flight status okay so I will give flight flight status which will also go as string okay do I want to pass anything else uh for date this flight has status okay maybe I want to add from uh departure airport and arrival airport if you want so let's do that so let's do D airport and this airport AR aort so something like again variable and initialize a variable uh let's say dep airport it is again string again add an action variable oops variable and initialize a variable and ARR airport string okay uh click save uh before clicking save let me uh I clicked saved so uh before doing that uh let me show you this there is a new designer also so if you don't see this kind of a screen you might be viewing something like this which will appear now like this so it's more or less same nothing Chang ches over here with respect to the functionality just that it has additional co-pilot functionality where you just write what you want to do and it will create the flow for you we are not going to do that because we are learning and we want to learn right okay so we have initialize four variable which we want to return we call the API right and we have now passed the gon now what we have to do is set that variable right so now variable set the variable what we want to do we want to first set the flight status and now click over here go to Dynamic content and this is the P Jess click on see more okay so that you will get all the uh responses right and this is the flight status right I will click over here and click add so this got added okay similarly uh I can do I think copy do we have option of copy no uh okay no worries variable again set variable which variable we want to set now we want to do variable set the date which uh value uh body flight date right click add and and again add action variable set date now what we want to set is uh departure airport right and click over here Dynamic content where is the Json Json yeah this one over here so it will be body uh departure uh just a second so it will be departure airport right okay I'm just seeing if we have directly that variable name otherwise we have to select airport and this is arrival so no not this airport another airport will be there airport airport airport airport airport airport yeah and this will be departure airport okay so this is done and then we will add again for the arrival variable set variable and this is arrival and dynamic content Dynamic pass J see all the values and we know that the below airport this is first airport and uh oops I think I miss where is airport yeah this one and this is arrival airport and click add and uh now what we want to do is return this variable right so input was over here if I scroll up input was your flight number and in the output what we want to return return is first is uh I think flight G status right and that value we have stored into our variable flight status click add another thing we want to return is flight date right so this left hand side whatever you write is the exit variables that will be appearing over there in the co-pilot site right uh flight date and then we are saying ARR Port something like that okay and that will be arrival airport that is containing that variable and DEP port or Capital Let It Be and once we click over here and DEP airport okay so everything is done we will also do change over here to the name PVA power virtual assistant uh Airline status so something like that will be uh the name of the call Flow or not the call Flow the power automate right and I will click publish unfortunately when you're are doing uh testing with input variable right so you have to run first time what is this manual not sure we can't test it right now over here because it's uh need to be uh uh run once from the co-pilot site so let's see if it is working or not so what we will do is we'll just click a refresh over here so that uh it get sync with the power automate and have that uh uh new flow that we have created over there in the power automate over here in the co-pilot side so sorry for the background noise if you getting uh there is a airport nearby and some high speed jets are running okay so we will do call an action and hopefully yeah that one is over here the one which we created so it's asking for input so input we stored into this variable we will select over here and select the variable it automatically creates the variables that uh output variable with their own same name right so you don't have to worry about that what you will we will do over here is status e we will do something like this uh what is that your flight number current status is uh what is that flight LED okay so we will select uh flight status enter uh for date entered for arrival departure to arrival oops it got deleted uh arrival so let let's SK it like this click on over here click save and we will do the testing let's see if it is working if any error we will debug also click save okay topic is save we will refresh the bot over here so that it gets the latest one we will say flight status and we will provide the flight number and let's see if it is working or not or if you're getting error it failed very nice okay so what we will do is we will go back over here in power automate and what what we can see over here is it shows as failed okay I will click over here so it will show me in which Step it has failed so it will be easy to debug so you can see that it's failed to do pass in the Json passsing the Json okay so the content we received like this we have schema like this invalid type expected integer but all blah blah blah right so what we will do I will copy this crl a contrl c click on edit and we'll go down to par Json and I will C control a delete sample body paste click done okay and click save draft and we'll do publish and test it over here since we have run one time we have now luxury to test that uh this uh Power automate from here directly so what I will do is I click on test select automatically recently I will select the failed one and click on test so what it will do it it will execute the same thing with the same variable which was passed by the co-pilot and and then still failing over here so understanding the error that we have over here so what is saying is it's expected an integer but got null right invalid type for data one arrival and day delay sorry so what we are saying so this first one is okay the issue is with the second one in that arrival in that delay is null okay so what we have to do is to change the schema that we have created because I think in above one above arrival I think we are getting delay as integer right so this is what the error is saying right expected integer but got null straightforward so what we will do is we will check change the schema to be like what we have for nuls right uh so it will be just the two cly brackets uh that we will have over here uh like this Okay click save and publish publish is done so let's uh start the board so again flight status okay and then we will give the flight number that we have over here right and then it's again calling the power automate hopefully it gives the result once it calls it's calling for a long time 1 2 3 3 4 5 6 7 8 9 10 is it working or what happened it's working now I'm just checking I think it is stuck power automate where is this C still will oh it got it work so it got success so now we got the status as landed right and we got the date why we got the date as this one log out of this one right so it has worked and displayed the information right now in the next tutorial uh maybe after calling the web service we are displaying the status like this uh what I'm planning to do is is call something like uh uh adaptive card so that we display the response in uh what do you say more intuitive way adaptive card M Microsoft so they have already given a bunch of uh adaptive cards uh I think this one uh what we will do is we will Leverage one of the uh what do you say adaptive cards that they have where it is designer so if you see over here we will have something called like this and uh which display information like little bit more intuitive and all this thing and we can use all these parameters so what we will do is uh we will call out for uh I think which one will be good over here I think yeah your flight details I think this will be or this will be trip to UA or something like that so something we will reduce few of this text or this one your flight update yeah this looks much better right so we will maybe use something like this or this is maybe whatever I found uh matching for this one we will use that into uh what is a add recard for the response that we are seeing over here uh which is nothing but over here okay hopefully you like the video thank you have a nice day
Info
Channel: Rajiv Coomar
Views: 1,367
Rating: undefined out of 5
Keywords: Copilot, API, Webservice, Power Automate, http, parse json
Id: YvTKX-jD9Qc
Channel Id: undefined
Length: 21min 48sec (1308 seconds)
Published: Fri Apr 12 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.