Using ChatGPT in Power Automate

Integrating AI into your workflows can dramatically improve efficiency, reduce manual effort, and enhance user experience. One of the most powerful combinations available today is ChatGPT with Microsoft Power Automate.

In this guide, we’ll walk through how to set up ChatGPT in Power Automate, what you can do with it, and best practices for getting the most out of this integration.

Why Use Chat GPT in Power Automate?

ChatGPT is a natural language AI model developed by OpenAI. When used in Power Automate, it can:

  • Interpret and respond to user input
  • Summarise documents or data
  • Generate dynamic content (emails, reports, messages)
  • Enhance decision-making with contextual understanding

This makes it ideal for automating tasks that require human-like language processing.

How to Set Up Chat GPT in Power Automate

Here’s a simple walkthrough to get started, in this example we are going to use Azure Open AI.
You will need to have already signed up for Open AI subscription and have a deployment already created
1. Getting API Details
  • Go to Azure OpenAI
  • Retrieve the API key and endpoint
2. Create a Flow in Power Automate
  • Choose a trigger (e.g. form submission, new item in SharePoint, manual button)
  • Add an HTTP action to call the OpenAI API
3. Configure the HTTP Request Use the following settings: Headers:
				
					{
  "Content-Type": "application/json",
  "api-key": "YOUR API KEY"
}
				
			

Body:

				
					{
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Write a short summary about Power Automate." }
  ],
  "max_tokens": 500,
  "temperature": 0.7
}
				
			

This will look something like below:

For the body, this is where we can define what we want to prompt to do. We can set just a system message or we can give Chat GTP a role as we have above.

    • Max Tokens – Amount of tokens the prompt will use (Action will fail if there is not enough tokens to complete the request)
    • Temperature – the accuracy of the agent (0.0 – 1.0) 0.0 – 0.3 is focused and predictable, 0.8-1.0 more create and random

This will the return a message like the below:

				
					{
  "choices": [
    {
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "protected_material_code": {
          "filtered": false,
          "detected": false
        },
        "protected_material_text": {
          "filtered": false,
          "detected": false
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "annotations": [],
        "content": "Power Automate is a cloud-based service from Microsoft that allows users to create automated workflows between various apps and services. It helps streamline repetitive tasks, improve productivity, and integrate different systems without requiring extensive coding knowledge. Users can automate processes such as data synchronization, notifications, approvals, and more, making it a valuable tool for both individuals and businesses to enhance efficiency.",
        "refusal": null,
        "role": "assistant"
      }
    }
  ],
  "created": 1760189922,
  "id": "chatcmpl",
  "model": "gpt-4",
  "object": "chat.completion",
  "prompt_filter_results": [
    {
      "prompt_index": 0,
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "jailbreak": {
          "filtered": false,
          "detected": false
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      }
    }
  ],
  "system_fingerprint": "fp",
  "usage": {
    "completion_tokens": 73,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens": 26,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "total_tokens": 99
  }
}
				
			

Now that we have the message we just need to return the response message.

To do this we could use Parse JSON, to extract the array, however a better way to do this is get the direct output.

As the choices in an array we can use [0] to get the first choice then the content from inside the message using the below:

				
					body('HTTP')?['choices']?[0]?['message']?['content']

				
			

This will then return the output as below:

Like this post? Why not share it!

LinkedIn
WhatsApp
Facebook
Reddit
X
Email

View more blog posts

Patch SharePoint List in Canvas Apps

4 min read

Read this blog

Setting Dataverse LookUp Value to Null Using Power Automate

1 min read

Read this blog

Rest API ‘GET’ Requests in Power Automate

2 min read

Read this blog

Trigger Child Flows

2 min read

Read this blog

Get In Touch

Let’s talk. Send us a message, and we’ll help you explore the best Power Platform solution for your business

We can turn your mondain tasks into effective workflows, saving you and your business time and money