# Connecting to Slack

With the SonarQube Server integration with Slack, users can receive real-time notifications on analysis results directly in Slack. For more information, see [slack](https://docs.sonarsource.com/sonarqube-server/discovering/integrations/slack "mention").

To set up this feature, a SonarQube Server administrator must first connect your SonarQube Server instance to your Slack workspace. Once this initial setup is complete, users can subscribe to SonarQube Server notifications directly within their Slack account: see [slack](https://docs.sonarsource.com/sonarqube-server/user-guide/managing-your-account/subscribing-to-notifications/slack "mention").

{% hint style="info" %}
You can connect your Slack workspace to multiple SonarQube Server instances and you can connect your instance to multiple workspaces.
{% endhint %}

## Connecting your SonarQube instance to your Slack workspace

You must be an administrator of your SonarQube Server instance and of your Slack workspace.

### Step 1: Create the SonarQube Server app for Slack for your SonarQube instance

{% stepper %}
{% step %}
**Create the app**

1. In your SonarQube Server instance, go to **Administration** > **Configuration** > **General Settings** > **Integrations**.

<figure><img src="broken-reference" alt="Select the Start setup button to start the Slack integration setup."><figcaption></figcaption></figure>

2. In the Slack section, select **Start setup**. You are redirected to Slack.

<figure><img src="broken-reference" alt="Select in the dialog box the Slack workspace in which the app will be created."><figcaption></figcaption></figure>

3. Select your Slack workspace and select **Next**. The app’s **Basic Information** page opens.
   {% endstep %}

{% step %}
**Set up the app**

1. In the left navigation bar of the app, select **Features** > **Event Subscriptions**.

<figure><img src="broken-reference" alt="Select the Retry button to verify the Request URL used for the token-revoked event."><figcaption></figcaption></figure>

2. In **Enable Events** > **Request URL**, select **Retry**. The Request URL should now be verified.

<div align="left"><figure><img src="broken-reference" alt="If the operation was successful, the Request URL is marked as Verified." width="563"><figcaption></figcaption></figure></div>

3. In the bottom right corner of the page, select **Save Changes**.
   {% endstep %}

{% step %}
**Copy-paste the app parameters to SonarQube Server**

1. In the left navigation bar of the app, select **Settings** > **Basic Information**. You can see the **Client ID**, **Client Secret**, and **Signing Secret** parameters in the **App Credentials** section.

<figure><img src="broken-reference" alt="Copy-paste each of the following parameters to SonarQube Server: Client ID, Client Secret, Signing Secret."><figcaption></figcaption></figure>

2. Copy-paste each of these parameters from Slack to your Slack configuration in SonarQube Server.

<figure><img src="broken-reference" alt="Paste the following parameters from the Slack app to SonarQube Server: Client ID, Client Secret, Signing Secret."><figcaption></figcaption></figure>

3. Select **Save configuration**. Your SonarQube Server app for Slack is ready to be installed.
   {% endstep %}
   {% endstepper %}

### Step 2: Install the app on your Slack workspace

Once you have successfully created your SonarQube Server app for Slack, you can install it in your Slack workspace.

{% hint style="warning" %}
You must install the app through SonarQube Server as described below. Don't use another method.
{% endhint %}

To install the app on your Slack workspace:

1. In your SonarQube Server instance, go to **Administration** > **Configuration** > **General Settings** > **Integrations**.

<figure><img src="broken-reference" alt="Select the Install SonarQube for Slack button to install the app in your workspace."><figcaption></figcaption></figure>

2. Select the **Install SonarQube for Slack** button. You’re redirected to Slack.

<figure><img src="broken-reference" alt="Select the Slack workspace in which you want to install your app."><figcaption></figcaption></figure>

3. Select your workspace.
4. Select **Allow**. The app is installed in your workspace. Workspace users can now subscribe to Slack notifications on SonarQube events.

## Connecting your SonarQube instance to multiple workspaces <a href="#multiple-workspaces" id="multiple-workspaces"></a>

You can connect your SonarQube Server instance to multiple Slack workspaces. Once you have created and installed the SonarQube Server App for Slack in your first workspace as explained above in [#connecting-your-instance-to-your-slack-workspace](#connecting-your-instance-to-your-slack-workspace "mention"), you must change the settings of your SonarQube Server App for Slack to enable multiple workspaces. Once this is done, you can install the app in other workspaces as described in [#step-2-install-the-app-on-your-slack-workspace](#step-2-install-the-app-on-your-slack-workspace "mention") above.

To enable multiple workspaces in your app:

1. Open the SonarQube Server App in the Slack workspace in which you created it.
2. In the left navigation bar, select **Settings** > **Manage Distribution** and navigate to the bottom of the page.
3. In **Share Your App with Other Workspaces** > **Remove hard Coded Information**, select the **I’ve reviewed and removed any hard-coded information** option.

<figure><img src="broken-reference" alt="To connect your SonarQube Server to multiple instances, enable the I&#x27;ve reviewed... option."><figcaption></figcaption></figure>

4. Select the **Activate Public Distribution** button.

## Connecting a workspace to multiple SonarQube instances <a href="#multiple-sonarqube-instances" id="multiple-sonarqube-instances"></a>

You can connect the same Slack workspace to several SonarQube Server instances. To do so, you must configure different slash commands for each SonarQube Server app for Slack to differentiate them. The slash command must have the following format:

`/sonarqube-server<identifier>`

For example, if you want to connect your workspace to two instances, you may configure the slash command as follows:

* For the first instance: `/sonarqube-server` (default value)
* For the second instance: `/sonarqube-server-2`

{% hint style="warning" %}
Inform your end users to use the correct Slash command when subscribing to Slack notifications for SonarQube.
{% endhint %}

To configure the slash command of your SonarQube Server app:

1. In your Slack workspace, open the SonarQube Server app you want to configure.
2. In the left navigation bar, select **Features** > **Slash Commands**.

<figure><img src="broken-reference" alt="To connect the same workspace to several SonarQube instances, you must configure different slash commands for the  apps installed in the workspace."><figcaption></figcaption></figure>

2. Select the edit icon and change the slash command.

## Modifying your Slack configuration <a href="#modifying-configuration" id="modifying-configuration"></a>

If you modify the client ID, client secret or signing secret of your SonarQube Server app for Slack, you must update the change in SonarQube Server.

To update your Slack configuration in SonarQube Server:

1. In your SonarQube Server instance, go to **Administration** > **Configuration** > **General Settings** > **Integrations**.

<figure><img src="broken-reference" alt="Select the Edit button to change the Slack configuration parameters in SonarQube."><figcaption></figcaption></figure>

2. In the **Slack** section, in **App configuration details**, select the **Edit** button. The Slack configuration dialog opens.
3. Update the parameters and select the **Update configuration** button.

## Deleting your Slack configuration <a href="#deleting-configuration" id="deleting-configuration"></a>

You must delete both the Slack configuration in  your SonarQube Server instance and the SonarQube Server app.  Deleting the Slack configuration will delete all connections and Slack-related data on SonarQube Server based on this configuration.&#x20;

Proceed as follows:

1. In your SonarQube Server instance, go to **Administration** > **Configuration** > **General Settings** > **Integrations**.
2. In the **Slack** section, in **App configuration details**, select the dustbin icon.

<figure><img src="broken-reference" alt="Select the dustbin icon to delete the Slack configuration."><figcaption></figcaption></figure>

3. Confirm the deletion.
4. Open the SonarQube Server app in the Slack workspace in which you created it and delete it.

## Troubleshooting

### User is stuck in the Connect > Already Bound loop

The SonarQube Server app for Slack blocks the user from subscribing by asking every time to subscribe. This may happen if your organization uses Slack Enterprise and the app has been installed on your workspace via a `@SonarQube Server` command or directly from the Slack app configuration page (This is possible if the app is already installed on another enterprise’s workspace). The SonarQube Server app for Slack must be installed directly through SonarQube Server otherwise it won’t work properly. To fix this:

1. Uninstall the app from your Slack workspace.
2. In SonarQube Server, install the app in your workspace as described in [#multiple-workspaces](#multiple-workspaces "mention").

## Relates pages

[slack](https://docs.sonarsource.com/sonarqube-server/user-guide/managing-your-account/subscribing-to-notifications/slack "mention")\
[slack](https://docs.sonarsource.com/sonarqube-server/discovering/integrations/slack "mention")
