Sunday 2 February 2020

Setting up Microsoft Teams Shifts Schedule Reminders

This article will help us to setup reminders for Shifts on Microsoft Teams using Power Automate. This will help to understand how shift reminders are triggered to shift owners a day before the shift schedules, as gentle reminders.

Before getting into implementation, we will see short introduction of Shifts app. Recently Microsoft has retired the Staffhub service, and Shift app is available as replacement and is available as an app on Microsoft Teams.


Microsoft Team's Shifts App


Shifts App, as quoted on Microsoft documentations: The Shifts app in Microsoft Teams keeps Firstline Workers connected and in sync. It's built mobile first for fast and effective time management and communication for teams.

Shifts app lets users on Microsoft Teams to create necessary shift schedules, and assign/share the schedules with teams. Once the schedule is created and shared on Teams, users will be able to view the schedules on their Teams login.
  • Currently, notifications are not working as expected. In my case, after sharing the schedule with a team, the notifications were not triggered to teams users. 
  • The shift schedule is not currently synced up with calendars. 
Hope the above drawbacks would be addressed in the near future by Microsoft product team.

This article helps us to understand a reminder notification requirement, which I came across recently. Let us look at how to trigger reminder notifications to respective schedule owners a day before the shift schedule.

Create a necessary shift schedules and share it with teams on Microsoft Teams interface.
Microsoft Team Shifts App - Sample Shift Schedule
Microsoft Team Shifts App - Sample Shift Schedule



Configuring Flow to send out reminder notifications


Using the Power Automate, let us leverage the Shifts connectors to manipulate and send out notifications periodically for shift owners.
  • The flow has to be triggered everyday once at particular time (say 12 midnight) 
  • The start time and end time needs to be calculated. Start time (current time) and end time (for next 24 hours) will be used in the get shifts action on Power Automate, to get the shifts scheduled for next 24 hours from the flow runtime. 
  • Shifts: List All team shifts is used get all shifts within 24 hours of time from the flow run time. 
Get all team shifts for particular time period (next 24hours)
Get all team shifts for particular time period (next 24hours)

The shifts retrieved from above action, needs to be manipulated using for loop. The user information, shift details, start time and end time are extracted as follows.
Retrieve Shift Schedule Details including user information
Retrieve Shift Schedule Details including user information

  • The user GUID is retrieved from shift action. The guid is passed to azure get user action, for getting schedule owner information: @{items('Apply_to_each')?['userId']}
  • The shift details needs to be extracted from JSON value retrieved from above action. In the parse JSON, the following parameters are passed
    • Content: @{items('Apply_to_each')?['sharedShift']}
    • Schema: To be generated using the sharedShift property JSON value. The following sharedShift sample value is extracted from previous action result JSON, for generating the schema.
sharedShift value used for generating Schema for retrieving shift name, and dates
sharedShift value used for generating Schema for retrieving shift name, and dates

  • Then the mail is sent by composing the details extracted.
Send email action within foreach loop to send out notification reminders
Send email action within foreach loop to send out notification reminders

This will trigger shift reminders to shift owners a day before the shift schedules.


Note:
  • The actions used on Power Automate are still under preview, is subject to change.
  • The reminders are sent out as mail notifications, which could be changed to Teams notifications based on requirements.