Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate

Adaptive Cards offer a new way for developers to display & exchange content in a common and consistent way across different applicationsIt can be hosted on:
  • Bot Framework Webchat
  • Cortona Skills
  • Outlook Actionable Messages
  • Windows Timeline
  • Microsoft Teams
  • Windows Notifications
SDKs (.NET, JavaScript, Android, React, iOS etc) are available for authoring & rendering cards inside your own apps. Microsoft has got great documentation on this. The schema explorer has got information about all the list of available Card elements, containers & actions sets to use. Adaptive card templating features are now available in preview mode to help create, reuse & share the cards you develop & enable you to separate the data from the layout in an Adaptive card. There is also a plugin available called Adaptive Card Viewer in Visual Studio code for visualizing the card & a team app called App Studio.
 
Develop a card using the Adaptive Card Designer from  scratch or you can start with some available samples. Card Authors describe their content as a simple JSON object with the help of the designer which could then be rendered natively inside a Host Application, automatically adapting to the look and feel of the Host.
 
In this article, I am going to show you how to create an Outlook actionable message using a sample (Input Form) available in Adaptive card designer. This collects information (Name, Email) from the user & stores it in a SharePoint list using two flows. There is also going to be a simple response card to be shown once the information is submitted.
 
For the outlook version requirements for actionable message, click on this link,
  1. Instant flow with the manual trigger for sending the adaptive card in an email
  2. Instant Flow using trigger when a request is received for sending information to SharePoint list
Actionable messages can be via email which I am focusing on in this article or by using connectors. Check here the supported scenarios via an Email.
 
Steps involved to create actionable message via an email:
  • Creating the Adaptive card for the host application (Outlook)
  • Creating the Flows
Let’s start with creating the card using the Adaptive Card designer
 

Adaptive Card Creation

 
There are going to be two adaptive cards:
  • The first one is the initial form to be sent on email using the sample input form
  • The second one is a response card which will be shown after the input form is submitted
First Adaptive Card
 
Go the designer & click on Open Sample, select Input Form as shown below
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Then change the host app from the default Bot Framework Webchat to Outlook Actionable Messages. Remove the phone number Text Block [Element] & the corresponding Text.Input [Inputs] field to keep it simple. Remove the Submit action set, add the action set of type Action.Http for us to call the flow with method POST for us to interact with SharePoint
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Update the following attributes of the just-added element action set:
  1. Rename the title of the element to Submit from Action.Http
  2. Add the Id submit
  3. Change the Style to Positive from Default
  4. Select the Method to POST
  5. Url to be set to our second FLOW (When a Http request is received) HTTP POST url later once we have it ready with us
  6. Add the following to the body:
    1. {  
    2.    "inputName":"{{myName.value}}",  
    3.    "inputEmail":"{{myEmail.value}}"  
    4. }  
  7. Set the HTTP Headers

    1. Click the Add New header, enter “Authorization” to Name and leave the Value blank. If this is not done, you will receive an HTTP 401 unauthorized message while clicking the button on the email. The HTTP request is received flow does not have any authentication - it's anonymous - so be careful with the URL and have some steps to validate on the flow so check if it's triggered from a valid source

    2. Add one more header, enter “Content-type” to Name and Value should be “application/json”. This is required to make the POST request from the email
The first card is ready, let's go ahead and create the second one which is the response card. This will be shown once the response is submitted
 
Second Adaptive Card:
 
This is going to be a very simple card, let's start from the scratch. Go to the designer and select New Card
  1. Add a Container
  2. Add a TextBlock with text “Your Response has been submitted successfully” on the container.
Click Copy Card JSON from ribbon for this card to be used on the flow. We now have the adaptive cards ready with us, let’s go ahead and then create the flows using Power Automate. Find the generated JSON below 
  1. {  
  2.   "type""AdaptiveCard",  
  3.   "version""1.0",  
  4.   "body": [  
  5.     {  
  6.       "type""Container",  
  7.       "items": [  
  8.         {  
  9.           "type""TextBlock",  
  10.           "text""Your response has been submitted successfully",  
  11.           "id""response text"  
  12.         }  
  13.       ]  
  14.     }  
  15.   ],  
  16.   "$schema""http://adaptivecards.io/schemas/adaptive-card.json"  
  17. }  

Instant Flow using trigger When a Request is received

 
This flow is an Instant flow with trigger “When a HTTP request is received”, this is going to be called from email for submitting the input form to a SharePoint list. Create a SharePoint list with two columns for us to store the Name and Email submitted from the adaptive card on email.
 
Create the flow with the trigger as said above. The POST url will be generated after the flow is saved with an action. Click Generate from sample on the trigger and copy and paste the below information which would automatically generate the schema for you. If you have more advanced JSON schema, try using this tool.
  1. {  
  2.  "inputName""",  
  3.  "inputEmail"""  
  4. }   
