Posting automatically to a Teams channel can help you increase efficiencies big time. E.g. if you want to update your colleagues or friends on a daily basis about certain events or you want to use an event based trigger like when a new deal is closed this can help you do all of it automatically without your intervention.
In this scenario I am using a recent idea in our company to post a "happy week meme" every Monday to create some fun and some excitement at the beginning of the week.
In order to achieve this, the following setup is done:
- Excel with the information about the meme to be shared
- MS Flow to gather the data and to post it in a teams channel
- The colleagues to enjoy the meme
Setting up the Excel for the content to post
The first step is to setup the Excel for the content which should be posted. The Excel has the following columns:
- ID: The id of the column, this is auto-calculated based on the year, month and day of the date column. This is necessary as it is easier to compare later in the flow. The assumption in this scenario is that there is at max 1 post per day.
- Date: The date when the content should be posted
- Message: The message of the post
- Image URL: The URL to the meme to be posted
Setting up the Microsoft Flow to post the content to a teams channel
The next step is to set up the flow. It will have three steps:
- Start the flow based on a trigger
- Check for available content for the day and load it
- Post the content to a teams channel
Start the flow based on a trigger
There are several triggers you can choose to start a flow. In this case the best trigger is a daily run of the flow. To configure a daily trigger, select a Recurrence trigger and set it up to run daily. Select Day in Frequency and then choose the days you want the flow to run.
Check for available content for the day and load it
In this step the flow checks for available content of today and loads it to use it in the post. To achieve this the "Get a row" action for MS Excel works best.
In the "Get a row" action you need to define the following attributes:
- Location: The location where your Excel is saved
- Document Library: The document library where your Excel is saved
- File: The path to the file
- Table: The table to use in the Excel
- Key Column: The key column in the table (here it is the described ID column in the previous section)
- Key Value: The value of the key to lookup. I am using the following formula for the Key Value: `formatDateTime(utcNow(), 'yyyy-M-d'). This has to match with the formula you use in the Excel to calculate the ID.
The result is an object you can use at later stages, if there is no value available for the key, the flow fails which is fine as you do not want to do any action then. Of course you can handle this error, which is not covered in this post.
Post the content to a teams channel
The last step is to post the content to a teams channel. For this you use the "Post message in a chat or channel" action. You have to set the following attributes:
- Post as: By whom is the content posted. I have selected Flow bot here, you can also choose User. This means that your user is posting the content then.
- Post in: Where you want to post your content, here it is a Channel.
- Team: The Teams team you want to post your content in.
- Channel: The channel you want to post your content in.
- Message: The message you want to post. Flip this to "source mode" and edit the HTML as below to post the message as well as the picture.
The result of your MS Flow post to a teams channel
That's it. Pretty straight forward and easy to implement. The result in my case looks like this: