How to use ChatGPT.(Power Automate Desktop)


Japanese version.

Introduction to using ChatGPT from Power Automate Desktop.

Overall view of Flow

Robin(for copy and paste)

It can be copied and pasted into Power Automate Desktop.

SET APIkey TO $'''sk-'''
Display.InputDialog Title: $'''Enter your question for ChatGPT.''' InputType: Display.InputType.SingleLine IsTopMost: False UserInput=> UserInput ButtonPressed=> ButtonPressed
Web.InvokeWebService.InvokeWebService Url: $'''''' Method: Web.Method.Post Accept: $'''application/json''' ContentType: $'''application/json''' CustomHeaders: $'''Authorization:Bearer %APIkey%''' RequestBody: $''' {
\"model\": \"text-davinci-003\",
\"prompt\": \"%UserInput%\",
\"max_tokens\": 2024,
\"temperature\": 0,
\"top_p\": 1
}''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100312 Firefox/3.6''' Encoding: Web.Encoding.AutoDetect AcceptUntrustedCertificates: False ResponseHeaders=> WebServiceResponseHeaders Response=> WebServiceResponse StatusCode=> StatusCode
Variables.ConvertJsonToCustomObject Json: WebServiceResponse CustomObject=> JsonAsCustomObject
Display.ShowMessageDialog.ShowMessage Title: $'''ChatGPT''' Message: JsonAsCustomObject['choices'][0]['text'] Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed2

Flow creation steps

Get the ChatGPT API key (secret key) in beforehand.
Create the variable %APIkey% in the Set Variable Action and set the API key.

Mark the %APIkey% variable as sensitive information.

Set up a Display input dialog Action to ask the user to enter a question into ChatGPT.

Set up a Invoke web service Action and set the parameters as follows.

Content typeapplication/json
Custom headersAuthorization:Bearer %APIkey%
Request body{
"model": "text-davinci-003",
"prompt": "%UserInput%",
"max_tokens": 2024,
"temperature": 0,
"top_p": 1
Encode request bodyOFF

Set up a Convert JSON tocustom object Action and set the JSON parameter to %WebServiceResponse%.

ChatGPT answers are set to %JsonAsCustomObject['choices'][0]['text']%.



ChatGPT Articles

Tips(Power Automate Desktop)