Integrating ChatGPT into Your Power Automate Flow.
Use pre-build “Chat completion” action or “HTTP” connector.
"Image of a professional holographic ai powered chatbot floating in the air with multiple data sources around him", Credit: Dall-E

Integrating ChatGPT into Your Power Automate Flow. Use pre-build “Chat completion” action or “HTTP” connector.

Leverage ChatGPT in your Power Automate workflows using a pre-built action or an HTTP connector. Following the trial introduction of Co-pilot and its subsequent popularity, many have explored incorporating ChatGPT into their automation tasks. Initially, setting up ChatGPT for free versions was straightforward. However, with the deprecation of all free versions (Ada, Babbage, Curie, and Davinci) on April 4, 2024, including the "GPT3 completes your prompt" action in Power Automate, alternative methods were necessary.


Prerequisites:

1.????? API Key for ChatGPT Connection: Obtain an API key and save it securely as it cannot be retrieved once issued; you will need to regenerate if lost. Learn more about OpenAI Authentication.

API Keys generation

2.????? Ensure Adequate Funding: Your OpenAI account should have a minimum of USD 5 credits that must be active. You can check it here.

Billing Overview

3.????? Access to Power Platform Subscription: Ensure you have an active subscription to test your scenarios.

?

I will demonstrate the simplest scenario in which I pose a question to ChatGPT and expect a response. You may adapt this approach to suit your specific needs, where ChatGPT can analyze images, interpret data from Excel, or integrate information from various external sources.

?

Chat completion action for ChatGPT Response Generation in Power Automate Flow

1.????? Create a New Flow: Launch Power Automate, initiate a new flow, click 'Skip', and rename the newly created empty flow if preferred.

Create a New Flow in Power Automate

2.????? Add a Trigger: For testing purposes, I will use a Manual trigger as it is the simplest form of activation. You may replace it with your preferred trigger once testing is complete.

Add a Trigger

3.????? Configure Text Input: Add a Text Input for your manual trigger and rename this input to 'Question'.

Configure Text Input

4.????? Insert Chat Completion Action: Following the 'Manually trigger a flow', incorporate a 'Chat Completion' action.

Insert Chat Completion Action

5.????? Data Entry:

a.????? Body/Model: Select "gpt-3.5-turbo" as the model, ensuring it is within your OpenAI credit limits.

b.????? Body/Message:

????????????????? i.????? Role – 1: "user".

???????????????? ii.????? Content-1: Enter your 'Question', select the 'lightning'?icon, and choose 'Question' from the 'Manually trigger a flow' menu.

c.????? Body/N: "1".

d.???? Temperature: "1".

e.????? Max Tokens: "1000".

f.?????? Frequency Penalty: "0".

g. Presence Penalty: "0".

ChatGPT Data input parameters

6.????? Connection Setup:

a)????? Scroll down and select 'Change connection'.

b)???? Click 'Add new' to establish a new ChatGPT connection.

c)????? Input the Connection name as "Authorization".

d)???? Enter your API Key: "Bearer YOUR CHATGPT KEY" (note the space between 'Bearer' and your key).

e)???? Click on the 'Create new' button.

Create ChatGPT connection authorization

7.????? Save and Test the Flow: Save your configurations and initiate a test run.


8.????? Manual Execution: Manually input your question and activate the flow by clicking the 'Run flow' button.


Run flow testing

9.????? Review the Output: Inspect the results in the Output > Body section.

Review the results of ChatGPT response

10. Final Adjustments: Update the trigger as needed and publish your flow to make it live.


This procedure will guide you through setting up a ChatGPT-powered flow in Power Automate, ensuring you can efficiently generate responses as needed.

?

HTTP Connection to ChatGPT in Power Automate Flow

1.????? Initialize a New Flow: Launch Power Automate, start a new flow, click 'Skip', and rename the newly created empty flow if desired.

Initialize a New Flow

2.????? Set Up a Trigger: For initial testing, I will use a Manual trigger as it simplifies the process. After testing is complete, you may switch to the trigger of your choice.

Set Up a Trigger for your flow

3.????? Configure Text Input: Add a Text Input for your manual trigger and rename it to 'Question'.

Configure Text Input

4.????? Implement HTTP Action: Insert an HTTP action following the 'Manually trigger a flow'.

Add HTTP action

5.????? Configure HTTP Parameters:

a.????? URL: Enter "https://api.openai.com/v1/completions" as outlined on the OpenAI Authentication page.

b.????? Method: Set to "POST".

c.?????? Headers: Configure as follows:

????????????????????????? i.????? Enter key: "Authorization”.

???????????????????????? ii.????? Enter value: "Bearer YOUR CHATGPT KEY" (ensure there is a space between 'Bearer' and your key).

d.????? Body: Adapt the body to fit your model requirements from the provided examples or include additional details regarding penalties and other GPT input parameters. Replace "YOUR QUESTION" with your 'Question' input from the Manual trigger step.

{

??? "model": "gpt-3.5-turbo-instruct",

??? "prompt": "YOUR QUESTION",

???? "max_tokens": 1000,

??? "temperature": 0,

??? "stop": null.

}

{

??? "model": "gpt-3.5-turbo",

??? "messages": [

??????? {

??????????? "role": "user",

??????????? "content": "YOUR QUESTION"

??????? }

??? ],

??? "max_tokens": 1000,

??? "temperature": 0,

??? "stop": null

}

  • ?For gpt-4, the curl request would need to look the same as in the case of gpt-3.5.-turbo, just use “gpt-4” as a model in the request.

6.????? Save and Test the Flow: Save your settings and conduct a test run.

7.????? Manual Execution: Manually input your question and activate the flow by clicking the 'Run flow' button..

Run your flow for testing

8.????? Review the Output: Examine the results in the Output > Body section.

Review ChatGPT response

9.????? Final Adjustments: Update the trigger as needed and publish your flow to finalize it.

?

This setup enables you to efficiently integrate ChatGPT into your Power Automate flows using HTTP actions, ensuring flexibility and customization according to your automation needs.

Koenraad Block

Founder @ Bridge2IT +32 471 26 11 22 | Business Analyst @ Carrefour Finance

4 个月

Thanks for shedding light on the capabilities of ChatGPT! ????

Víctor álvarez

PLANIFICACIóN DE SISTEMAS ELECTRICOS | CONEXIóN Y DESARROLLO DE PROYECTOS | CIENCIA DE DATOS

4 个月

Alona, muchas gracias por compartir la conexión entre ambas herramientas.

Woodley B. Preucil, CFA

Senior Managing Director

5 个月

Alona Soroka Very Informative. Thank you for sharing.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了