Friday, 2 June 2017

Reminders in Microsoft Teams using Flow

Following on from my previous post, I thought I'd do another "solution" to a feature missing from Microsoft Teams that I used in Slack. Reminders.

In Slack, it was possible to set reminders within channels which Slack would remind you (or the channel) about at a given time. These reminders could be as simple as "remind @channel at 1pm to go to the meeting" or as complex as "remind @channel at 9am every weekday to go to standup".

This feature is unfortunately missing from Teams, with no bots available to fill the gap and nothing but a feature request to hold our breath on.

While we wait however, we can use Microsoft Flow to fill the gap.

(NOTE: There is currently a limitation with this guide around handles. Handles are currently not expanded when received by Teams, which means users belonging to that handle will not get notified. This is currently being worked on)

This tutorial will look into setting up a reminder; both simple and complicated. I'll be assuming that you know the basics of creating a flow, so lets get started by logging into Flow and select "Create from blank".

Setting up when our reminder goes off

Our flow will start off by setting up our schedule. This is achieved via the Schedule - Recurrence trigger. From here we setup our Frequency and Interval, which will be used to determine how often you want the reminder to go off. For instance, if you wanted the reminder to go off once a week, then you would set the Frequency to "Day" and Interval to "7" (i.e. every 7 days). In order to determine the day/time in which the reminder will go off, we'll need to look at the advanced options.

From here, we can setup a start date from when the reminder should start. This will also be the point in which our interval will initially be counted from. So if we wanted to have our reminder go off every Friday at 1pm, then our Start Time would be set to "2017-06-02T14:00:00". Note that you should adjust this to a date that falls on a Friday in the future, or the flow will never trigger :) You'll also want to setup a time zone to ensure it triggers based on your local time. For me, this is GMT (or UTC+0). Your trigger should look like the following.

Expanding our reminder

Our recurrence is fine if you want your reminder going off once a week or every day, but what if you wanted something more complicated? Something like our example where we want it every week day. In Flow, this is achieved via conditions.

To achieve this we'll need two conditions to make sure the day of the reminder is between Monday and Friday, which will need to be entered in advanced mode. The first condition should look like the following.

@greater(dayOfWeek(utcnow()), 0)

This condition is passing the current date/time into a function which returns the day of the week in the form of a number. 0 is Sunday, 1 is Monday all the way to Saturday which is 6. We are wanting this number to be greater than zero (Sunday), therefore starting on Monday.

From this condition, we'll then want to setup a second condition if the first condition is true/yes. This should look like

@less(dayofweek(utcnow()), 6)

This condition is similar to our first, but we want to make sure our day is less than 6 (representing Saturday), therefore ending on Friday. From here, all further actions will need to be added to the yes section of our conditions. The flow should look like the following:

Creating our reminder message

Once our Flow trigger goes off (and our conditions, if set up, are met), we'll want to compose our message to send a nicely formatted message to Teams. This can be done by adding an action following on from our trigger called Data Operations - Compose. Within the input field, we can then compose the message we want to send. This can include any supported markdown to create a formatted message (e.g. bold text).
In the example below, we're going to be posting "Stand up" in bold text

Sending To Microsoft Teams

The last part is to send our message to our desired channel within Teams. At the time of writing, Flow includes Teams integration directly, but there are two main problems that I have found when using it
  1. When Flow posts the data to Teams, it is posted on behalf of your account. This just looks odd to other users and I'm not sure if you'll get notifications when Flow posts on your behalf.
  2. The Teams integration doesn't support markdown for some reason. As this is still in preview, this will probably be fixed before final release.
Because of these problems, we're going to send our data to an incoming web hook made in Teams. Therefore, go to Teams and setup an incoming webhook. I like to give it a bit of style and therefore I've called it Flow Reminder with an alarm icon to make it stand out when posting.

Once done, copy the URL provided with the incoming web hook; we'll need this later on. In Flow, add a final action using HTTP - HTTP. The URI field should be set to the URL generated by the Team's incoming web hook. The rest of the action should look like the following:

As you can see, we're using Dynamic Content with our body. Dynamic Content are pieces of data that are generated as our Flow progresses and is based upon our previous triggers and actions and can be used in conjunction with fixed text. These are available in an overlay to the right of the action. They're added simply by tapping the relevant label.

Once complete give the Flow a name and save it. It's now ready to start sending you reminders in Teams. If you can't wait for the time to arrive, you can always run it manually.