Conditional Slack Triggers

I have a slack integration set up to notify a channel when there’s code reviews that are created, but I don’t see a way to customize when these triggers are sent beyond just always sent on “after-mkreview” and “after-editreview”. Am I missing something, do I set this stuff on the Slack end?


I would like to:

  1. Be able to set and customize the message.

For instance, if I could reference the reviewers in the message, I could @ them in slack to make sure it’s seen by them.

  1. Be able to send the message conditionally.

For instance, I want the channel to get a notification when a code review is marked as “Under Review”. When the status changes to “Rework Required” or “Approved”, I don’t want the notification to be sent, but if it goes from “Rework Required” to “Under Review”, then I want “Code review edited” to trigger.

Adding onto this: the main problem I’m trying to solve is our engineers need to know when they need to review something. Typically we would setup email notifications for when a review is requested from someone, or have a dashboard to see all the PRs that need attention.

We couldn’t find any email notifications, so I created the slack integration. But with this, we can’t even see who the reviewers are! There is such very little information in this message. There isn’t even a link to the PR!

The reality is, upon seeing this, I would need to open up the web portal, find the PR with this name, then check if I’m a reviewer or not.

Thanks for this feedback.

Customisation of the message:
I believe this level of customisation to the message that is posted in Slack would be possible on a self-hosted solution, but not available currently on the Cloud. This is very valid feedback and I will be sharing it with the development team to see what improvements can be made.

Send the message conditionally:
To get the events to trigger only on certain conditions, you would need to use filters. Please see the detailed triggers reference for the filters that can be used for the mkreview and editreview triggers.

Hope this helps!

Hi Ollie, in my support ticket you mentioned using webhooks and a custom server to do things like sending out email notifications as that’s not supported right now. I tried doing this (which also addresses the two problems of filtering + customizing messages) but it still has some shortcomings due to the lack of information being sent:

  1. There’s no one field that lists all the reviewers. PLASTIC_REVIEW_ASSIGNEE only lists a single reviewer. This means that when a code review status is updated, I don’t have access to who all the reviewers are in order to notify them.
  2. Moreover, if there is a user group like “Developers”, it doesn’t give the emails or any details of who’s in that user group. This means I would need to hardcode this information in the custom webhook server.
  3. It’s a little unclear as to when a code review is created. PLASTIC_REVIEW_ACTION is not set when a code review is created, which is unexpected to me.
  4. There’s no URL to the PR, which adds some inconvenience to the reviewer who needs to find the PR.

As an immediate and actionable ask, would it be possible for Unity to add all of the reviewers as a comma separated list in the webhook data? And ideally, if Unity could resolve the user group aliases on the backend side so that “Developers” for instance gets expanded into “developerA@company.com, developerB@company.com”… this would become a viable workflow for us.

I would also like to request that PLASTIC_REVIEW_ACTION be set when a code review is created, and a URL pointing to the review (instead of just the review ID) be added as well.

Here’s some of the data I’m seeing:

Code Review is created:

Received webhook:  {
  PLASTIC_USER: 'author@company.com',
  PLASTIC_CLIENTMACHINE: 'Server:production-east-us-01',
  PLASTIC_SERVER: 'organization@production-east-us-01:port',
  PLASTIC_REVIEW_ID: '26138',
  PLASTIC_REPOSITORY_NAME: 'chibi-hz',
  PLASTIC_REVIEW_TITLE: 'Testing Webhook',
  PLASTIC_REVIEW_STATUS: 'Under review',
  PLASTIC_REVIEW_TARGET_TYPE: 'branch',
  PLASTIC_REVIEW_TARGET: '/main/test',
  INPUT: '[]',
  content: 'New code review `Testing Webhook` created\n'
}

For each reviewer, there is then a separate webhook trigger with:
PLASTIC_REVIEW_ACTION: ‘add reviewer’,
PLASTIC_REVIEW_ACTION_INFO: ‘reviewer@company.com’,
PLASTIC_REVIEW_ASSIGNEE: ‘reviewer@company.com’,

Code Review is edited:

Received webhook:  {
  PLASTIC_USER: 'author@company.com',
  PLASTIC_CLIENTMACHINE: 'Server:production-east-us-01',
  PLASTIC_SERVER: 'organization@production-east-us-01:port',
  PLASTIC_REVIEW_ID: '26138',
  PLASTIC_REPOSITORY_NAME: 'chibi-hz',
  PLASTIC_REVIEW_TITLE: 'Testing Webhook (test renaming)',
  PLASTIC_REVIEW_STATUS: 'Under review',
  PLASTIC_REVIEW_TARGET_TYPE: 'branch',
  PLASTIC_REVIEW_TARGET: '/main/test',
  PLASTIC_REVIEW_ACTION: 'edit title',
  PLASTIC_REVIEW_ACTION_INFO: "'Testing Webhook (test renaming)'",
  PLASTIC_REVIEW_COMMENT_ACTION: '',
  PLASTIC_REVIEW_COMMENT: '',
  INPUT: '[]',
  content: 'New comment to the review `Testing Webhook (test renaming)`\nUnder review'
}

I just wanted to update you that “multiple reviewers in the trigger payload” has now been raised as a task for the development team and I will keep you informed of progress as I receive it.

1 Like

Hey Ollie, following up on this about the other concerns:

"if Unity could resolve the user group aliases on the backend side so that “Developers” for instance gets expanded into “developerA@company.com, developerB@company.com”… this would become a viable workflow for us.

  1. I’d like for there to be a way to turn a user group into a set of users. I thought I could do this in the REST API since that would work too if you guys don’t resolve it on your end, but I didn’t see an API for this.

  2. I would also like to request that PLASTIC_REVIEW_ACTION be set when a code review is created, and a URL pointing to the review (instead of just the review ID) be added as well.