Power Platform and AI – Part 2: Power Automate
In the previous part of this series, we went through the AI features of Canvas Power Apps. This time we will go through the AI features available to the Power Automate cloud flow maker in a similar way. This article covers:
- Creating a formula using an example
- Creating a cloud flow using natural language
- Editing a cloud flow with Copilot
- Leveraging AI in cloud flow actions
Creating a formula using an example
This is still an experimental feature. If you want to try it, you must allow the use of experimental features in the settings.
After this, create a new flow. Flow gets orders from the SharePoint list.
We need the initials of the creator of the order. How could they be formed most easily?
Add compose action where a value is added for each order. The loop (Apply to each) must be done in advance so that the next step works.
Let’s set a value for the format function using an example (Format data by examples).
Select the field from which the initials are formatted (Created By DisplayName).
Let’s give examples of different names and what output we want from each one.
With the Get expression button, we see what the AI suggests as a formula.
And then the thousand dollar question. Do you understand what the formula does and dare to use it in your flow?
concat(slice(items('Apply_to_each')?['Author/DisplayName'], 0, 1), substring(items('Apply_to_each')?['Author/DisplayName'], add(indexOf(items('Apply_to_each')?['Author/DisplayName'], ' '), 1), 1))
It is good for the creator of flow to understand how the created formula works. Otherwise, it may happen that the formula only works with some of the inputs. For the rest, it produces the wrong result.
So the created formula does the following
- Takes the first letter of a string (slice). That is, the first letter of the first name.
- Gets the position of the first space (indexOf) in the string and adds one to it. After that, it extracts (substring) one character from that part. That is, the first letter of the last name
- Finally, the two characters are concatenated
We can use this. With the Apply button, it can be added to the compose action.
Creating a flow using natural language
You can also create an entire flow just by describing what it should do. This sounds great!
Let’s ask the copilot to create a flow for us that checks on Fridays whether new customers have been created during the week without a primary contact. If there is, a reminder is sent to the user who created the customer.
The prompt is as follows.
Check every friday if there has been created new accounts in last 7 days without having primary contact. If there is send email notification to the user who has created the account
Copilot sets up Flow amazingly fast.
Next, the connections to be used are checked. Looking good. Let’s create a flow.
Copilot creates a flow that looks just right. Impressive. Don’t get confused by the interface. Copilot uses a new flow editor.
However, it still can’t do everything. Most of the function parameters are empty. We still have to define
- when does the flow start (on Fridays)
- which customers are fetched from Dataverse (created in the past week)
- on what basis the email is sent (primary contact missing)
- to whom the email is sent (customer creator)
- what the email says
So there is still work for the maker.
We also notice that the values of some functions are completely ridiculous. Maybe it’s better that the copilots don’t fill them all yet.
You can continue working on your flow with Copilot. Let’s select the List rows action and ask the copilot to set it to fetch the rows created in the last 7 days.
for selected list rows action. make it retrieve only accounts created during last 7 days
I admit I was surprised. It just updated the action. And with proper formula.
Let’s continue. Next we ask the copilot to send a reminder message to the right person.
For selected send email action. Send an email to the user who created the row. Email subject is "Your action is needed" and in content there is text politely saying that user has created account but forgot to add primary contact on that.
And yes. It knows how to set the email recipient to the correct one and fill in the title and content fields.
Editing a flow with Copilot
You can open any flow with Copilot.
Then you can just have a good time with your new friend.
Finally, let’s open the flow we just made and clean it up a bit. Finally, we ask the copilot what this flow actually does.
what this flow does?
The answer is amazingly good.
“This flow sends an email to the Creator of an account in Dynamics 365 if the account was created in the last 7 days and does not have a primary contact. The email reminds the Creator to add a primary contact to the account. The flow runs every Friday.”
Leveraging AI in cloud flow actions
And how can different AI features be used inside the flow itself?
The easiest way is to use ready-made functions. There you can find, for example, the basic models of AI Builder.
You can also use OpenAI’s chatGPT with the help of a ready-made (Independent Publisher) connector.
Please remember that queries containing confidential information should not be sent to the OpenAI service.
For that, you can create your own OpenAI service in Azure. You can use it (and most of the other services behind the API) with my favorite action (Http request).
If the copilot for Power Apps explored in part 1 felt a bit lacking, then the copilot in Power Automate is on a completely different level. This is understandable. Making flows is a lot more specific scenario of business logic code generation, compared to creating an application with UI and logic with Canvas Power Apps.
Would I use these features myself? Not for building and editing. I could certainly seek inspiration for more complex patterns, though.
For analysis purposes, explaining the operation of a flow made by someone else (what does this flow do?) is a nice feature.
For a Power Automate beginner, the copilot is definitely a useful buddy. You can quickly create a skeleton of the flow with it. During the process, you can ask the copilot to make further changes to it, iteratively working towards the process automation that meets your needs.
However, it remains the author’s responsibility to ensure that the flow built in this way really does what is required.