使用微软Power automate构建单点更新多渠道发布工作流

赠人玫瑰,手留余香。

使用微软Power automate构建单点更新多渠道发布工作流

很多工作具有极大的重复性,巧用RPA工具可以让各种桌面应用联动起来,将提升工作效率。
本文按照自己实际工作经验举例说明了使用power Automate来讲任务(planner),Teams和Excel联动,这样我发布任务后团队可以自动得到通知消息,并且任务记录自动归档到Excel中

本文所述部分功能可能需要Office 365订阅,本文尝试的版本均基于订阅了Office 365 E3许可,详细许可证为:

Viva Learning Seeded
Nucleus
Information Protection and Governance Analytics – Standard
Power Virtual Agents for Office 365
Common Data Service for Teams
Project for Office (Plan E3)
Common Data Service
Microsoft Bookings
Microsoft Kaizala Pro
Microsoft Search
Whiteboard (Plan 2)
Information Protection for Office 365 – Standard
Insights by MyAnalytics
To-Do (Plan 2)
Microsoft Forms (Plan E3)
Microsoft Stream for Office 365 E3
Microsoft StaffHub
Power Automate for Office 365
Power Apps for Office 365
Microsoft Teams
Microsoft Planner
Sway
Yammer Enterprise
Azure Rights Management
Office 最新的桌面版本
Office for the Web
SharePoint (Plan 2)
Exchange Online (Plan 2)

Power BI (free)
Exchange Foundation
Power BI (free)

Microsoft Power Automate Free
Exchange Foundation
Common Data Service
Flow Free

Enterprise Mobility + Security E3
Exchange Foundation
Microsoft Defender for Cloud Apps Discovery
Azure Information Protection Premium P1
Microsoft Intune
Azure Rights Management
Azure Active Directory Premium P1
Microsoft Azure Multi-Factor Authentication

许可查询方法

Power Automate介绍

Power Automate是微软的RPA应用,优势在于微软自有的应用的集成,包括日常办公离不来的各种office 365组件

因为自带很多模板,所以可以上手很快,可以尝试从模板入手,之后会发现手动建立也很简单。
链接

MS Teams(work)

Teams集成了微软之前的skype和开放给其他微软云应用的接口,包括onedrive,sharepoint,planner,lists,wiki,Viva,onenote,stream,whiteboard,Forms, Power BI, Azure等等,所以从teams中可以方便的开始聊天,视屏会议,协作等等
链接

MS Sharepoint

全新基于云的Sharepoint使用体验要好很多,因为它和teams集成在一起,所以teams中的内容会自动同步到站点,极大的方便了内容的管理。但是本身的定位让它在目前办公系统中的作用不是很清晰。
链接

MS Forms

这个Forms相当于微软的问卷调查工具,可以用来做问卷调查表,收集结果到Excel中。
链接

MS planner

这个工具可以发布计划任务,可以内嵌在Teams中作为一个tab,同时有单独app可以用,方便想到什么就记下并分配任务。
链接

MS Lists

这个lists有些类似Monday.com,可以当成是一个方便协作的Excel,通过列表方式作为跟踪器来跟踪事项的进展。可以作为一个简单的CRM系统使用,内嵌规则引擎,可以实现一些自动功能。
链接

MS Excel

这就不介绍了
链接

使用示范 – 初阶

1.在planner种新建task,自动把task发布到指定的teams通道

适合于通知到没有被task指派到的人
这个可以直接找到相应模板来使用,搜索planner就可以找到
file
从模板创建过程中需要填写你需要指定的PlanID和teams发布目的地,如图所示的带*部分。
file
注意:有可能需要teams的channel中添加power automate才能让流有权限去发布消息

如果手动建立,也很简单,总体逻辑是确定使用什么来触发以及触发的结果。

  1. 确定触发条件If,监测某个特定的planner,触发条件是新建了一个task
    点击这个步骤旁边的…图标并选择扫视代码可以看到一下代码。(此步骤不是必须,仅仅是为了理解power automate背后实现的逻辑)

    {
    "inputs": {
    "host": {
    "connection": {
    "name": "@parameters('`$connections')['shared_planner']['connectionId']"
                }
            },
            "method": "get",
            "path": "/v1.0/planner/onnewtask_trigger/plans/@{encodeURIComponent('Yh-2JtLMwECdXHsnlmSzP2UAB8iX')}/tasks",
            "authentication": "@parameters('$`authentication')"
    },
    "recurrence": {
    "interval": 5,
    "frequency": "Minute"
    },
    "metadata": {
    "flowSystemMetadata": {
    "swaggerOperationId": "OnNewTask\_V2"
    }
    },
    "splitOn": "@triggerBody()?\['value']"
    }

