If you have ever used a Power Automate (formerly Microsoft Flow) Approval action, you probably know the struggle of getting the body of the mail look great. Markdown isn’t only a terrible way of styling the details of your approval, it also doesn’t support all of the elements you may want to use.
So, are we to accept this way of working, or is there another way? In this blog post, I will tell you how you can do this differently.
First of all, let me explain the basics of markdown language.
It is supposed to be an ‘easy-to-read, easy-to-write’ plain text format, but that depends on what you are used to write. Some of us (like me), coming from earlier workflow solutions, are more known with RTF or HTML.
Markdown will let you write basic syntax and after ‘compiling’ it will automatically convert to an (X)HTML format for you. That way, you don’t need to know the HTML coding principles.
In HTML, a header is defined by using <h1>This is my header</h1>. In markdown, the same header is defined by using #This is my header#.
More information about the markdown language syntax can be found here.
Now, is this a true problem for all users using Approvals? Ofcourse it isn’t, but markdown (and especially the approval action itself) does limit you in the way your approval is sent out.
On the other hand, since the approval action uses an actionable message, you can handle the approval request entirely from your mail client which makes it quite powerful.
Note: actionable messages are only supported in Outlook 2016, Outlook 2019 and Outlook Online. If you are using another mail client, you will get a ‘plain’ e-mail message with link buttons to the flow approval portal.
So, are we condemned to using markdown language for all of our approval actions? The answer is simple: no!
You can still define your own HTML formatted message and use links to the corresponding approval item in the approval portal.
The above example is just a simple example. You don’t really need to alter from markdown to HTML if you use such a basic format, but it shows you the basics of having an HTML mail with links that immediately redirects you to the corresponding approval item and even selects the output for you.
Imagine using your company branded mail body instead of this basic example. Wouldn’t that be awesome?!
Using HTML instead of markdown
First of all, you need to know which approval action you should use. There are 3 actions within the Approvals connector:
You need the ‘Create an approval‘, combined with the ‘Wait for an approval‘ action. If you use the ‘Start and wait for an approval‘, your flow will halt at that action until the response is given, which will not allow you to send an e-mail after this action.
Within the Create an approval action, you will configure it as you always do (maybe with a little bit less info in the Details section, because you can provide that information in the HTML mail and some basic information in this section). After you have configured your approval, make sure you disable sending a notification to the approver(s)! Otherwise, the default approval mail will still be sent to the approver(s).
You can do this by setting the Enable notifications option (below Show advanced options) to No.
After configuring the approval action, we can send out our own customized approval mail. But first, we need to build our approve/reject URLs. You can also do this directly into your Send an email action, but I prefer to separate such actions, so I built the URLs inside separate Compose actions.
The URL consists of the following:
- Path to the Approval Portal, which is ‘https://flow.microsoft.com/manage/approvals/received/‘
- The ID of the approval item, which can be pulled from the Dynamic Content attribute ‘Approval ID‘
- The response you want to give (optional), which is ‘Approve‘ or ‘Reject‘
If you put these 3 elements together using the concat() expression (with the Expression builder), you will get the following expressions:
concat( 'https://flow.microsoft.com/manage/approvals/received/', body('Create_an_approval')?['name'], '?response=%27Approve%27' )
concat( 'https://flow.microsoft.com/manage/approvals/received/', body('Create_an_approval')?['name'], '?response=%27Reject%27' )
Now that we have the URLs, we can put together the approval mail. You’re completely free to use whatever you want. You can use the default RTF builder or write your own HTML. You only need to make sure to use the URLs generated above for the Approve and Reject buttons. You can even set the importance and/or choose if you want to send the mail from a shared mailbox. Isn’t that convenient?
After that, you need to add the Wait for an approval action and add the Approval ID attribute from the Dynamic Content to the Approval ID field. With that in place, you can configure your flow further as you always do: configuring a condition that will check the outcome of your Wait for an approval action for a specific outcome (Approve/Reject) and do whatever you want to do next!
If you’re happy with the way markdown works or not looking for another way of styling your approval requests, you can stick with the markdown language within your approval actions. But if you want to go just a little bit further with the possibilities of styling your approval requests, you can consider the method I described above.
Please do keep in mind that if you alter from the default approval notification to a self-generated e-mail, you will loose the ability to directly handle your approval request from out your mail client.