{"id":110965,"date":"2018-09-12T07:06:44","date_gmt":"2018-09-12T14:06:44","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/sending-pull-request-review-reminders-using-ms-flows\/"},"modified":"2018-09-12T07:06:44","modified_gmt":"2018-09-12T14:06:44","slug":"sending-pull-request-review-reminders-using-ms-flows","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/sending-pull-request-review-reminders-using-ms-flows\/","title":{"rendered":"Advanced | Flow of the Week: Sending Pull Request review reminders using MS Flows"},"content":{"rendered":"
Hello Flow Fans!<\/p>\n
With the increasing number of code repositories it was getting difficult to keep track of Pull Requests (PRs) that need to be reviewed. As an effort to improve dev productivity and reduce PR wait times we created a simple flow using the Visual Studio Team Services (VSTS) connector to consolidate all PR links and send reminders to reviewers. Now, having a single email in their inbox every week with PRs to be reviewed saves everyone the hassle of navigating to each repository.<\/p>\n
The Flow in this article, sends emails to a filtered list of users to not spam members from other teams.<\/strong> This can be enhanced to send emails to users in an alias (not in scope of this article).<\/p>\n <\/p>\n \u00a0<\/p>\n A recurrence trigger can be used as the aim is to send an email at regular intervals. \/you can set yours up like mine, or choose a schedule of your own.<\/p>\n <\/p>\n \u00a0<\/p>\n The VSTS connector supports multiple actions; the one we used is called ‘Send an HTTP request to VSTS’. VSTS exposes hundreds of REST APIs https:\/\/docs.microsoft.com\/en-us\/rest\/api\/vsts\/?view=vsts-rest-4.1<\/a> at our disposal. We will leverage the Pull Requests APIs here.<\/p>\n <\/p>\n We use HTTP GET method to retrieve all active PRs where a particular reviewer was added. Account name is the Azure DevOps organization name (e.g. for jorg.visualstudio.com account name is jorg). Here, the query gets all the active pull requests where a particular reviewer has been added.<\/p>\n <\/p>\n \u00a0<\/p>\n The output is then parsed using the ‘Parse JSON’ connector. You can use a sample payload to generate schema as the response json structure could be complicated.<\/p>\n <\/p>\n \u00a0<\/p>\n After which we iterate over all the PRs and reviewers to prepare a dictionary of Users and PRs.<\/p>\n <\/p>\n \u00a0<\/p>\n At this step, the reviewer list for each PR it iterated through and we prepare a Reviewer-PR map. E.g.<\/p>\n {First choose your Trigger<\/strong><\/h3>\n
Now add an action to get Pull Requests from VSTS<\/strong><\/h3>\n
Next we will add an action to Parse the JSON<\/strong><\/h3>\n
Iterate over PRs<\/strong><\/h3>\n
Iterate over reviewers for each PR<\/strong><\/h3>\n
\n“reviewer1_alias”: [
\n“<tr>\\n<td>PR Title 1 <\/td>\\n<td>requester1<\/td>\\n<td > Pending review<\/td>\\n <td> https:\/\/url1\\n<\/td>\\n<\/tr><\/a> ”
\n],
\n“reviewer2_alias”: [
\n“<tr>\\n<td>PR Title 2 <\/td>\\n<td>requester2<\/td>\\n<td > Waiting for author<\/td>\\n <td> https:\/\/url2\\n<\/td>\\n<\/tr><\/a> “,
\n“<tr>\\n<td>PR Title 3 <\/td>\\n<td>requester2<\/td>\\n<td > Pending review<\/td>\\n <td> https:\/\/url3\\n<\/td>\\n<\/tr><\/a> ”
\n]
\n}<\/p>\n