相关接口可以参考这个说明链接

参考Get Task的返回值说明

这里为了方便看所以列出了返回值:GetTask_Response_V3

Name Path Type Description
Display Name createdBy.user.displayName string The display name of the user who created this task.
Id createdBy.user.id string The id of the user who created this task.
Plan Id planId string The id of the plan this task belongs to.
Bucket Id bucketId string The id of the bucket this task belongs to.
Title title string The title of the task.
Percent Complete percentComplete integer The completion percentage of the task.
Start Date Time startDateTime date-time The start datetime of the task.
Created Date Time createdDateTime date-time The datetime the task was created.
Due Date Time dueDateTime date-time The datetime the task is due.
Has Description hasDescription boolean Set to true if the task has a description.
Completed Date Time completedDateTime date-time The datetime the task was completed.
Reference Count referenceCount integer The number of external references that exist on the task.
Id id string The id of the task.
appliedCategories appliedCategories AppliedCategories The categories to which the task has been applied.
Priority priority integer Priority of the task. Valid range of values is between 0 and 10 (inclusive), with increasing value being lower priority (0 has the highest priority and 10 has the lowest priority). Currently, Planner interprets values 0 and 1 as "urgent", 2 and 3 and 4 as "important", 5, 6, and 7 as "medium", and 8, 9, and 10 as "low". Currently, Planner sets the value 1 for "urgent", 3 for "important", 5 for "medium", and 9 for "low".
assignments _assignments array of object
Assigned To User Id _assignments.userId string The id of the user to whom this task was assigned to.
Assigned By User Id _assignments.value.assignedBy.user.id string The id of the user who assigned this task.
Assigned Date Time _assignments.value.assignedDateTime date-time The datetime the task was assigned.
Order Hint _assignments.value.orderHint string Order Hint
  1. 确定触发的结果Then, 这里就是发布Planner中新task的相关信息到某个teams的channel中
    点击这个步骤旁边的…图标并选择扫视代码可以看到一下代码。(此步骤不是必须,仅仅是为了理解power automate背后实现的逻辑)
{
    "inputs": {
    "host": {
    "connection": {
    "name": "@parameters('`$connections')['shared_teams']['connectionId']"
                }
            },
            "method": "post",
            "body": {
                "recipient": {
                    "groupId": "64504887-246f-4426-ac85-e66b4a73bc22",
                    "channelId": "19:3d0e1cc4b04348168a21847137082aff@thread.tacv2"
                },
                "messageBody": "New task Name: @{triggerBody()?['title']}\nDue Date: @{triggerBody()?['dueDateTime']}\nCreated By: @{triggerBody()?['createdBy']?['user']?['displayName']}"
            },
            "path": "/beta/teams/conversation/message/poster/Flow bot/location/@{encodeURIComponent('Channel')}",
            "authentication": "@parameters('$`authentication')"
    },
    "metadata": {
    "flowSystemMetadata": {
    "swaggerOperationId": "PostMessageToConversation"
    },
    "operationMetadataId": "6030a4d5-b217-49f1-9654-3ca15cf194d3"
    }
    }
  1. 保存,这就完成了这个自动触发流的配置。
  2. 测试,可以尝试在planner中发布一个新任务之后看设定的teams通道中是否有消息,注意:触发器是轮询机制,所以建好了任务之后可能需要等待一个轮询周期才能从teams的通道中看到消息。测试结果界面也比较友好,可以点击其中的步骤来看每个步骤的测试结果。

    2.在Planner中完成某个task,自动发布消息到指定的teams通道

    适合于通知到没有被task指派到的人
    这个可以直接找到相应模板来使用,搜索planner就可以找到,创建过程和第一个示例类似,不在赘述。
    file
    手动创建的逻辑以及扫视代码截图如下

  3. 确定触发条件,监测某个特定的planner,看是否有task完成,参考说明
{
    "inputs": {
    "host": {
    "connectionName": "shared\_planner",
    "operationId": "OnCompleteTask\_V3",
    "apiId": "/providers/Microsoft.PowerApps/apis/shared\_planner"
    },
    "parameters": {
    "groupId": "64504887-246f-4426-ac85-e66b4a73bc22",
    "id": "Yh-2JtLMwECdXHsnlmSzP2UAB8iX"
    },
    "authentication": "@parameters('\$authentication')"
    },
    "recurrence": {
    "interval": 5,
    "frequency": "Minute"
    },
    "splitOn": "@triggerOutputs()?\['body/value']"
    }
  1. 确定结果,发布Planner中完成task的相关信息到某个teams的channel中
{
    "inputs": {
    "host": {
    "connectionName": "shared\_teams",
    "operationId": "PostMessageToConversation",
    "apiId": "/providers/Microsoft.PowerApps/apis/shared\_teams"
    },
    "parameters": {
    "poster": "Flow bot",
    "location": "Channel",
    "body/recipient/groupId": "64504887-246f-4426-ac85-e66b4a73bc22",
    "body/recipient/channelId": "19:3d0e1cc4b04348168a21847137082aff\@thread.tacv2",
    "body/messageBody": "<p>Planner task titled '@{triggerOutputs()?\['body/title']} ' is completed.</p>"
    },
    "authentication": "@parameters('\$authentication')"
    },
    "metadata": {
    "operationMetadataId": "d91183d7-4d5a-476a-878a-cfe6e5e9d3ce"
    }
    }

