Send Action card from Dynamics 365 CE as Actionable Message via Email

Posted by

Users can stay updated with Action cards in Dynamics 365 CE by enabling the Relationship assistant as part of Sales AI. For those users that are hooked on Email notifications it’s possible to send the Action cards as Actionable Messages via Email with the help of Microsoft Flow. These so-called Adaptive Cards can have similar markup and actions.

Here is an overview of the Flow.

We can trigger the Flow on creation of Action Card records; this entity is not available in the UI of Dynamics 365 CE (Advanced Find, Create Process dialog). The Get Owner record action will get the Email Address of the Owner of the Action card and the related Opportunity. And the Get Action card type record will give us among other the relative URL of the icon image that is used in the Action card: ‘/_static/_controls/ActionHubControl/CloseDateComingSoon_Teal_24.png’

In this case we send an Actionable Message for the Card Type 20 (CardType_CloseDateComingSoon): the Close Date of Opportunity is coming soon. We can recreate this card with the help of the Adaptive Cards designer.


With the Get Opportunity record we get the details of the related Opportunity like Est. Close Date, Name, etc. The Convert time zone action will convert and format the Est. Close Date.

In the body of the Send an email action we paste the JSON from the Adaptive Cards designer and wrap it in HTML tags according to the following instruction. Finally we add the Dynamic content from the previous actions to set the Name, Est. Close Date, Record URL of the Opportunity. Here is the complete code snippet:

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script type="application/adaptivecard+json">{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "size": "Medium",
                    "weight": "Bolder",
                    "text": "Dynamics 365 Action card alert"
                },
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "items": [
                                {
                                    "type": "Image",
                                    "style": "Person",
                                    "url": "https://organization.crm4.dynamics.com@{body('Get_Action_card_type_record')['cardtypeicon']}",
                                    "size": "Small"
                                }
                            ],
                            "width": "auto"
                        },
                        {
                            "type": "Column",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Opportunity Closing Soon",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "spacing": "None",
                                    "text": "@{body('Get_Opportunity_record')['name']}",
                                    "isSubtle": true,
                                    "wrap": true
                                }
                            ],
                            "width": "stretch"
                        }
                    ]
                }
            ]
        },
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Opportunity closes on @{body('Convert_time_zone')}",
                    "wrap": true
                },
                {
                    "type": "FactSet",
                    "facts": [
                        {
                            "title": "Account:",
                            "value": "@{body('Get_Opportunity_record')['_parentaccountid_value']}"
                        },
                        {
                            "title": "Country:",
                            "value": "@{body('Get_Opportunity_record')['pp_country']}"
                        },
                        {
                            "title": "Area:",
                            "value": "@{body('Get_Opportunity_record')['_pp_territoryid_value']}"
                        },
                        {
                            "title": "Est. Revenue:",
                            "value": "€@{body('Get_Opportunity_record')['estimatedvalue_base']}"
                        }
                    ]
                }
            ]
        }
    ],
    "actions": [
        {
            "type": "Action.OpenUrl",
            "title": "OPEN OPPORTUNITY",
            "url": "@{body('Get_Opportunity_record')['pp_recordurl']}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.0"
}
</script>
</head>
<body>
Sent with Microsoft Flow.
</body>
</html>

The Email should be in HTML format to make it work: Is HTML = Yes.

So when a new Action card is created of the type CloseDateComingSoon an Email is sent to the Owner with an Adaptive Card like this:

We can click the action Open Opportunity to open the Opportunity record 😉

Leave a Reply

Your email address will not be published. Required fields are marked *