We’ve been using Teams in our organisation for 12 months now but it often surprises me when a colleague chooses to email me. A recent example included a group email where discussion began and before we knew it there were 10 or so replies and the ordering of the conversion was out of sync as colleagues replied to one, replied to all, what’s going on? I then thought, what if I could have diverted this thread to Teams Chat at the click of a button?
The simplest way for me, to transfer the conversation from Outlook and trigger a flow, was to use “When an email is flagged” trigger. Therefore I can simply flag an email in Outlook and take the conversation onto Teams.
With the variables provided by the email trigger, I compose the to and from fields in order to get all mail recipients and simply replace the semi colon with a comma, this is needed for the next and final step.
Finally using the “Post your own adaptive card as the Flow bot to a user” step, I am able to send an adaptive card notification in Teams to myself and provide a summary of the email I am transferring, from, subject and body preview and in my case the option to start a 1:1 chat with the sender or a group chat if there are more than one recipients of the email. This is done using the Deep Link feature of Teams.
I have supplied a copy/paste option at the end of my post that will allow you to replicate this in your personal PowerAutomate / Teams environment in a matter of seconds. **NOTE** make sure you update the TO field in the post adaptive card action as it’s currently set to youremail[at]yourdomain[dot]com.
So, what does it look like?
The PowerAutomate
The User Experience
If you want to give this a go yourself, create a new cloud flow with the trigger “when an email is flagged” or the trigger of your choice and then copy and paste the code into the clipboard of Power Automate. **NOTE** make sure you update the TO field in the post adaptive card action as it’s currently set to youremail[at]yourdomain[dot]com.
{"id":"f616b2c7-1645-4360-aff5-1710-a2bfb6a1","brandColor":"#8C3900","connectionReferences":{"shared_office365":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365/connections/shared-office365-2c7a215d-616e-4cc2-9dab-9d05f14c21a5"}},"shared_teams_1":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-c32e6b36-e3dd-4ca6-806d-5969ba7e6dee"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"DamoBird365_Transfer_Email_To_Teams","operationDefinition":{"type":"Scope","actions":{"Get_All_To_and_From_Emails":{"type":"Compose","inputs":"@replace(tolower(concat(triggerOutputs()?['body/toRecipients'], ';', triggerOutputs()?['body/from'])), ';', ',')","runAfter":{}},"Post_your_own_adaptive_card_as_the_Flow_bot_to_a_user":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_teams_1","operationId":"PostUserAdaptiveCard","apiId":"/providers/Microsoft.PowerApps/apis/shared_teams"},"parameters":{"PostAdaptiveCardRequest/recipient/to":"youremail[at]yourdomain[dot]com;","PostAdaptiveCardRequest/messageBody":"{\n \"type\": \"AdaptiveCard\",\n \"body\": [\n {\n \"type\": \"TextBlock\",\n \"size\": \"Medium\",\n \"weight\": \"Bolder\",\n \"text\": \"Transfer Email to Chat\",\n \"wrap\": true\n },\n {\n \"type\": \"ColumnSet\",\n \"columns\": [\n {\n \"type\": \"Column\",\n \"items\": [\n {\n \"type\": \"TextBlock\",\n \"weight\": \"Bolder\",\n \"text\": \"@{triggerOutputs()?['body/from']}\",\n \"wrap\": true\n },\n {\n \"type\": \"TextBlock\",\n \"spacing\": \"None\",\n \"text\": \"@{triggerOutputs()?['body/subject']}\",\n \"isSubtle\": true,\n \"wrap\": true\n }\n ],\n \"width\": \"stretch\"\n }\n ]\n },\n {\n \"type\": \"TextBlock\",\n \"text\": \"@{triggerOutputs()?['body/bodyPreview']}\",\n \"wrap\": true\n }\n ],\n \"actions\": [\n {\n \"type\": \"Action.OpenUrl\",\n \"title\": \"Start Group DM in Teams\",\n \"url\": \"https://teams.microsoft.com/l/chat/0/0?users=@{outputs('Get_All_To_and_From_Emails')}&topicName=@{triggerOutputs()?['body/subject']}&message=Hi, regarding your Email (@{triggerOutputs()?['body/subject']}). \"\n },\n {\n \"type\": \"Action.OpenUrl\",\n \"title\": \"Start 1:1 DM in Teams\",\n \"url\": \"https://teams.microsoft.com/l/chat/0/0?users=@{triggerOutputs()?['body/from']}&topicName=@{triggerOutputs()?['body/subject']}&message=Hi, regarding your Email (@{triggerOutputs()?['body/subject']}). \"\n },\n ],\n \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n \"version\": \"1.2\"\n}","PostAdaptiveCardRequest/messageTitle":"Transfer Email To Teams"},"authentication":"@parameters('$authentication')"},"runAfter":{"Get_All_To_and_From_Emails":["Succeeded"]}}},"runAfter":{},"description":"***Please make sure you update the TO: in the Adaptive Card***"}}
What do you think? Could this work for your adoption? How else might you trigger this Cloud Flow / PowerAutomate?
Hi Damo,
that’s great, thanks for that, I really want to try and get away from email and so does my manager. One thing I noticed is that it doesn’t add cc’ed people to the group chat.
Thanks,
Seán
Hey Seán, thanks for reaching out and glad you are looking to try this. You can include CC’d emails by updating the compose action as follows:
replace(tolower(concat(triggerOutputs()?[‘body/toRecipients’], ‘;’, triggerOutputs()?[‘body/from’], ‘;’, triggerOutputs()?[‘body/ccRecipients’])), ‘;’, ‘,’)
Let me know how you get on.
I know it’s me, but I’m missing the step in how to integrate the this into Outlook. Is it a case of exporting the zip package and then importing into Outlook as a “Quick Action” ?
Hi Gil, this is a Power Automate solution. See here https://flow.microsoft.com. You can build a cloud flow which will monitor your mailbox for an email being flagged, when this happens the flow is triggered and an adaptive card is sent to your Teams application with details of the email and users you want to have a conversation with. If you want a demo, I can maybe do a quick video, just let me know.
Hey thanks Damien,
I created the flow without issues and tested it fine using a manual trigger in Power Automate.
Based on the secret sauce, should flagging an email in Outlook automagically kick off the flow?
A video would be awesome in case I’ve missed some vital step!
Cheers,
Gil
It works! Rookie mistake on my part. I didn’t add the right trigger.
This is truly awesome. Thanks again for sharing!
Awesome Gil! Glad you got it working. I have now done a video of the solution so that might have helped before – sorry for not thinking of that sooner and glad you are up and running.
One more question. Unless I’m mistaken, only works in OWA?
I’m sure I’ve used this in both web and desktop outlook clients? PowerAutomate will trigger on the flag from either clients. What’s your experience?
Works as expected on web version but nothing at all on desktop version.
Hi Gil, take a look here https://youtu.be/W3KU-rq10Ak. I’ve fired up my Outlook Desktop Client and the Cloud Flow works fine for me. I wonder what the difference could be at your end?!