Microsoft Flow – Send an email with options buttons

Sometimes with managing cases in Microsoft Dynamics 365, users want to automate sending an email to a customer and present them with some basic buttons so that the customer can choose whether to close a case without the need to reply directly to the email. In this post, I’m going to show you how we can leverage Microsoft Flow to send the email for us with the button options.
Triggering the Flow
There are a few ways we could trigger this Flow, for the purpose of this post, I’ve created a simple tickbox on the case form and once its ticked, I will trigger the flow to send out the email.
Flow Logic
For the Flow, my trigger is set to cases and I have a condition to check if the field is equal to true (ticked).
My no branch is very simple, I’m terminating the flow with a status of cancelled. I like to set the status of cancelled so I can tell if a Flow has executed any logic. This is my preference to help me troubleshoot issues, but you could set this to succeeded if you prefer.
My Yes branch has all the logic I need to action my email with options. Firstly, I fetch the contact record associated to the case so that I can get the email address. Unlike Microsoft Dynamics 365 workflows where you would map the contact to the ‘to’ field in the email, in Microsoft Flow you need to fetch all the data manually from the system.
I’ve then chosen the Send Email with Options Action under Office 365. This allows me to configure the various options I want to present to the user. I’ve mapped email from the contact and also merged in some personalisation such as the contact first name. I’ve set my options as ‘Yes please close my case’, ‘my case is not resolved’ and ‘Please call me’. Based on the different options you provide, you can then action the responses appropriately.
I’ve then added a couple of parallel actions, the first is a switch statement that I’ll run through further down and in the last action. I’ve set a delay action to wait 4 days, send an email to say that the customer has not responded and terminate the Flow with a status of succeeded. As this is an example, I’ve kept this bit fairly simple. You could make this more complex and update the case status in Dynamics 365 or trigger some additional actions etc.
On the other parallel branch, my switch statement allows me to configure different outputs based on the option selected by the email recipient.
The Selected Option value is an output provided by the Send email with options action.
If the customer selects ‘Yes please close my case’, I’m updating a field on the record that will trigger a Dynamics workflow to close the case. You can’t close cases directly using the Update record action in Microsoft Flow. Another alternative if you didn’t want to do this is to look at potentially calling the Dynamics Web API directly from Flow to do this but that’s a post for another day. For now, we’ll update a hidden field that will trigger the closure via a workflow.
I’ve also terminated the Flow after this action so that the parallel action I mentioned above doesn’t process if the recipient has clicked on a button.
If the recipient selected ‘my case is not resolved’, I’ve just updated the description as an example. You could update the status reason or again update a hidden field to trigger some sort of escalation process if you prefer.
If the ‘Please call me’ option is selected, I’ve created a task regarding the case due straight away for the case owner to contact the recipient. We could also send an email or post a message into a Microsoft Teams channel if that is what is required.
The overall Flow looks like this:
Customer Experience
Lets look at the experience from the customers point of view.
The recipient receives an email in their mailbox and they click the Please call me button.
They then get a confirmation screen that they can close when required.
From a Microsoft Dynamics 365 perspective, as the email is sent from my mailbox I can track it to the appropriate case.
Once clicked, the task is successfully created against the case!
The run history in Flow shows us the path the Flow has taken based on the recipients selection.
The creation of the Flow took me about 10 minutes and its really intuitive. Microsoft Flow opens up a load of possibilities that we’ve never been able to do out of the box with standard Microsoft Dynamics 365 workflows. If you’re interested in learning and like the self-teach route, Microsoft have great content on the Flow website that you can access here. Otherwise, feel free to contact Rocket CRM for some Flow training!