Bitbucket Pull Request SLA and Review Load Balancer
On a schedule, the flow finds open Bitbucket pull requests awaiting review past an SLA, balances assignment by reviewer load (skipping out-of-office reviewers), nudges assigned reviewers in Teams, and escalates stale PRs to the lead. Keeps code review fast and fairly distributed.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow keeps Bitbucket code review fast and fair. On a schedule it lists open pull requests, finds those that have waited past a configurable review SLA without an approval, picks a reviewer by round-robin load balancing (skipping anyone out of office), nudges that reviewer in a Microsoft Teams channel, and escalates genuinely stale PRs to the team lead by Outlook email. Review latency and uneven reviewer load slow delivery and burn people out; automated SLA enforcement plus fair assignment keeps the queue moving and equitable, with zero hardcoded values so it ports to any tenant by editing environment variables only.
Use Case
A development team wants every open PR reviewed within an SLA window, reviewer workload spread evenly across an available pool, out-of-office reviewers skipped, and any PR that goes stale escalated to the lead so nothing silently rots in the review queue.
Flow Architecture
Every 4 Hours During Work Hours
RecurrenceRuns the review-SLA sweep on a schedule.
Initialize Config
Initialize variableBinds the review SLA hours, stale-escalation hours, and lead email from env vars.
Build Eligible Reviewer Pool
Filter arrayReviewer pool minus out-of-office reviewers; composes the available count so the round-robin never divides by zero.
Get Open Pull Requests
Bitbucket - ListPullRequestsLists OPEN PRs for the configured repo.
Process Each Open PR
Apply to eachComputes PR age in hours, filters already-approved reviewers, and round-robin picks one eligible reviewer using the PR id.
Nudge Assigned Reviewer
Teams - PostMessageToConversationWhen a PR is past SLA and unreviewed, posts a channel nudge to the load-balanced reviewer.
Escalate Stale PR To Lead
Outlook - SendEmailV2When the PR is also past the stale threshold, emails the lead (High importance) about the stale PR.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_BitbucketWorkspace | String | your-workspace | Bitbucket workspace slug (account path param). |
| flowlibs_BitbucketRepoSlug | String | <configure> | Repository slug (slug path param). |
| flowlibs_ReviewSlaHours | String | 8 | Hours a PR may await review before it is past SLA. |
| flowlibs_StaleEscalationHours | String | 24 | Hours after which an unreviewed PR is escalated to the lead. |
| flowlibs_ReviewerPool | String | alice@yourcompany.com,bob@yourcompany.com,carol@yourcompany.com | Comma-separated eligible reviewers for round-robin. |
| flowlibs_OutOfOfficeReviewers | String | carol@yourcompany.com | Comma-separated reviewers to skip (out of office). |
| flowlibs_LeadEscalationEmail | String | lead@yourcompany.com | Lead who receives stale-PR escalations. |
| flowlibs_TeamsGroupId | String | <your-team-id> | Target Teams team for the nudge. |
| flowlibs_TeamsChannelId | String | <your-channel-id> | Target Teams channel for the nudge. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Bitbucket | shared_bitbucket | ListPullRequests |
| Microsoft Teams | shared_teams | PostMessageToConversation |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Cadence
- Change the Recurrence frequency/interval to match working hours (e.g. hourly during 9-5).
- SLA & escalation windows
- Tune flowlibs_ReviewSlaHours and flowlibs_StaleEscalationHours.
- Reviewer pool & OOO
- Maintain flowlibs_ReviewerPool / flowlibs_OutOfOfficeReviewers (ideally fed from an HR/OOF source).
- Smarter balancing
- Replace round-robin with load-weighted selection (open reviews per person from a Dataverse table) or CODEOWNERS-based routing.
- De-dupe nudges
- Add a Dataverse ledger keyed by PR id so the same PR is not re-nudged every run.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01PR age in hours
Hours the PR has been open.
EXPR.02Round-robin reviewer
Even distribution via mod(PR id, pool size).
EXPR.03Past SLA and unreviewed gate
Acts only past SLA with no approval yet.
Customize & download
Generate a ready-to-import copy of this solution with your environment-variable values baked in — available on Base, Pro, or Team.
Upgrade to customize
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.