close
Microsoft Teams

Teams + Power Automate: Practical Examples to Automate Tasks

217-08-23-2021-TEC-BLOG-Teams-Power-Automate-Practical-Examples-to-Automate-Tasks-1-340×200

Teams + Power Automate = Automation awesomeness! With the new Teams connector (currently in preview), you can automate tasks with Power Automate and trigger events using Teams data. The Teams connector enables you to use in Logic Apps, Power Automate, and Power Apps.

Using flow with Teams

Power Automate can be used in these scenarios with Teams:

  • Trigger flows from Teams messages
  • List, run, describe flow from Power Automate bot
  • Use flows with adaptive cards
  • Create flows from within the Power Automate app in Teams

You can start with a blank flow or choose to create a new flow based on one of the popular Teams templates (Figure 1):

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 1: Power Automate popular Teams templates and Teams triggers and actions.

You can trigger a flow when keywords are mentioned in a chat or channel conversation and use actions to create a team, add a member to a team, and even create a basic team from a flow. Figure 2 shows some of the common triggers and actions available for the Teams connector:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 2: Microsoft Teams triggers and actions in Power Automate.

Teams apps: Power Automate & Approvals app

There are two apps available to add into Teams: the Power Automate app and the Approvals app.

  • Power Automate app: Automates Teams activities or connects to other apps and services using the Power Automate app in Teams. Create, manage, and edit Teams flows or All Flows directly within this app.
  • Approvals app: Send, receive, manage, and share approvals in directly within Teams.
Teams + Power Automate: Practical Examples to Automate Tasks
Figure 3: Power Automate app in Teams.

The Power Automate app in Teams has multiple tabs for different functions. The Home tab displays a list of all your Teams flows, and you can change the drop-down filter to display All flows:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 5: Power Automate app Home tab displaying All flows option in filter drop-down.

The Create tab displays an embedded page with a list of categorized templates (Figure 5). You can choose from to create a new flow from a template, or you can click on the + Create from blank button:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 5: Power Automate app in Teams Create tab page with categorized templates.

Adaptive Cards for Teams

Adaptive Cards are platform-agnostic user interface snippets of used within Power Automate to share blocks of information or to collect data. They are created in JSON format and transformed into the native UI the adaptive card is being rendered in. You can design your own Adaptive Card and use the card in flow actions to post to a Teams chat or channel, or as a Flow bot to a user. If you want to collect data from an Adaptive Card, you can use the action to post an Adaptive Card to Teams and wait for a response:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 6: Adaptive Card actions for the Microsoft Teams connector in Power Automate.

When I’m designing Adaptive Cards, I like to use the free online Adaptive Cards Designer so I can edit and preview the card before committing to its use.

READ MORE: Overview of Adaptive Cards for Microsoft Teams

Teams App Template: Request a Team

A few years ago, Microsoft launched App Templates for Microsoft Teams, a gallery of pre-built templates you can easily deploy for Teams. One of the most common app templates organizations have deployed is an app to allow end users to request the creation of a new team. The Request a Team template provides a way to implement a create team request approval/provisioning process through a wizard-guided request form, embedded approval process, request dashboard, and automated team builds.

The Request a Team app template consists of the following:

  • Power App: Surfaced in Teams with tabs and home screen.
  • SharePoint lists: Three lists used to store the data for the Team Request Settings, Teams Templates, and Teams Requests.
  • Microsoft Teams: A team for admins to approve team requests that get posted as Adaptive Cards from the flow.
  • Power Automate flows: Two flows. One flow triggered from a button in the Power App to check if the team name is available. Second flow is used for the approval process of the request that sends an adaptive card to Teams and saves the response in a SharePoint list.
  • Logic App: The Azure Logic App runs at a scheduled interval to read from the Teams Request SharePoint list and provisions a team for all requests that have been approved and not yet created. It sends an email to the requestor once the team is created.

When the app is deployed in your tenant, you can add the Request-a -team app as a tab in Teams:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 7: Add a tab dialog with the Request-a-team app available to select.

The Power App will default to the Request a team screen which gives the requester a choice to create a team from scratch or create from a template:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 8: Request-a-team Power App embedded in the team as a tab default screen.

The requester continues with the request through the wizard-guide and input all required fields in the app. On the Team information screen, they will provide a Team name and then click on the Check availability button which triggers the Check Team Availability flow that checks to see if the team name is available:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 9: Check availability button that triggers the Check Team Availability flow.

If the requester chooses to create a team from a template, they see a screen with a drop-down of templates to select. The template information is pulled from the data in the Teams Template SharePoint list:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 10: Select a template screen in the Power App that pulls from the Teams Templates SharePoint list.

The last screen of the wizard is the Review and submit screen, where the requestor can preview the information of their request and either go Back and make changes or click Submit to send the request:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 11: Review and submit screen with sample request.

The Submit button saves the data of the request to the Teams Requests SharePoint list.

When a new item is added to the SharePoint list, the Status defaults to Pending Approval and the Team Request Approval flow runs. The flow then posts an Adaptive Card to the target channel in the Request a Team Admins team and waits for the response for approval:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 12: Adaptive Card posted from the Team Request Approval flow in the team for admin approval.

The approver has buttons to Approve or Reject the request. When a button is selected the Add a comment box displays with a Submit button:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 13: Adaptive Card updated to show response submitted.
Teams + Power Automate: Practical Examples to Automate Tasks
Figure 14: Resource group with ProcessTeamsRequest Logic app used for provisioning the teams that have been requested and approved.
Teams + Power Automate: Practical Examples to Automate Tasks
Figure 15: ProcessTeamRequest Logic app with When an item is created or modified trigger to run on a schedule pulling from the Teams Requests SharePoint list.

When the logic app runs, it will read and process requests from the Teams Requests SharePoint list. It has steps to loop through and add owners and members (if requestor added members in the request) as well as check the template type of the request. The provisioning process takes around 5 minutes for each team it processes:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 16: ProcessTeamRequest Logic app steps for looping through members and owners values from the request in the SharePoint list.

Once the team has been provisioned, the logic app sends an email to the requestor letting them know the team has been created as shown:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 17: ProcessTeamRequest Logic app with When an item is created or modified trigger to run on a schedule pulling from the Teams Requests SharePoint list.

The team shows up in Teams for the owners and members with a welcome message posted from an action in the logic app:

Teams + Power Automate: Practical Examples to Automate Tasks
Figure 18: New team created by the logic app with welcome message that was posted from an action in the logic app.

Summary

I hope you enjoy my session at TEC on September 1st, as well as this companion article to help understand the integration with Teams and Power Automate. I encourage you to try out the Request a Team app template as well as many of the other Power Platform app template solutions available to download at https://aka.ms/TeamsAppTemplates. You can use the templates as is or modify any of them to fit your needs. Please note: if you encounter issues with the deployment please raise an issue in the GitHub repo.

Source Practical365

Chioma Ugochukwu

The author Chioma Ugochukwu

Leave a Response