Click Advanced options to select the method POST. Add the action create item to store the user form response to SharePoint list created above with the request body information mapped to Title (Name - inputName) & Email (inputEmail) using the dynamic content.
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Add the Compose action, paste the JSON of the second adaptive card to the Inputs.
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Add the Response action, a premium one with the header key CARD-UPDATE-IN-BODY and the value as true. The body parameter should be the outputs of the compose action JSON.
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Save the flow, the POST url will now be generated; copy it and go to the first adaptive card and paste it on the url attribute for the Submit action set. After this copy the JSON from ribbon, we are now ready for creating the next flow
 

Instant flow with the manual trigger for sending the Adaptive Card

 
This flow is an instant flow with trigger. Manually trigger a flow for sending the adaptive card an outlook-actionable message in an Email. You can have a different type of trigger based on the requirement. Add the compose & send an email (v2) action, paste the JSON for the first adaptive card to the inputs field of compose action. Make sure JSON also has the POST Url of the first flow on the action set. On the compose action, also include the script tags as given below,
  1. <script type="application/adaptivecard+json">  
  2.    -- JSON of First Adaptive Card—  
  3. </script>   
Find the JSON generated from the designer 
  1. <script type="application/adaptivecard+json">  
  2. {  
  3.     "$schema""http://adaptivecards.io/schemas/adaptive-card.json",  
  4.     "type""AdaptiveCard",  
  5.      "version""1.0",  
  6.     "body": [  
  7.         {  
  8.             "type""ColumnSet",  
  9.             "columns": [  
  10.                 {  
  11.                     "type""Column",  
  12.                     "width": 2,  
  13.                     "items": [  
  14.                         {  
  15.                             "type""TextBlock",  
  16.                             "text""Tell us about yourself",  
  17.                             "weight""Bolder",  
  18.                             "size""Medium"  
  19.                         },  
  20.                         {  
  21.                             "type""TextBlock",  
  22.                             "text""We just need a few more details to get you booked for the trip of a lifetime!",  
  23.                             "isSubtle"true,  
  24.                             "wrap"true  
  25.                         },  
  26.                         {  
  27.                             "type""TextBlock",  
  28.                             "text""Don't worry, we'll never share or sell your information.",  
  29.                             "isSubtle"true,  
  30.                             "wrap"true,  
  31.                             "size""Small"  
  32.                         },  
  33.                         {  
  34.                             "type""TextBlock",  
  35.                             "text""Your name",  
  36.                             "wrap"true  
  37.                         },  
  38.                         {  
  39.                             "type""Input.Text",  
  40.                             "id""myName",  
  41.                             "placeholder""Last, First"  
  42.                         },  
  43.                         {  
  44.                             "type""TextBlock",  
  45.                             "text""Your email",  
  46.                             "wrap"true  
  47.                         },  
  48.                         {  
  49.                             "type""Input.Text",  
  50.                             "id""myEmail",  
  51.                             "placeholder""[email protected]",  
  52.                             "style""Email"  
  53.                         }  
  54.                     ]  
  55.                 },  
  56.                 {  
  57.                     "type""Column",  
  58.                     "width": 1,  
  59.                     "items": [  
  60.                         {  
  61.                             "type""Image",  
  62.                             "url""https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg",  
  63.                             "size""auto"  
  64.                         }  
  65.                     ]  
  66.                 }  
  67.             ]  
  68.         }  
  69.     ],  
  70.     "actions": [  
  71.         {  
  72.             "type""Action.Http",  
  73.             "title""Submit",  
  74.             "url""https://prod-17.centralindia.logic.azure.com:443/workflows/70ff9c6207d94f62a68af8f8011c6f05/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=rX1jf6ZM3_PPR6HQwZccO668Bx6A3Dxuuajq2dHAfKY",  
  75.             "id""submit",  
  76.             "style""positive",  
  77.             "method""POST",  
  78.             "body""{\"inputName\":\"{{myName.value}}\",\"inputEmail\":\"{{myEmail.value}}\"}",  
  79.             "headers": [  
  80.                 {  
  81.                     "name""Authorization",  
  82.                     "value"""  
  83.                 },  
  84.                 {  
  85.                     "name""Content-type",  
  86.                     "value""application/json"  
  87.                 }  
  88.             ]  
  89.         }  
  90.     ]  
  91. }  
  92. </script>  
 Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
On the send an email (V2) action, click the html view and select the outputs of the compose JSON which has the first adaptive card JSON. The flow is ready, click the Test link on the right corner of your flow to trigger it. The email will be received to the sender as below,
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Once the information is Submitted, you would see the response as below,
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
If you would like to test with the tenant or global users, then register your adaptive card actionable message on the Actionable Email Developer Dashboard to enable this service. Enter the Flow URL (HTTP Request response), scope & sender email address. For more information on the developer dashboard refer here. Regarding security of the actionable message, refer here.
 
Actionable Outlook Message Using Adaptive Card Connected To SharePoint Using Power Automate
 
Once your provider is approved, add the Provider Id (originator) field to the originator attribute in your JSON of the adaptive cards next to the type key, as follows,
 
"originator": "ProviderId",
 

Summary

 
You now have an actionable message adaptive card on outlook for collecting information from users through email. It provides you more functionality than the available out of the box actions Approvals or Emails with options. To know the future road map, click here. I hope you have enjoyed reading this post and find it useful. If you have any comments or feedback, please provide it in the comments section below.


Similar Articles