Before we begin, please note that the OpenAI GPT-3 API is a paid service, and you will need an API key to use it. You can sign up for the OpenAI API on their website.
Step 1. Create a Power Automate flow
First, we must create a Power Automate flow that will call the OpenAI GPT-3 API and return the response to PowerApps.
- In Power Automate, click “Create” in the top navigation bar and select “Instant – from blank”.
- Give your flow a name and select “PowerApps” as the trigger.
- In the trigger configuration, select “PowerApps button” as the trigger.
- Add the “HTTP” action: In the Power Automate flow, configure a new “HTTP” action to send a POST request to your ChatGPT API endpoint. You must provide the message text from the Teams channel as a parameter in the request body.
- Next, add the PARSE JSON to convert the result to JSON format like below.
- Add the “Apply to each ” – Post a message (V3)” action: Once you receive the response from the ChatGPT API, you can use the “append Variable- Post a message (V3)” action to send the response message back to the PowerApps.
- Save your flow.
Step 2. Create a PowerApps app
Next, we need to create a PowerApps app that will call the Power Automate flow and display the response from the OpenAI API.
- In PowerApps, click “Create” in the left-hand navigation menu and select “Canvas app from blank”.
- Give your app a name and select your preferred layout.
- Add a “Text input” control to your app by searching for it in the left-hand panel and dragging it onto the canvas.
- Add a “Button” control to your app by searching for it in the left-hand panel and dragging it onto the canvas.
- Select the button control and go to the “OnSelect” property in the right-hand panel.
- Enter the following expression to call the Power Automate flow:
Set( result, 'Flow name'.Run(TextInput1.Text).Answer )
SQLCopyReplace'Flow name'
with the name of the Power Automate flow that you created in step - Go to the label where you want to display the result, so go to the item property and add the result.
This formula calls the “ChatGPT” flow and passes the user input as a parameter. It then extracts the response text and displays it in the label.
For more details on using the Microsoft Teams channel as a ChatGPT, please refer to the following link: https://www.c-sharpcorner.com/article/how-to-use-microsoft-teams-channel-as-a-chatgpt/
I am Rajkiran Swain From Odisha , India. Here in the IT industry for more than 10+ years and during these days I have enjoyed working with Microsoft Technologies such as Dot net, SharePoint, PowerApps, Power Automate, Power BI, AI and CHAT GPT etc. Also I am a SharePoint MVP ,Currently working with a reputed organization OMNIA LLP. Before that I was working for Rotary ,Aricent and Tech Mahindra Clients. During these period I worked in various concepts like SharePoint Apps, Workflow, InfoPath, Custom web part development, Search, SharePoint customization like master page and page layouts. Apart from that I have also also work in both SharePoint server object model as well as client object model. if any one contact me [rkiran44@hotmail.com]
Reference:
Swaiin, R. (2023). Create a ChatGPT in PowerApps. Available at: https://www.c-sharpcorner.com/article/create-a-chatgpt-in-powerapps/ [Accessed: 21st August 2023].