Teams Real Simple with Pictures: Using Power Automate and Keywords to ad-hoc pull feeds and videos into channels

This blog is part of a series on Teams. For more articles, check back often

Written: 30/04/2022 | Updated: N/A

So a few weeks back I did a piece on the Teams Keyword trigger in Power Automate and how it can be used to build a command list for repetitive communications which could be used to cut down on workload. I’ve started using this myself. But also, I have started using keywords to pull info I need within the flow of my work. This includes RSS Feeds and Videos off YouTube. There are, of course, other ways you can get these things. One example for RSS Feeds is connectors. However, I don’t want to necessarily have an RSS Feed repeatedly pull into a channel. I only want it when I need it as in ad-hoc, on demand. Whether we want the latest updates to the Microsoft 365 Roadmap, or the latest video on a YouTube channel, keywords pull that information and we can get it as we need

Let’s go.

This blog will cover

  • Spinning up a private channel
  • Flow to pull RSS Feed
  • Flow to pull latest videos from a YouTube channel
  • Conclusion

Prerequisites

  • Teams and Power Automate Licence (Within Microsoft 365 Licence)
  • Teams Owner Permissions (if creating the channel)

SPINNING UP A PRIVATE CHANNEL

As per the last blog, I decided to use a private channel because the Power Automate trigger is explicitly when a keyword is mentioned so I want a place where I can use them to launch flows which isn’t going to be used by others. I am going to be using these keywords in a different context – to get information I need as opposed to communicating with other – but the private channel being particular to me will serve the same purpose

1.) I have deployed a fresh team called Keyword Test. On that team I select More Options (…) and then select Add Channel

2.) I add a title of Commands and then set privacy to Private and select create

3.) I select Skip. I won’t be adding members to this private channel

4.) My private channel is created. Good.

FLOW TO PULL AN RSS FEED

In this flow I am going to use a keyword – MSRoadmap to pull the latest items in the Microsoft 365 Roadmap into the command channel

1.) Login to Power Automate and select Create from the left navigation

2.) Select Automated Cloud Flow

3.) Add a Title for the flow. In this example I will use M365 Roadmap Pull. Select the trigger When Keywords are Mentioned (Teams) and then select Create

4.) Add the message type as Channel. Add the keywords which is here defined as MSRoadmap. Add the Team and Channel and then select New Step

5.) Search for and select List all RSS Feed Items

6.) Grab the RSS Feed URL (Here https://www.microsoft.com/en-gb/microsoft-365/RoadmapFeatureRSS/) and leave the rest as is. The Feed URL can be taken from the Microsoft 365 Roadmap website just like any other site which has an RSS feed. Select Next Step

7.) Search for and select Filter Array

8.) Here we are going to set what we want to pull using Dynamic Content and an expression. Use the RSS Dynamic Content Body in the From field. Then add the RSS DC Feed Published together with greater than in the first two fields under Body. To finish off, use the expression add days and set this specifically as addDays(utcnow(), -7). What this all means is that the item pulled from the RSS Feed will be filtered to show those published in the RSS Feed within the last seven days and exempt everything else. In other words, we are getting the M365 Roadmap items added for the last 7 days.

Once done, select New Step

9.) Up until this point, we have defined the keyword and we have filtered what will be returned from the RSS feed. We now need to collect the filtered items and get them back into the channel. Search for and select the control condition

10.) In the condition, add the expression length and set this to be length(body(‘Filter_array’)). Set it to be greater than 0. Length (Collection) is used to return elements in an array.

11.) In the no box search for and add a terminate control. Set the terminate control to succeeded. This means that nothing will be returned should no M365 Roadmap items have been added to the roadmap, and hence the RSS Feed, in the last 7 days. If you want to explicitly have a notification there are no roadmap items, you can add a Post Message into a Chat or Channel Message so something is returned.

12.) The final stage is to configure what happens if there are items in the RSS Feed to be returned. In the If Yes box select Add an Action and select the control Apply to Each

13.) In the Select an output from previous steps field add the expression take(body(‘Filter_array’),15) and then rename the action to Compose the links for each blog post

Select Add an Action within the Compose the links for each blog post action

14.) Search for and select Compose

15.) In the input, use HTML and Items expressions, such as shown below, to determine how the items will look when posted to teams

Select Add an action outside the Compose the links for each blog post action

<tr><td><h3><a href="@{items('Compose_the_links_for_each_blog_post')?['primaryLink']}">@{items('Compose_the_links_for_each_blog_post')['title']}</a></h3></td></tr><tr><td style="color: #777777;"></td></tr><tr><td>@{items('Compose_the_links_for_each_blog_post')?['summary']}</td></tr>

16.) Finally, search for and add the action Post a Message in a Chat or Channel. Add the details of the channel in the action. In the Message field use the expression

join(outputs(‘Compose’),”)

Then save the flow

17.) Now time to test. Select Test at the top right

18.) Select Manually and then Test

19.) Add the keyword in the channel

20.) A list of roadmap items is returned

Our job here is done. A list of the latest items which have been added to the Microsoft 365 roadmap returned on command from entering a keyword in the channel.

FLOW TO PULL THE LATEST VIDEOS FROM A YOUTUBE CHANNEL

Ok, we proved we could pull an RSS Feed. Now I am going to try it with video. I am going to do it to the Teams Nation Channel on YouTube

1.) First, how do we get the video from the YouTube channel? We get it from an RSS Feed. You can get the RSS Feed for a YouTube channel by using

https://www.youtube.com/feeds/videos.xml?channel_id=

For Teams Nation, this is

2.) Now, I create the steps of the flow based upon the ones I did above for RSS Feeds. I create the keyword – here I’ll use TeamsNationVids and the RSS Feed URL to the action

3.) I add the filter array and condition

4.) Add the termination under no, and the optional teams action

5.) Copy the same as before, but change the apply to each title to Compose the links for each video and use the following input

<tr><td><h3><a href="@{items('Compose_the_links_for_each_video')?['primaryLink']}">@{items('Compose_the_links_for_each_video')?['title']}</a></h3></td></tr><tr><td style="color: #777777;"></td></tr><tr><td>@{items('Compose_the_links_for_each_video')?['summary']}</td></tr>

6.) Now use the keyword

7.) The videos are returned in the chat

The link goes to YouTube

8.) By simply amending the parameters, like the number of days in the filter array, can return more results. For example, this changes the filter array to look for videos uploaded in the last 30 days. The take expression determines how many will be shown

CONCLUSION

Our job here is done.

How useful will this be? When we are in the flow of our work we can use keywords to get the resources we need, or keep up to date with the latest. Connectors will deliver information from RSS feeds, or scheduled flows could also do this, but this is on a schedule at a particular time. Sometimes, we want that information ad-hoc, in the moment, when it is valuable. Simply putting a command into a channel in Teams and Power Automate will do all the work to get what we need without cluttering up our channels. I think this could be very useful should we do this for several sites we need to use.