How to Get Reply from GPT in Power Apps

To get a reply from GPT in Power Apps, you can use an API call to GPT (through services like OpenAI's API) or use a pre-configured connector via Power Automate. Power Apps will pass user inputs to the GPT model, which will then process the data and return a text-based response. Below is a detailed explanation of how you can set this up.

Integrating GPT API with Power Apps using Power Automate flow

Here are the steps.

Step 1. Create a new blank canvas app.

Step 2. Add Text input and an icon button on the screen.

Text input

Step 3. From the left side panel, select Power Automate and create a new flow.

Power Automate

Step 4. Clicking Create from blank will create a new flow with the Power apps trigger.

Power apps trigger

Step 5. Add the input value to trigger and add the "Initialize variable" action to get that input value.

Initialize variable

Step 6. Add actions as per the image below.

Create text with GPT using a prompt - select AI Reply from the dropdown of that action, and in the Input Text, add the output of the compose action, which we have added previously.

GPT

We have added one compose action to get the output of GPT reply text and at the end, we have added the "Respond to Power apps" action. We have created one variable to get the response in Power Apps.

In the value of the variable, we have added the output of the compose 2 action.

Step 7. Save the flow and go back to the Power apps. In the OnSelect property of the icon, add the following code.

Set(
    varFlowOutput, 
    PowerappsFlow.Run(
        TextInput4.Text
    )
);

Reset(TextInput4)

OnSelect property

Step 8. Add the text label, and in the Text property, add the following code.

varFlowOutput.vartextoutput

Text property

At last, let's run the app and see how we get the answer.

I have added some text to the text box, and after clicking on the icon, I get the reply from GPT.

GPT Model

Here is the flow run we have triggered from Power Apps.

Flow Run

Input

Conclusion

Integrating GPT into Power Apps allows you to enhance your applications with AI-driven conversational responses. Through Power Automate, you can easily pass user inputs to GPT and retrieve intelligent replies, adding dynamic interactivity to your app. This setup opens the door for various innovative use cases, from chatbots to content generation and more.


Similar Articles