使用示范 – 中阶

3. 在planner中新建task,自动把task发布到指定的teams通道,并自动将task增加到指定的Excel中

适合于通知到没有被task指派到的人,且使用表格对task时进行汇总,方便后续查询和统计

这个可以参考示范5

4. 在planner种新建task,自动把task发布到指定的teams通道,并自动将task增加到lists(Sharepoint或者Teams)中

适合于通知到没有被task指派到的人,且使用表格对task时进行汇总,方便后续查询和统计

和上述类似,不再单独示范

5. 在planner种新建task,自动把task发布到多个指定的teams通道,并自动将task增加到指定的Excel中

适合于将task通知发布到多个相关teams通道,且使用表格对task时进行汇总,方便后续查询和统计

这个可以通过手动添加步骤的方式实现,先添加触发条件,点击+新步骤添加执行插入行到excel中,再点击+新步骤添加发消息到teams的动作。

需要注意的是:需要在做流之前做好Excel表格,在Excel中建立对应task的各个字段(参考初级示范中的返回值定义),然后提前使用Ctrl+T将表格变成超级表格。

这样后续步骤中会展现如图:
file

可以在两个步骤中间点击带圆圈的+来插入新步骤,插入的新步骤可以是新操作或者是新并行分支

截图如下:file

详细示例请在Power Automate – >我的流, 找到名称为“ 在planner中新建task时自动把task发布到多个teams通道并将task增加到指定的Excel中”

注意:需要注意发布目的Teams的Channel的权限,如果没有权限会导致发布失败

使用示范 – 高阶

6. 在Planner中完成某个task,自动发布消息到多个指定的teams通道,并自动更新Excel中对应TaskID的Task的状态

适合于将task通知发布到多个相关teams通道,且使用表格对task时进行汇总,方便后续查询和统计。难点在于Excel对应TaskID条目的更新

使用planner的当任务完成时作为触发条件时会返回相关任务ID信息,从中得到完成任务的taskID,更新Excel对应ID相关行

同样采用手动创建,首先创建触发器即Planner中的任务完成,接着点击+新步骤添加Excel更新行动作,如下图所示
file

需要注意的是planner任务完成时触发器的返回是一个数组,更新Excel中的条目中的动态内容是值而不是数组,所以如果选择非值的动态内容会自动创建新步骤。

总体步骤如下图所示:
file

7. 在Planner中完成某个task,自动发布消息到1个或多个指定的teams通道,并自动更新lists(Sharepoint或者Teams)中对应的Task的状态

适合于将task通知发布到多个相关teams通道,且使用表格对task时进行汇总,方便后续查询和统计。难点在于lists对应TaskID条目的更新

和6类似,只是第2个步骤的动作选择更新项目update item,参考说明

需要注意的是需要提前建好list,对应task各项建好list的各列的标题。
file

8. 当Form收到新回复时,新建Planner的task

用Form表单发布信息,适用于产品功能更新信息的发布和记录

简单不需要讲,直接见图。
file

9. 每周日中午12点检查planner项目,比对Excel并将不一致部分更新到Excel中,并在Teams中反馈同步结果

定时任务,难点在于Excel对应TaskID条目的更新,以及对Excel中有无这个ID的判断逻辑,如果有同样ID执行EXcel相应ID那行的更新,如果没有ID则执行Excel中新增一行。

是针对每一个Planner中的taskID都需要遍历Excel一遍吗?

另外一个逻辑就是对task结果不判断直接加入excel,但是会导致excel中数据额重复,并且要考虑排重的逻辑,在排重的时候保留已经更新的那些行

这个还没有搞定,当作业。

写在最后,RPA虽然好,但是也可能很快微软的AI将能够取代这些需要手动设置的自动流,比如目前office 365中的Viva,相当智能,可以综合微软账户的各种应用给出你会觉得恰当和受用的建议


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *