Slack Configuration

For using the Slack-related features of the Pull Request Analytics app, the Bitbucket administrator has to configure the Slack settings once. This includes creating a Slack app for the Pull Request Analytics app in your workspace and transferring the necessary parameters from this Slack app into the Pull Request Analytics configuration. These steps are described below.

Please notice that the Slack app Pull Request Analytics will be local to your workspace and not public and thus can only be seen in your workspace.

To reuse the Slack application in other workspaces, follow the instructions on our separate Wiki page after you have created the Slack app below.

Steps to configure the Slack app for Pull Request Analytics

You have the option to reference the instructional video below and/or the written steps listed following the video.

 

1. Create a new Slack app

Go to Bitbucket Admin → PR Analytics, click New and follow the link under Create Slack app:

 

2. Enter the Slack app details

In the dialog Create a Slack app (https://api.slack.com/apps), enter a name and choose your Slack workspace for the new Slack app:

Then, click Create App.

 

3. Enable interactive components

Go to Interactivity & Shortcuts, toggle ON and use the following value for the field Request URL:

Request URL: https://YOUR_BITBUCKET_SERVER/rest/pra4bbs/1.0/slack/action

Then, click Save Changes.

 

 

4. Create Slash commands

To communicate with the Bitbucket app by using Slack commands, these need to be configured under Slash Commands. There, click Create New Command:

Please notice that using Slack commands for this app requires that your Bitbucket instance is accessible from the public internet so that Slack can access it.
You can still use personal and repository-level notifications even if your Bitbucket is behind a firewall.

 

Then, fill in the following parameters and click Save:

Command: /pra

Request URL: https://YOUR_BITBUCKET_SERVER/rest/pra4bbs/1.0/slack/pra

 



5. Configure the bot user

Under App Home, fill in the following parameters:

Display Name: Pull Request Analytics

Default username: pra

 

 

Then, click Save. Afterwards, enable Always Show My Bot as Online:

 

 

 


6. Subscribe to event subscriptions

Go to Event Subscriptions, toggle Enable Events to ON and enter the following Request URL:

Request URL: https://YOUR_BITBUCKET_SERVER/rest/pra4bbs/1.0/slack/event

Then, subscribe to the mentioned bot events.

Finally, click Save Changes. (if events aren’t saved yet)

 

 

7. Set up OAuth & Permissions

In the menu OAuth & Permissions, add a redirect URL:

Redirect URLs: https://YOUR_BITBUCKET_SERVER/rest/pra4bbs/1.0/oauth

 

 

Then, click on Save URLs.

Add the following scopes (Bot and User Token Scopes) which the Pull Request Analytics app needs:

 

 

Finally, click on Install App to Workspace.

 

 

 

8. Go back to Bitbucket and fill in the app and OAuth credentials

Go in Slack API to Basic Information and fill in the app credentials fields to the Bitbucket app in your Bitbucket:

 

 

Go to OAuth & Permissions and fill in the OAuth tokens to the Bitbucket app:

 

 

Then, click Save.

 

 

9. Verify Slack connection in Bitbucket app

After you entered all tokens, you should see a Connection status: CONNECTED:

 

Then, please click on Authenticate yourself and you should see User status: CONNECTED:

 

10. Verify Slack command

Now, call /pra in one of your channels and you should see the following output if everything works:

 

 

Congrats, everything works now

 

 

Possible problems

Problem: OAuth redirect fails

After clicking “Authenticate yourself”, the following error comes up:

Solution: OAuth redirect fails

Either the OAuth redirect URL was not saved (click “Save URLs”) or is wrong. Double-check that you have configured the redirect URL correctly. It should have the form

https://YOUR_BITBUCKET_SERVER/rest/pra4bbs/1.0/oauth

Also watch out if the protocol is correct (https:// vs. http://).

 

 

Remove the app:

It’s a pity If you encountered any issues or missing features, let us know via our support email. But if you still like to remove the app, just navigate to your App directory via {your_workspace}.slack.com/apps, select the app, and click on the button “Remove App” and delete the connection in the Bitbucket admin section → PR Analytics.