Lets assume you are a fanatic Microsoft Teams user and Teams is your number one interface for your daily tasks. However your organization is still partly using a classic SharePoint Online approach for Intranet and “official” organizational news are still created as a classic blog posts which was a really common approach before modern SharePoint Online and modern news model few years ago. As a Teams user you don’t want to order email based notifications / alerts about news or use some other ways to access them.
This is a quite simple way to get notified about new news items directly to your MS Teams interface by using MS Flow, MS Flow Bot, Adaptive Cards and SharePoint connector.
The Flow requires actually only four steps:
We will use ‘when an item is created’ event as trigger in case of blog site template based news. What you have to know in this example is the blog site address (News site) and the blog list name which is always ‘posts’ in this scenario.
Then we are reading users’ own profile to get user email for Teams Flow bot. Just select ‘Get my profile (V2)’ action and there are no additional properties for this action.
News converting action ‘Html to text’ is required when reading rich text content from SharePoint blog post body since adaptive cards can’t be used with html content directly. Also this step is really simple:
Finally we are forming and posting adaptive card to Teams through Flow Bot.
Adaptive Cards is a fairly new concept which can be used in many different occasions and platforms. In this case we are using it with Microsoft Teams and you can access adaptive card designer in Url https://adaptivecards.io/designer . This makes planning of your adaptive card fairly easy. Just make sure you have select ‘Microsoft Teams’ as a host app (Yes, dark mode is also included) and after you are ready with formatting, adding actions and other components you want just use ‘Copy card JSON’ button to get your ready made JSON to clipboard.
Now you can paste your adaptive card JSON to Teams Flow Bot action message field which is used to create actual adaptive card. This action is still preview but works quite nicely. As recipient use email retrieved from ‘Get my profile (V2)’ action. Please notice there is also action available to post adaptive card directly to Teams channel with Flow Bot if you need more general approach. To form adaptive card content you can and you should now use dynamic content from SharePoint trigger. Also be careful when modifying JSON – The editor itself is still not so intuitive to use…
The only trickier part is to form news abstract since probably you don’t want to view whole news content in adaptive card. In this case I’m using Flow expression to get first 300 character from news body and after that I’m adding ‘…’ through concat function. Also notice I’m using blog post body ‘Html to Text’ conversion result instead of actual html so full expression here is concat(substring(body(‘Html_to_text’),0,300), ‘…’). This step is only needed when we are using rich text or html formats within adaptive cards.
As a result whenever a new organizational news is published as a blog item in classic SharePoint Online I can get a direct message from Flow bot to my MS Teams client. Also I added action button to open actual news item if needed.
Through this approach you can actually get notification to Teams client from any of the SharePoint list based actions if needed to support your own or your teams work. With little bit different SharePoint trigger you can get the same result out either from classic publishing pages (in case your organizational news are based for them) or even from modern SharePoint news if your organization is already using them.
Let’s hope this post will give you ideas how to use flow and adaptive cards in real world scenarios. Now take advantage of your licenses and start using Flow 😉