Install and connect Slack
Set up the Slack integration to allow P4 Code Review to send notifications to your Slack workspace.
Create or install a Slack app, assign the required permissions, and connect it to P4 Code Review. You can install the integration manually or from the Slack Marketplace.
Prerequisites
Before installing the Slack integration, ensure that:
-
You have admin or super user access in P4 Code Review
-
You have access to the Slack workspace where the integration will be installed.
-
You have permission to install apps in Slack, or approval from a Slack administrator.
-
You know the Slack channels that will receive notifications.
-
You have access to the P4 Code Review configuration file (
config.php) if required.
Overview
To connect Slack:
-
Create or install the Slack app.
-
Assign the required OAuth scopes.
-
Install the app to your Slack workspace.
-
Copy the bot token or generated configuration.
-
Add the configuration to P4 Code Review.
-
Verify that notifications are delivered successfully.
After completing these steps, P4 Code Review can post notifications to Slack.
Install options
You can connect Slack in one of two ways:
-
Manual setup (recommended): Create and configure a Slack app with the required permissions.
-
Install the Slack integration: Install a preconfigured app using the Add to Slack button.
Both methods install a Slack bot and provide the information required to connect P4 Code Review to Slack.
Manual setup provides full control over the Slack app configuration and supports all advanced features.
Create and configure a Slack app (manual setup)
Use manual setup if you need full control over configuration or require advanced features.
1. Create a Slack app
-
Go to the Slack API website.
-
Click Create New App.
-
Select From scratch.
-
Enter:
-
An application name (for example, P4 Code Review).
-
The Slack workspace where the app will be installed.
-
-
Click Create App.
2. Configure OAuth permissions
Configure the bot token permissions required for Slack integration.
-
In your Slack app, go to OAuth & Permissions.
-
Under Bot Token Scopes, add the required scopes.
Required scopes
-
chat:write- Post messages to channels. -
channels:read- Access public channel information. -
groups:read- Access private channel information.
Additional scopes for advanced features
-
users:read.email- Resolve users for @mentions. -
im:write- Send direct messages. -
files:write- Upload image attachments for previews.
-
These additional scopes enable advanced Slack integration features such as user mentions, direct messaging, and image previews.
3. Install the app
-
In OAuth & Permissions, click Install to <workspace-name>.
Where <workspace-name> is the name of your workspace.
-
Review the permissions.
-
Click Allow.
-
Copy the Bot User OAuth Token.
This token is added to P4 Code Review to connect to the Slack app.
4. Configure Slack in P4 Code Review
There are two ways to add the Slack configuration to P4 Code Review.
Option 1: Configure using System Information (recommended)
The configuration stored in System Information is the runtime source of truth. Settings saved in the System Information override values in config.php.
-
Open the user menu (top-right corner of P4 Code Review) and select System Information.
-
Click Configuration.
-
Click on the Slack tab to expand the options.
-
Add the following details:
-
Workspace ID - Add a unique name for the Slack Workspace. After you have added a Slack workspace in P4 Code Review, you cannot update the Workspace ID.
-
Bot Token - Enter the bot token (found in the Slack app) to authenticate this workspace.
-
(Optional) - Configure the additional settings. To learn more, see Configure Slack.
-
-
Save your changes.
After the workspace is created, configure additional options such as channel mappings and notification settings as required.
Option 2: Configure using data/config.php (legacy)
File-based configuration is supported for backward compatibility but will be phased out in a future release.
Add the Slack configuration manually in SWARM_ROOT/data/config.php
For example:
'slack' => [
'token' => 'xoxb-your-bot-token',
'project_channels' => [
'*all*' => ['your-channel-name']
],
],
To learn more about configuring Slack settings, see Configure Slack.
To learn more about configuring multiple Slack workspaces, see Manage Slack workspaces.
5. Verify the integration
After completing the configuration:
-
Create a review or update an existing review in P4 Code Review.
-
Confirm that a notification appears in Slack.
If notifications are not delivered:
-
Verify that the bot token is valid.
-
Confirm that the Slack app is installed in the correct workspace.
-
Verify that the required OAuth scopes are configured.
-
Check the Slack configuration in P4 Code Review.
Install the Slack integration
You can install the Slack integration directly from Perforce.
To install the integration:
-
Navigate to Slack Integration on the Perforce website.
-
Click Add to Slack button.
-
Select the workspace to integrate Slack with.
-
Click Allow.
-
Copy the generated Slack configuration.
-
Add the configuration to P4 Code Review:
-
System Information (recommended)
-
SWARM_ROOT/data/config.php(legacy).
-
After installation, configure your project-to-channel mappings and notification settings. To learn more, see Configure Slack (legacy) .