top of page

How to Interact with Power Automate in a Custom GPT

Updated: Nov 15, 2023

First, let's create an instant cloud flow

We'll need to use the When an HTTP request is received trigger

Change the Who can trigger this flow? setting to Anyone and under Show advanced options select GET as the Method



Next, to make a simple test flow, we'll respond with the current time. To do that, add the Current time action from the Date Time operation group.

Then we'll add a Response action under the Request operation group.

and we'll set the Body of the Response action to the Current time dynamic content of the trigger


Now give your flow a name and click save. The flow trigger will be assigned an HTTP GET URL, which is the endpoint ChatGPT will use to interact with the flow. Your flow should look like this:



Since we used GET as our trigger's method, we can simply go to the HTTP GET URL in our browser to see the result of the flow.



Now, we create a new GPT! Navigate to https://chat.openai.com/gpts/editor

GPTs are created through natural language, so all we have to do is explain what we want it to do, for example:


Use the provided API to tell the user what time it is. You can also use code interpreter to convert the time zone from the UTC output.

This is of course a very basic example, but ChatGPT will go with it. The GPT Builder will then recommend a name and icon for the GPT. You can configure these yourself as well.

Now, let's go ahead and save. You can select the Only me option in the Publish to selection for now, you can change this later.

Now, let's switch over to the Configure tab. We want to enable code interpreter since we instructed it to use code to convert time zones.

Next, ChatGPT will want an OpenAPI schema for our action endpoint. To create that, we'll fill out some basic info in a certain structure to create a valid schema.


The HTTP GET URL from your flow has two parts - the server and the path. Here is my HTTP GET URL:


https://prod-102.westus.logic.azure.com:443/workflows/00f7ec528c32433baedf901e19a02c45/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=e9IbGRc4183W4qeGoaomdOS35tczjSZIQehQi2qKNjs 

The server in my example is https://prod-102.westus.logic.azure.com:443 and the path is everything after that.

Look at my example OpenAPI schema below and modify it with your server (the server will change from flow to flow) and your path. You'll also want to change the title, operationId, summary, description, etc.


openapi: 3.0.0
info:
  title: Current Time API
  version: 1.0.0
paths:
  /workflows/00f7ec528c32433baedf901e19a02c45/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=e9IbGRc4183W4qeGoaomdOS35tczjSZIQehQi2qKNjs:
    get:
      operationId: getTime
      summary: Get Current Time
      responses:
        '200':
          description: Successful response
          content:
            text/plain:
              schema:
                type: string
                example: '2023-11-14T14:28:19.3220844Z'
servers:
  - url: https://prod-102.westus.logic.azure.com:443

Next, we'll add our OpenAPI schema. Select Add actions under the Actions section.

Paste your OpenAPI schema in the Schema textbox.

ChatGPT will parse the schema to find the endpoints it can call. Our basic example only has one endpoint, but it can handle several. I'll be writing a more advanced example of a GPT built off of a Power Automate flow in the future. Subscribe to get updates.


If you run into issues at this point, double-check your schema and use a regular ChatGPT thread to troubleshoot your schema. You can even paste the URL of this blog post into ChatGPT and it will help.


Now, let's test the GPT! In the Preview pane to the right of the GPT editor, I will ask it what time it is in Alabama. The GPT will ask for approval before reaching out to APIs

The GPT then communicates with the flow and gets the time. It includes a debug trail in the preview

Finally, the output:

I'll now publish it again, this time I'll view the GPT

I'll test it again outside of the preview, and that's it!

Things to keep in mind:

  • This method does not require authentication, do not make sensitive or private information available to the public even if you limit access to the GPT to only yourself.

  • The server can change flow-to-flow. I have not found a way to include multiple servers in a way that makes the GPT interact with multiple flows. You can add multiple actions in one flow and branch them conditionally. I'll discuss this more in an advanced post in the future.

  • The knowledge cutoff for ChatGPT means it is currently unaware of GPTs, so getting help requires web browsing and you must point it to OpenAI's documentation on GPTs for additional help, though I've found trial and error is the best way to learn.

  • The OpenAPI schema used is technically invalid. Including path parameters in the OpenAPI schema will give you errors in The Swagger Editor, but appears to still work in both the editor and with GPTs.

I hope this post gets your gears moving and lets you extend the functionality of a GPT! You can use this method to read or write data and unleashes an entirely new way to automate business processes!

Let me know what you create in the comments!

1,015 views0 comments

Contact

Thanks for reaching out!

PowerUp!

My goal is to educate people in the advanced topics of the Power Platform in a way that helps users go from citizen developer to solution architect.

Connect

  • LinkedIn

© 2021 PowerUp - Power Platform Tutorials. All Rights Reserved

bottom of page