How to use ChatGPT.(Power Automate Cloud flow)

03/11/2023

Japanese version.

Introduction to using ChatGPT from Power Automate (Cloud flow).

Stems

Get the ChatGPT API key (secret key) in beforehand.

Then set up the Initialize variable Action.

Specify APY_KEY for Name, String for Type, and API key for Value.

One more Initialize variable Action is set up, with prompt in the Name, string in the Type, and the contents of the query to ChatGPT in the Value.

Set up an HTTP Action.

Set up as follows.

ParameterValue
MethodPOST
URIhttps://api.openai.com/v1/completions
Header, line 1, leftContent-Type
Header, line 1, rightapplication/json
Header, line 2, leftAuthorization
Header, line 2, rightBearer @{variables('APY_KEY')}
Body{
"model": "text-davinci-003",
"prompt": @{variables('prompt')},
"max_tokens": 2024,
"temperature": 0,
"top_p": 1
}

When the flow is saved, the @{variables('APY_KEY')} and @{variables('prompt')} parts change.

The result from ChatGPT is obtained by the following Expression.

trim(body('HTTP')?['choices'][0]?['text'])

The flow is complete.

Overall view

Links

How to use ChatGPT in Microsoft Teams.(Power Automate Cloud flow)

ChatGPT Articles