Power Automate and ChatGPT: How to Create a Custom Connector

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
integrate jet DPT directly in your power automate flows let me show you how easy that is to create a custom connector in power automate go to data over here and then you click custom connectors we would like to create a new custom connector for our chat TPT so you click up here and then you choose create from blank we will give our connector a name I will call mine chat DPT and then I click continue first thing we will need is a nice logo for our custom connector so we go to Google and then we search for chat TPT logo PNG like this and click enter go to images I will pick this one but you're free to choose whatever logo you want I click here then I go over here to the right I right click save image as and I place it on my desktop so it's easily accessible then I go back to Power automate and our connector creation I click upload here I point to my newly downloaded icon and then I click open then we have an icon but you can see we have gray borders around it that is because it's transparent so we will add this logo color to these areas the way we do this is to go to Icon background color make a hashtag and we say 7 5 a c 9 D and now you will see that this is entirely green then you can give your custom connector a description if you wanted that is optional the scheme that is https and then we need a host this is API dot openai.com like this we can click security down here the way we authenticate to this API that is to tell open AI chat DBT that this is us that is true in API key so click this drop down and choose API key the parameter label that will be API key the parameter name that will be authorization author then relaxation this is very important in case you misspell it it won't work the parameter location that is header so we can click definition here you go up to actions and new action then we will create these default ones this is the text that you want to get showed in power automate whenever you search for your connector so I will just say ask chat DPT like this we can give it a description so for example asking chat TPT and this operation ID that is to identify this action internally so I will just call this ask chat GPT like this scroll a little bit down to request import from sample click here the method we will use for our API call to chat DBT that is post and now we come to the URL I created a document you can find that in the video description below it looks like this so just download it and you will have all this information that we'll use in this video to find the url that is the newest endpoint you just copy this address here Ctrl C we go to our browser open up a new tab Ctrl V enter this one changes a lot so make sure you go to this URL and grab this one down here and not just use this blindly so then we go back the UL I just Ctrl V paste it in then we need some headers so I go back to the document I created for you you'll find the headers here mark it and paste it in you can of course also type this then we have the body body that is this request body I also created that one here go over to the body Ctrl V at n and let me explain what this is first we had the headers here we specify that the data that we send this body that is in the Json format and the body itself we have a model that is text DaVinci 0 0 3 it's built on the same engine as chat DBT that is the DPT tree we have a random prompt that is what's a custom connector you can type any prompt in here you want this is just for testing we will make it Dynamic so it will of course work with any prompt you have the max tokens that is a thousand that is how many tokens chat DBT should use from your account a thousand tokens that is about 750 words you have about 900 000 tokens for free so around 675 000 words that's a lot the temperature that is Randomness in output it ranges from 0 to 1 where 0 is the lowest Randomness in output that is we have very strict answers chat DPG is not very creative or in our case the text DaVinci is not very creative the end that is how many completions we use to generate each prompt the higher this one is the more tokens you use so be careful we just set it to 1 and we say import go up here and click create connector this will take a few seconds we are now updated we can test it so click this test here and we will need to create a new connection so click new connection and up here I'll write in a large B I'll make it visible so you can see what I do here I'll type in barrel and then space this is very important now we need an API key again we go to our document here so I copy this API key open up a new tab paste it in Click enter here you need to either log in if you already have an account or simply just sign up it's free so just go do that having logged in it looks like this you just click create new secret key copy the key go back to your connections here and then I paste it in I say create connection then we need to jump back to Power automate and here you can see it doesn't show up you simply just need to press refresh here and we have it here then we need to fill in the parameters first of all the content type that was the application forward slash Json since we are lazy we are automation developers I just copy paste it in here but feel free to write we could fill in all these parameters but it's easier just to say raw body delete these two find the raw body here Ctrl C copy it go back here and paste it in then you say test operation if I scroll a little bit down you can see that this works because we in the body if I go to choices text you can see a custom connector is a type of connector that is designed to meet blah blah blah this was our sample question what you need to do now is to go into this body Ctrl a to Mark everything Ctrl C to copy it then I go back to my definition scroll a little bit down here you go to response add default response click that leave the headers blank but in the body Ctrl V paste in what you just copied click import if we start our custom connector creation here we would have to fill in these parameters each time we use the custom connector that would be annoying so let's make some default values scroll a little bit up here and under request go into content type click edit in the default value we want to have the application forward slash Json so I go to my document copy it out paste it in here this is required I don't want to give the user a chance to change this so I'll say internal this can't be changed in case you warned an expandable menu you could choose advanced then you go back we scrolled down again now we want to edit the body so you click body edit here you'll see our parameters we will edit each one of them I'll start with Max tokens I'll click edit we will give it the default value that was 1000 and again here I might could have written this this was very easy it is required and it's internal I go back the model click edit here here you might want to copy it so you don't misspell it Ctrl C in the default value control V it is required and it's internal I go back the N I click edit here and let us just refresh what the N was that was the one and the temperature was Zero so here I say one it is required it's internal I go back let's wait with the prompt let's take the temperature first I click edit in the default value I type in 0 it is required and it's internal I go back The Prompt we want the user to fill that in but we want to customize it a bit so click here click edit first of all we will give it a title here I will say query that is the label title you'll see on the actual field and here that is the pre-filled in description and here I can just say ask chat DPT anything since this is a required field we don't want to send an empty query we say is required then I say update connector this will also take a few seconds and then our customer connector is ready let's go test it so I go up here to create we will choose an instant cloudflow for now we can give our flow a name here I'll say test chat DPT manually trigger all flow and then we'll click create we want to have our prompt in the trigger That Could by the way be an email coming in or anything this is just a manual one this will be a text so a text comes in here in our trigger then we will have our new step now the exciting part comes if I search for chat DBT here is our connector click it and here it is just as we customized it so we could of course write something in here but since we already created an input from up here we will use that so scroll a little bit down over here and take input now we can test it so I save my flow go test it here test it manually like this we have signed in and we click continue and now we can make our prompt here I will say tell me three nice things that will light up my day then we say run flow we click done our flow is running our flow range successfully let's inspect the output so I go in here if I take show row outputs this is the output that we get back from open AI first of all it's a Json you can see that by the curly bracket up here the curly bracket down here when we transfer data in power automate it's always in Json by the way we also get Json spec from the open AI here the one that we are going to look at navigate down to body choices text here you can see you an amazing person and you deserve all the and a lot of nice facts that could light up my date what I want to do here since I don't need all of this I really want to only have the text here that will be navigate into the body take the choices this is an array you can see that's by these hard brackets so I want the first element an array is zero index that means that we will have the zeroth element it's a little bit confusing but that's just to say it's the first element and then we want the text so let's go do that I click edit my flow here let's just have a compose click it here and if I go up here to the inputs you can see I can actually pick this text here the downside with this is that if I pick this power automate will create an apply to each because it recognized that this text is inside the choices which is an array that can contains more than one element this is a little bit redundant since we know we only have one element in choices so let me delete this again what we want to do is to take a new Step again we'll take the compose and we will create an expression this is straightforward as well so mark it up here go over to Expressions first we want to look at the outputs we want to look at the outputs from ask chat DPT so we have a parenthesis we have a single quotation marks and then we just need to type in the name of that action spaces that is underscores so here ask chat DPT like this then we have a question mark now we want to say we want to move into the output so here I have hard brackets single quotation marks I'll have the body forward slash choices remember so now we are in the body choices I move out here then I say I want the first element that is hard brackets zero and then give me the text so here I will say text I can't spell today text like this we also want since we might have some unwanted white spaces in front and in the end scroll to the start say trim this will be move all white spaces go to the end and have a parentheses end here I'll click ok we now have this expression let's go try it again so I click save save and test I go up to input and here I can for example say what important to learn as a power automate developer then I can click run flow again it will take a few seconds and what we want to inspect now is this compose can we get the text out let's click in here yes we could now you can see that we have our output nicely formatted this was 10 points Network and get help to your power to make solutions from more than 6 000 RPA developers the link to join the I love automation Discord Community is right here [Music]
Info
Channel: Anders Jensen
Views: 8,047
Rating: undefined out of 5
Keywords: power automate, chatgpt, gpt3, custom connector in power automate, power automate custom connector, anders jensen, how to crete a custom connector in power automate, microsoft power automate, custom connectors in power automate, create custom connector in power automate, custom connector tutorial, chatgpt in power automate, power automate chatgpt, power automate and chatgpt, chatgpt custom connector
Id: UbwPV_zG4dE
Channel Id: undefined
Length: 16min 16sec (976 seconds)
Published: Mon Feb 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.